Files
3dealer/resources/views/components/header.blade.php
T

212 lines
11 KiB
PHP
Raw Normal View History

{{-- No bottom border on the mobile homepage, so the header runs straight into the hero. --}}
<header @class(['sticky top-0 z-50 h-20 bg-neutral-200 border-b border-black lg:h-26', 'max-lg:border-b-0' => request()->routeIs('home')])>
<div class="flex items-center gap-4 px-5 max-lg:h-full sm:px-8 lg:gap-14 lg:px-10">
2026-07-31 17:41:55 +03:00
{{-- Logo --}}
<a href="{{ url('/'.app()->getLocale()) }}" class="shrink-0 lg:py-4">
2026-10-24 00:20:57 +03:00
<img src="/images/logo.png" alt="{{ config('app.name') }}" class="h-14 w-auto lg:h-18">
2026-07-31 17:41:55 +03:00
</a>
{{-- Primary nav --}}
2026-10-24 00:20:57 +03:00
<nav class="hidden lg:flex items-center gap-6 h-full">
2026-07-31 17:41:55 +03:00
{{-- Products (CSS-only hover dropdown) --}}
<div class="group relative h-full flex items-center">
<a href="{{ route('products') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline py-8">
<span>{{ __('storefront.nav.products') }}</span>
2026-07-31 17:41:55 +03:00
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-4 not-italic transition-transform group-hover:rotate-180">
<path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
</svg>
</a>
<div class="nav-dropdown">
@foreach($categories ?? [] as $category)
<a href="{{ route('category.show', ['id' => $category['id']]) }}">
{{ $category['name'] }}
2026-07-31 17:41:55 +03:00
</a>
@endforeach
2026-07-31 17:41:55 +03:00
</div>
</div>
2026-10-26 16:06:55 +02:00
{{-- FAQ --}}
<a href="{{ route('faq') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('storefront.nav.faq') }}</span></a>
2026-10-27 12:19:29 +02:00
{{-- Contact --}}
<a href="{{ route('contact') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('storefront.nav.contact') }}</span></a>
2026-07-31 17:41:55 +03:00
</nav>
2026-10-24 00:20:57 +03:00
{{-- Right side actions — language, wishlist and account move into the mobile menu below `lg` --}}
<div class="ml-auto flex items-center gap-3 lg:gap-8">
2026-07-31 17:41:55 +03:00
{{-- Language switcher --}}
@foreach ($altLocales ?? [] as $altLocale)
2026-10-24 00:20:57 +03:00
<a href="{{ $altLocale['url'] }}" class="hidden lg:block uppercase font-display font-extrabold text-sm hover:opacity-70 transition-opacity" hreflang="{{ $altLocale['code'] }}" aria-label="{{ $altLocale['name'] }}">
{{ $altLocale['code'] }}
</a>
@endforeach
{{-- Wishlist — always the guest page, which sends logged-in users on
to the account version, so the header doesn't depend on login --}}
<a
href="{{ route('wishlist') }}"
2026-10-24 00:20:57 +03:00
class="hidden lg:flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.account.nav_wishlist') }}"
@if (request()->routeIs('account.wishlist', 'wishlist')) aria-current="page" @endif
>
<x-ui.icon name="heart" :size="40" />
</a>
{{-- Account — always the account page; the auth middleware sends
guests to login. [data-account-link] is the island target shared
with the mobile menu's link. --}}
<a
data-account-link
href="{{ route('account') }}"
2026-10-24 00:20:57 +03:00
class="hidden lg:flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.nav.account') }}"
>
<x-ui.icon name="user" :size="40" />
</a>
2026-09-04 19:39:37 +03:00
{{-- Cart — opens the checkout module's drawer, no separate cart page --}}
<button
type="button"
class="relative flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
2026-10-24 00:20:57 +03:00
aria-label="{{ __('storefront.nav.cart') }}"
2026-09-04 19:39:37 +03:00
aria-haspopup="dialog"
data-controller="cart-count"
data-action="cart-count#open"
>
2026-07-31 17:41:55 +03:00
<x-ui.icon name="bag" :size="40" />
{{-- Island target: the count will come from the islands request
(Turbo Stream on #cart-badge). It's absolute inside the
fixed-size button, so showing it or going from 1 to 2 digits
never moves the header. Rule for every island: it may never
change the size of its container. --}}
2026-09-04 19:39:37 +03:00
<span
id="cart-badge"
2026-09-04 19:39:37 +03:00
data-cart-count-target="badge"
2026-10-24 00:20:57 +03:00
class="absolute -top-1 -right-2 text-sm font-bold leading-none"
2026-09-04 19:39:37 +03:00
hidden
>0</span>
</button>
2026-07-31 17:41:55 +03:00
{{-- Search --}}
<button
type="button"
popovertarget="search-overlay"
popovertargetaction="toggle"
class="flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.shop.search_label') }}"
>
2026-07-31 17:41:55 +03:00
<x-ui.icon name="search" :size="40" />
</button>
</div>
2026-10-24 00:20:57 +03:00
{{-- Burger — toggles the #mobile-nav menu below `lg`; its three lines
morph into an X while the menu is open (.burger in app.css). --}}
<button
type="button"
popovertarget="mobile-nav"
class="burger flex h-10 w-10.5 shrink-0 flex-col items-center justify-center gap-1.75 lg:hidden"
aria-label="{{ __('storefront.nav.menu') }}"
aria-controls="mobile-nav"
>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
</button>
2026-07-31 17:41:55 +03:00
</div>
<x-search-overlay />
2026-10-24 00:20:57 +03:00
{{--
Mobile menu — a [popover] (top layer, Escape and click-away close for
free) that drops down from under the header, opened and closed by the
burger above. The header is a fixed h-20 below `lg` so the menu can sit
at top-20. The top-to-bottom wipe and the burger → X morph live in
app.css (.mobile-menu, .burger). Display stays on the inner wrapper,
never on the popover itself, so the UA's closed-state display:none holds.
--}}
<nav
id="mobile-nav"
popover
aria-label="{{ __('storefront.nav.menu') }}"
class="mobile-menu fixed inset-x-0 top-20 bottom-auto m-0 max-h-[calc(100dvh-5rem)] w-full max-w-none overflow-y-auto border-0 bg-neutral-200 p-0 text-black"
2026-10-24 00:20:57 +03:00
>
<div class="flex flex-col gap-8 px-5 py-6 sm:px-8">
2026-10-24 00:20:57 +03:00
<ul class="flex flex-col gap-5 font-display font-extrabold italic">
<li class="flex flex-col gap-4">
<a
href="{{ route('products') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('products')])
@if (request()->routeIs('products')) aria-current="page" @endif
>
<span>{{ __('storefront.nav.products') }}</span>
<x-ui.icon name="arrow-right" :size="22" />
</a>
@if (count($categories ?? []))
<ul class="flex flex-col gap-3 border-l border-black pl-4 font-sans font-normal not-italic">
@foreach ($categories as $category)
<li>
<a href="{{ route('category.show', ['id' => $category['id']]) }}" class="underline-slide">{{ $category['name'] }}</a>
</li>
@endforeach
</ul>
@endif
</li>
<li>
<a
2026-10-27 12:19:29 +02:00
href="{{ route('faq') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('faq')])
@if (request()->routeIs('faq')) aria-current="page" @endif
2026-10-24 00:20:57 +03:00
>
2026-10-27 12:19:29 +02:00
<span>{{ __('storefront.nav.faq') }}</span>
2026-10-24 00:20:57 +03:00
<x-ui.icon name="arrow-right" :size="22" />
</a>
</li>
2026-10-26 16:06:55 +02:00
<li>
<a
2026-10-27 12:19:29 +02:00
href="{{ route('contact') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('contact')])
@if (request()->routeIs('contact')) aria-current="page" @endif
2026-10-26 16:06:55 +02:00
>
2026-10-27 12:19:29 +02:00
<span>{{ __('storefront.nav.contact') }}</span>
2026-10-26 16:06:55 +02:00
<x-ui.icon name="arrow-right" :size="22" />
</a>
</li>
2026-10-24 00:20:57 +03:00
</ul>
<ul class="flex flex-col gap-4 border-t border-black pt-6">
<li>
<a
href="{{ route('wishlist') }}"
2026-10-24 00:20:57 +03:00
class="inline-flex items-center gap-3 hover:opacity-70 transition-opacity"
@if (request()->routeIs('account.wishlist', 'wishlist')) aria-current="page" @endif
>
<x-ui.icon name="heart" :size="28" />
<span>{{ __('storefront.account.nav_wishlist') }}</span>
</a>
</li>
<li>
<a
data-account-link
href="{{ route('account') }}"
2026-10-24 00:20:57 +03:00
class="inline-flex items-center gap-3 hover:opacity-70 transition-opacity"
>
<x-ui.icon name="user" :size="28" />
<span>{{ __('storefront.nav.account') }}</span>
2026-10-24 00:20:57 +03:00
</a>
</li>
@foreach ($altLocales ?? [] as $altLocale)
<li>
<a href="{{ $altLocale['url'] }}" hreflang="{{ $altLocale['code'] }}" lang="{{ $altLocale['code'] }}" class="underline-slide">{{ $altLocale['name'] }}</a>
</li>
@endforeach
</ul>
</div>
</nav>
2026-07-31 17:41:55 +03:00
</header>