This commit is contained in:
100
resources/views/components/header.blade.php
Normal file
100
resources/views/components/header.blade.php
Normal file
@@ -0,0 +1,100 @@
|
||||
@php
|
||||
$favoritesCount = count((array) session('favorites', []));
|
||||
$compareCount = count((array) session('compare', []));
|
||||
$cartCount = collect((array) session('cart', []))->sum(fn ($quantity) => (int) $quantity);
|
||||
$companyName = config('shop.company_name', config('app.name'));
|
||||
$navItems = [
|
||||
['label' => 'Главная', 'route' => route('home'), 'active' => request()->routeIs('home')],
|
||||
[
|
||||
'label' => 'Каталог',
|
||||
'route' => route('catalog.index'),
|
||||
'active' => request()->routeIs('catalog.*') || request()->routeIs('products.show') || request()->routeIs('search.index'),
|
||||
],
|
||||
['label' => 'О нас', 'route' => route('pages.about'), 'active' => request()->routeIs('pages.about')],
|
||||
[
|
||||
'label' => 'Доставка и оплата',
|
||||
'route' => route('pages.shipping-payment'),
|
||||
'active' => request()->routeIs('pages.shipping-payment'),
|
||||
],
|
||||
['label' => 'Контакты', 'route' => route('pages.contacts'), 'active' => request()->routeIs('pages.contacts')],
|
||||
];
|
||||
@endphp
|
||||
|
||||
<header class="pc-header pc-animate" style="--delay: 0s">
|
||||
<input type="checkbox" id="pc-mobile-menu-toggle" class="pc-mobile-menu-toggle">
|
||||
<label for="pc-mobile-menu-toggle" class="pc-hamburger" aria-label="Меню">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</label>
|
||||
<div class="pc-mobile-menu-head">
|
||||
<label for="pc-mobile-menu-toggle" class="pc-mobile-menu-close" aria-label="Закрыть меню">×</label>
|
||||
</div>
|
||||
<div class="pc-header-left">
|
||||
<a class="pc-logo" href="{{ route('home') }}">
|
||||
<span class="pc-logo-mark"></span>
|
||||
{{ $companyName }}
|
||||
</a>
|
||||
<a class="pc-btn pc-catalog-btn" href="{{ route('catalog.index') }}">Каталог</a>
|
||||
</div>
|
||||
<div class="pc-header-center">
|
||||
<form class="pc-search" action="{{ route('search.index') }}" method="get">
|
||||
<input type="text" name="q" placeholder="Поиск товаров по наименованию" value="{{ request('q') }}" />
|
||||
<button class="pc-search-submit" type="submit" aria-label="Искать">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M15.5 14h-.79l-.28-.27a6 6 0 1 0-.71.71l.27.28v.79L20 20.5 21.5 19 15.5 14zm-5.5 0A4.5 4.5 0 1 1 10 5a4.5 4.5 0 0 1 0 9z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="pc-header-icons">
|
||||
<a class="pc-icon-link" href="{{ route('favorites.index') }}" aria-label="Избранное">
|
||||
<span class="pc-icon">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M12 20s-7-4.5-9-9c-1.2-2.7.7-6 4.2-6 2 0 3.2 1 3.8 2 0.6-1 1.8-2 3.8-2 3.5 0 5.4 3.3 4.2 6-2 4.5-9 9-9 9z"></path>
|
||||
</svg>
|
||||
@if ($favoritesCount > 0)
|
||||
<span class="pc-icon-count">{{ $favoritesCount }}</span>
|
||||
@endif
|
||||
</span>
|
||||
<span class="pc-icon-label">Избранное</span>
|
||||
</a>
|
||||
<a class="pc-icon-link" href="{{ route('compare.index') }}" aria-label="Сравнение">
|
||||
<span class="pc-icon">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M5 4h3v16H5zM16 4h3v16h-3zM10.5 8h3v12h-3z"></path>
|
||||
</svg>
|
||||
@if ($compareCount > 0)
|
||||
<span class="pc-icon-count">{{ $compareCount }}</span>
|
||||
@endif
|
||||
</span>
|
||||
<span class="pc-icon-label">Сравнение</span>
|
||||
</a>
|
||||
<a class="pc-icon-link" href="{{ route('cart.index') }}" aria-label="Корзина">
|
||||
<span class="pc-icon">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M6 6h14l-2 9H8L6 6zm-2-2h3l1 2h-4zM9 20a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm8 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"></path>
|
||||
</svg>
|
||||
@if ($cartCount > 0)
|
||||
<span class="pc-icon-count">{{ $cartCount }}</span>
|
||||
@endif
|
||||
</span>
|
||||
<span class="pc-icon-label">Корзина</span>
|
||||
</a>
|
||||
<a class="pc-icon-link" href="{{ auth()->check() ? route('account') : route('login') }}" aria-label="Личный кабинет">
|
||||
<span class="pc-icon">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M12 12a4 4 0 1 0-4-4 4 4 0 0 0 4 4zm0 2c-4.4 0-8 2.2-8 5v1h16v-1c0-2.8-3.6-5-8-5z"></path>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="pc-icon-label">{{ auth()->check() ? 'Кабинет' : 'Войти' }}</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="pc-header-nav" aria-label="Разделы сайта">
|
||||
@foreach ($navItems as $item)
|
||||
<a class="pc-header-nav-link {{ $item['active'] ? 'is-active' : '' }}" href="{{ $item['route'] }}">
|
||||
{{ $item['label'] }}
|
||||
</a>
|
||||
@endforeach
|
||||
</nav>
|
||||
</header>
|
||||
Reference in New Issue
Block a user