dsfdf
This commit is contained in:
@@ -286,27 +286,8 @@ function module_shell_header(string $module, array $options = []): string
|
||||
$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">';
|
||||
if ($title !== '' || $description !== '' || !empty($options['show_eyebrow'])) {
|
||||
$html .= '<div class="module-hero-copy">';
|
||||
if (!empty($options['show_eyebrow'])) {
|
||||
$html .= '<div class="eyebrow">' . e($eyebrow) . '</div>';
|
||||
}
|
||||
if ($title !== '') {
|
||||
$html .= '<h1 class="module-title">' . e($title) . '</h1>';
|
||||
}
|
||||
if ($description !== '') {
|
||||
$html .= '<p class="module-lead">' . e($description) . '</p>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
$html .= '<div class="module-hero-copy module-hero-copy--compact" aria-hidden="true"></div>';
|
||||
}
|
||||
|
||||
if ($actions !== []) {
|
||||
$html .= '<div class="module-hero-actions">';
|
||||
$renderActions = static function (array $actions): string {
|
||||
$html = '';
|
||||
foreach ($actions as $action) {
|
||||
if (!is_array($action)) {
|
||||
continue;
|
||||
@@ -324,27 +305,68 @@ function module_shell_header(string $module, array $options = []): string
|
||||
}
|
||||
$html .= '<a class="' . e($class) . '" href="' . e($href) . '">' . e($label) . '</a>';
|
||||
}
|
||||
return $html;
|
||||
};
|
||||
|
||||
$html = '<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">';
|
||||
$html .= '<header class="module-hero">';
|
||||
|
||||
if ($tabs !== [] || $actions !== []) {
|
||||
$html .= '<div class="module-hero-top module-hero-top--compact">';
|
||||
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>';
|
||||
}
|
||||
if ($actions !== []) {
|
||||
$html .= '<div class="module-hero-actions">' . $renderActions($actions) . '</div>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
} elseif ($title !== '' || $description !== '' || !empty($options['show_eyebrow'])) {
|
||||
$html .= '<div class="module-hero-copy">';
|
||||
if (!empty($options['show_eyebrow'])) {
|
||||
$html .= '<div class="eyebrow">' . e($eyebrow) . '</div>';
|
||||
}
|
||||
if ($title !== '') {
|
||||
$html .= '<h1 class="module-title">' . e($title) . '</h1>';
|
||||
}
|
||||
if ($description !== '') {
|
||||
$html .= '<p class="module-lead">' . e($description) . '</p>';
|
||||
}
|
||||
$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>';
|
||||
if ($title !== '') {
|
||||
$moduleTitle = trim((string) ($design['title'] ?? ucfirst($module)));
|
||||
$script = '(function(){'
|
||||
. 'var root=document.querySelector(".home-hero[data-module-name=' . json_encode($module, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '] .brand-copy h1");'
|
||||
. 'if(!root){return;}'
|
||||
. 'var old=root.querySelector(".module-page-context");'
|
||||
. 'if(old){old.remove();}'
|
||||
. 'root.textContent=' . json_encode($moduleTitle, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';'
|
||||
. 'var pageTitle=' . json_encode($title, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';'
|
||||
. 'if(pageTitle&&pageTitle!==' . json_encode($moduleTitle, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '){'
|
||||
. 'var span=document.createElement("span");'
|
||||
. 'span.className="module-page-context";'
|
||||
. 'span.textContent=" / "+pageTitle;'
|
||||
. 'root.appendChild(span);'
|
||||
. '}'
|
||||
. '})();';
|
||||
$html .= '<script>' . $script . '</script>';
|
||||
}
|
||||
|
||||
$html .= '</header>';
|
||||
|
||||
return $html;
|
||||
|
||||
Reference in New Issue
Block a user