feat: implement screendesign

This commit is contained in:
Björn Fromme
2026-03-16 11:59:12 +01:00
parent 39e6cc4d68
commit 4a2d1f4a02
84 changed files with 2807 additions and 2603 deletions
+24 -15
View File
@@ -52,14 +52,6 @@ class AppRuntime implements RuntimeExtensionInterface
return $this->intlExtension->formatCurrency($amount, 'EUR');
}
public function renderIcon(Environment $environment, string $icon, string $classes = 'w-5 h-5'): string
{
return $environment->render('_partials/_icon.html.twig', [
'icon' => $icon,
'class' => $classes,
]);
}
public function mapStatus(string $status): string
{
$status = strtoupper($status);
@@ -171,18 +163,35 @@ class AppRuntime implements RuntimeExtensionInterface
}
/**
* Generates a Gravatar URL for the given email address.
* Recursively collects labels of invalid form fields.
*
* @param string $email The email address
* @param int $size The size of the avatar in pixels (default: 80)
* @param FormView $form The form view to check
*
* @return string The Gravatar URL
* @return array<string> Array of invalid field labels
*/
public function getGravatarUrl(string $email, int $size = 80): string
public function collectInvalidFieldLabels(FormView $form): array
{
$hash = md5(strtolower(trim($email)));
$labels = [];
return sprintf('https://www.gravatar.com/avatar/%s?s=%d&d=404', $hash, $size);
foreach ($form->children as $child) {
$hasErrors = \count($child->vars['errors']) > 0;
$hasInvalidChildren = false === $child->vars['valid'];
if ($hasErrors || $hasInvalidChildren) {
$hasChildren = \count($child->children) > 0;
$isExpanded = $child->vars['expanded'] ?? false;
if ($hasChildren && false === $isExpanded && false === $hasErrors) {
// Nested form without own errors (e.g., address, bodyDimensions) - recurse
$labels = array_merge($labels, $this->collectInvalidFieldLabels($child));
} else {
// Leaf field, expanded choice, or compound field with own errors
$labels[] = $child->vars['label'] ?? $child->vars['name'];
}
}
}
return $labels;
}
/**