sfsdf
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-23 00:21:47 +02:00
parent ac3ac0803b
commit 39bddf39e2
11 changed files with 375 additions and 71 deletions

View File

@@ -253,6 +253,96 @@ function module_tpl(string $module, string $name, array $data = []): void
}
}
function module_design(string $module): array
{
if (preg_match('/[^a-zA-Z0-9_\-]/', $module)) {
return [];
}
static $cache = [];
if (array_key_exists($module, $cache)) {
return $cache[$module];
}
$path = __DIR__ . '/../../modules/' . $module . '/design.json';
if (!is_file($path)) {
$cache[$module] = [];
return $cache[$module];
}
$raw = file_get_contents($path);
$decoded = is_string($raw) && $raw !== '' ? json_decode($raw, true) : null;
$cache[$module] = is_array($decoded) ? $decoded : [];
return $cache[$module];
}
function module_shell_header(string $module, array $options = []): string
{
$design = module_design($module);
$requestPath = app()->request()->path();
$title = trim((string) ($options['title'] ?? $design['title'] ?? ucfirst($module)));
$description = trim((string) ($options['description'] ?? $design['description'] ?? ''));
$eyebrow = trim((string) ($options['eyebrow'] ?? $design['eyebrow'] ?? 'Modul'));
$actions = is_array($options['actions'] ?? null) ? $options['actions'] : (is_array($design['actions'] ?? null) ? $design['actions'] : []);
$tabs = is_array($options['tabs'] ?? null) ? $options['tabs'] : (is_array($design['tabs'] ?? null) ? $design['tabs'] : []);
$html = '<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">';
$html .= '<header class="module-hero">';
$html .= '<div class="module-hero-top">';
$html .= '<div class="module-hero-copy">';
$html .= '<div class="eyebrow">' . e($eyebrow) . '</div>';
$html .= '<h1 class="module-title">' . e($title) . '</h1>';
if ($description !== '') {
$html .= '<p class="module-lead">' . e($description) . '</p>';
}
$html .= '</div>';
if ($actions !== []) {
$html .= '<div class="module-hero-actions">';
foreach ($actions as $action) {
if (!is_array($action)) {
continue;
}
$label = trim((string) ($action['label'] ?? ''));
$href = trim((string) ($action['href'] ?? ''));
if ($label === '' || $href === '') {
continue;
}
$variant = trim((string) ($action['variant'] ?? 'secondary'));
$class = $variant === 'ghost' ? 'module-button module-button--ghost' : 'module-button module-button--secondary';
$html .= '<a class="' . e($class) . '" href="' . e($href) . '">' . e($label) . '</a>';
}
$html .= '</div>';
}
$html .= '</div>';
if ($tabs !== []) {
$html .= '<nav class="module-tabs" aria-label="Modulnavigation">';
foreach ($tabs as $tab) {
if (!is_array($tab)) {
continue;
}
$label = trim((string) ($tab['label'] ?? ''));
$href = trim((string) ($tab['href'] ?? ''));
if ($label === '' || $href === '') {
continue;
}
$isActive = !empty($tab['active']) || $href === $requestPath;
$class = $isActive ? 'module-button module-button--tab-active' : 'module-button module-button--tab';
$html .= '<a class="' . e($class) . '" href="' . e($href) . '">' . e($label) . '</a>';
}
$html .= '</nav>';
}
$html .= '</header>';
return $html;
}
function module_shell_footer(): string
{
return '</div></div></div>';
}
/**
* HTML Escaping Helper.
*/