{{-- Left-column category navigation (Ozon-style): back-links up the tree, current category, and its children (or siblings for a leaf), collapsed after N. Вид — панель «Категории» со страницы продавца из макета редизайна. --}} @php $navItems = $children->isNotEmpty() ? $children : $siblings; $currentInList = $children->isEmpty() && $siblings->isNotEmpty(); // leaf → current highlighted inside the siblings list $collapseAfter = 8; $indent = $ancestors->isNotEmpty() ? 'ml-3' : ''; @endphp
Категории
{{-- Back-links up the tree --}} @foreach ($ancestors as $ancestor) {{ $ancestor->name }} @endforeach {{-- Current category (own header only when it has children of its own) --}} @unless ($currentInList)
{{ $category->name }}
@endunless {{-- Children (or siblings for a leaf), collapsed after N --}} @if ($navItems->isNotEmpty())
@foreach ($navItems as $i => $item) @php($isCurrent = $currentInList && $item->id === $category->id) = $collapseAfter && ! $isCurrent) x-show="expanded" x-cloak @endif class="rounded-[var(--radius-md)] px-3 py-[7px] text-[13.5px] leading-snug transition {{ $isCurrent ? 'bg-[var(--color-primary-soft)] font-bold text-[var(--color-primary)]' : 'text-[var(--color-slate)] hover:bg-[var(--color-canvas)]' }}"> {{ $item->name }} @endforeach @if ($navItems->count() > $collapseAfter) @endif
@endif