Files
ABSDEV/resources/themes/saasland/views/partials/header.blade.php
T
2026-07-27 13:24:42 +01:00

84 lines
4.7 KiB
PHP

@php
$headerContent = $headerContent ?? [];
$configuredLinks = collect($headerContent['links'] ?? []);
$navigationLinks = $configuredLinks->isNotEmpty()
? $configuredLinks
: collect($primaryNavigation ?? [])->map(fn (array $item): array => [
'enabled' => true,
'label' => $item['label'] ?? 'Link',
'url' => $item['url'] ?? '#',
]);
$navigationLinks = $navigationLinks->filter(
fn (array $link): bool => filter_var($link['enabled'] ?? true, FILTER_VALIDATE_BOOL)
);
@endphp
<style>
.nav.cms-editable-header{display:grid;grid-template-columns:minmax(220px,1fr) auto minmax(220px,1fr);align-items:center;gap:2rem;width:100%;}
.cms-editable-header .desktop-nav{display:flex;align-items:center;justify-content:center;gap:2rem;}
.cms-editable-header .nav-actions{justify-self:end;display:flex;align-items:center;gap:1rem;}
.cms-editable-header .cms-brand{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
@media (max-width:900px){.nav.cms-editable-header{grid-template-columns:1fr auto}.cms-editable-header .desktop-nav{display:none}.cms-editable-header .nav-actions{grid-column:2}.cms-editable-header .account-name{display:none}}
</style>
<header class="nav cms-editable-header">
<a href="{{ $headerContent['brand_url'] ?? url('/') }}" class="logo cms-brand" aria-label="{{ $headerContent['brand_text'] ?? $siteTitle }} home">
@if (! empty($headerContent['logo_url'] ?? $logoUrl))
<img src="{{ $headerContent['logo_url'] ?? $logoUrl }}" alt="{{ $headerContent['brand_text'] ?? $siteTitle }}">
@else
{{ $headerContent['brand_text'] ?? $siteTitle }}
@endif
</a>
@if (filter_var($headerContent['show_navigation'] ?? true, FILTER_VALIDATE_BOOL) && $navigationLinks->isNotEmpty())
<nav class="desktop-nav" aria-label="Primary navigation">
@foreach ($navigationLinks as $link)
<a href="{{ $link['url'] ?? '#' }}">{{ $link['label'] ?? 'Link' }}</a>
@endforeach
</nav>
@endif
<div class="nav-actions">
@auth
@if (filter_var($headerContent['show_dashboard'] ?? true, FILTER_VALIDATE_BOOL) && Route::has('dashboard'))
<a class="nav-account" href="{{ route('dashboard') }}">{{ $headerContent['dashboard_label'] ?? 'Dashboard' }}</a>
@endif
@if (filter_var($headerContent['show_user_name'] ?? true, FILTER_VALIDATE_BOOL))
<div class="account-menu" x-data="{ accountOpen: false }">
<button type="button" class="account-trigger" @click="accountOpen = ! accountOpen" :aria-expanded="accountOpen">
<span>{{ str(auth()->user()->name)->substr(0, 1)->upper() }}</span>
<span class="account-name">{{ auth()->user()->name }}</span>
</button>
<div class="account-dropdown" x-show="accountOpen" @click.outside="accountOpen = false" x-cloak>
@if (Route::has('profile.edit'))<a href="{{ route('profile.edit') }}">Profile</a>@endif
@if (Route::has('settings.profile'))<a href="{{ route('settings.profile') }}">Account settings</a>@endif
@if (Route::has('logout'))
<form method="POST" action="{{ route('logout') }}">@csrf<button type="submit">Log out</button></form>
@endif
</div>
</div>
@endif
@else
@if (filter_var($headerContent['show_login'] ?? true, FILTER_VALIDATE_BOOL) && Route::has('login'))
<a class="nav-login" href="{{ route('login') }}">{{ $headerContent['login_label'] ?? 'Log in' }}</a>
@endif
@if (filter_var($headerContent['show_registration'] ?? true, FILTER_VALIDATE_BOOL) && Route::has('register'))
<a class="btn primary nav-register" href="{{ route('register') }}">{{ $headerContent['registration_label'] ?? 'Get started' }}</a>
@endif
@endauth
@if (filter_var($headerContent['show_mobile_menu'] ?? true, FILTER_VALIDATE_BOOL))
<button class="menu" type="button" aria-label="Toggle navigation" :aria-expanded="menuOpen" @click="menuOpen = ! menuOpen"><span></span><span></span><span></span></button>
@endif
</div>
</header>
@if (filter_var($headerContent['show_mobile_menu'] ?? true, FILTER_VALIDATE_BOOL))
<div class="mobile-nav" x-show="menuOpen" x-cloak>
@foreach ($navigationLinks as $link)
<a href="{{ $link['url'] ?? '#' }}">{{ $link['label'] ?? 'Link' }}</a>
@endforeach
</div>
@endif