Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m55s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m20s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m44s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m13s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m13s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m0s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 43s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s
Bleibendes Inertia-Layout (PortalFrame) mit festem Seitenkopf-Bereich; PageHeader teleportiert dorthin, AppLayout meldet Titel und Seitenvorlage (default/medium/narrow/app). Seiten ohne Kopf bekommen einen vom Rahmen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
125 lines
6 KiB
Vue
125 lines
6 KiB
Vue
<script setup>
|
||
import { computed } from 'vue';
|
||
import { Link, usePage } from '@inertiajs/vue3';
|
||
import { ChevronRight } from '@lucide/vue';
|
||
import AppIcon from '@/components/AppIcon.vue';
|
||
import { registerHeader, useFrame } from '@/lib/frame';
|
||
|
||
/**
|
||
* Einheitlicher Seitenkopf: Pfad, Titel, Unterzeile und Aktionen rechts.
|
||
* Die Gestaltung ist im Backend wählbar (Erscheinungsbild → Farben → Seitenköpfe):
|
||
* band (Standard), band_icon, icon, bold.
|
||
*/
|
||
const props = defineProps({
|
||
title: { type: String, required: true },
|
||
description: { type: String, default: '' },
|
||
breadcrumbs: { type: Array, default: () => [] }, // [{ label, href }]
|
||
/** Symbol des Bereichs (Lucide-Name); leer = Symbol des passenden Menüpunkts */
|
||
icon: { type: String, default: null },
|
||
/** intern: vom Rahmen selbst gezeigter Kopf (Seite ohne eigenen) */
|
||
auto: { type: Boolean, default: false },
|
||
});
|
||
|
||
const page = usePage();
|
||
const variant = computed(() => page.props.branding?.page_header ?? 'band');
|
||
|
||
// Im Portalrahmen erscheint der Kopf in dessen festem Bereich unter dem Menü – immer über die volle
|
||
// Breite, ausgerichtet an der Breite der Seitenvorlage. Außerhalb des Rahmens steht er an Ort und Stelle.
|
||
const frame = useFrame();
|
||
const inFrame = !!frame && !props.auto;
|
||
if (inFrame) registerHeader(frame);
|
||
const maxWidth = computed(() => frame?.maxWidth ?? 'max-w-[1440px]');
|
||
|
||
const isBand = computed(() => variant.value === 'band' || variant.value === 'band_icon');
|
||
const withIcon = computed(() => variant.value === 'band_icon' || variant.value === 'icon');
|
||
|
||
// Passender Menüpunkt – aktiv markiert oder, sonst, der längste, mit dem die Adresse beginnt
|
||
const menuItem = computed(() => {
|
||
const items = page.props.navigation ?? [];
|
||
|
||
for (const item of items) {
|
||
const child = (item.children ?? []).find((c) => c.active);
|
||
if (child) return { icon: child.icon ?? item.icon, area: item.label, label: child.label };
|
||
if (item.active) return { icon: item.icon, area: null, label: item.label };
|
||
}
|
||
|
||
const path = (page.url ?? '').split(/[?#]/)[0];
|
||
let best = null;
|
||
|
||
for (const item of items) {
|
||
for (const entry of [item, ...(item.children ?? [])]) {
|
||
const href = entry.href ?? '';
|
||
if (href.length > 1 && href.startsWith('/') && (path === href || path.startsWith(`${href}/`)) && (!best || href.length > best.href.length)) {
|
||
best = { href, icon: entry.icon ?? item.icon, area: entry === item ? null : item.label, label: entry.label };
|
||
}
|
||
}
|
||
}
|
||
|
||
return best;
|
||
});
|
||
|
||
const pageIcon = computed(() => props.icon ?? menuItem.value?.icon ?? null);
|
||
// Kleine Bereichszeile über dem Titel (nur „Kräftiger Titel“, wenn es keinen Pfad gibt)
|
||
const eyebrow = computed(() => menuItem.value?.area ?? (menuItem.value && menuItem.value.label !== props.title ? menuItem.value.label : null));
|
||
const showEyebrow = computed(() => variant.value === 'bold' && !props.breadcrumbs.length && !!eyebrow.value);
|
||
</script>
|
||
|
||
<template>
|
||
<Teleport to="#ih-page-header" defer :disabled="!inFrame">
|
||
<header :class="[isBand ? 'border-b bg-card' : '', inFrame || auto ? '' : 'mb-6']">
|
||
<div
|
||
class="mx-auto flex flex-wrap justify-between gap-y-3"
|
||
:class="[
|
||
inFrame || auto ? `${maxWidth} px-4 lg:px-6` : '',
|
||
isBand ? 'items-center gap-x-8 py-4' : 'gap-x-6',
|
||
!isBand && (inFrame || auto) ? 'pt-6 lg:pt-7' : '',
|
||
variant === 'icon' ? 'items-center border-b pb-5' : '',
|
||
variant === 'bold' ? 'items-end' : '',
|
||
]"
|
||
>
|
||
<div class="flex min-w-0 items-center" :class="withIcon ? 'gap-3.5' : 'gap-3'">
|
||
<slot name="leading">
|
||
<span
|
||
v-if="withIcon && pageIcon"
|
||
class="grid shrink-0 place-items-center rounded-lg bg-brand-soft text-brand-text"
|
||
:class="variant === 'icon' ? 'size-12' : 'size-10'"
|
||
aria-hidden="true"
|
||
>
|
||
<AppIcon :name="pageIcon" :class="variant === 'icon' ? 'size-6' : 'size-5'" :stroke-width="1.75" />
|
||
</span>
|
||
</slot>
|
||
<div class="min-w-0">
|
||
<nav v-if="breadcrumbs.length" class="mb-0.5 flex flex-wrap items-center gap-1 text-[13px] text-muted-foreground" aria-label="Brotkrumen">
|
||
<template v-for="(crumb, index) in breadcrumbs" :key="crumb.href">
|
||
<ChevronRight v-if="index" class="size-3.5" />
|
||
<Link :href="crumb.href" class="hover:text-foreground hover:underline">{{ crumb.label }}</Link>
|
||
</template>
|
||
</nav>
|
||
<p v-else-if="showEyebrow" class="mb-1 text-xs font-semibold tracking-[0.08em] text-brand-text uppercase">{{ eyebrow }}</p>
|
||
<h1
|
||
class="leading-tight tracking-tight"
|
||
:class="{
|
||
'text-2xl font-semibold': isBand,
|
||
'text-[26px] font-semibold': variant === 'icon',
|
||
'text-3xl font-bold': variant === 'bold',
|
||
}"
|
||
>
|
||
{{ title }}
|
||
</h1>
|
||
<span v-if="variant === 'bold'" class="mt-2.5 block h-[3px] w-10 rounded-full bg-brand" aria-hidden="true" />
|
||
<p
|
||
v-if="description || $slots.description"
|
||
class="max-w-3xl text-muted-foreground"
|
||
:class="variant === 'bold' ? 'mt-2.5 text-[15px]' : 'mt-0.5 text-sm'"
|
||
>
|
||
<slot name="description">{{ description }}</slot>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<div v-if="$slots.actions" class="flex w-full flex-wrap items-center gap-2 sm:w-auto">
|
||
<slot name="actions" />
|
||
</div>
|
||
</div>
|
||
</header>
|
||
</Teleport>
|
||
</template>
|