@php $limit = max(1, (int) ($s['limit'] ?? 6)); $categories = \App\Models\Category::query() ->active() ->withCount(['products' => fn ($query) => $query->where('is_active', true)]) ->orderBy('sort_order') ->limit($limit) ->get(); $style = $s['style'] ?? 'cream'; $sectionClass = match ($style) { 'sand' => 'section bg-sand', 'white' => 'section bg-white', 'dark' => 'section bg-ink', default => 'section', }; // Advanced appearance settings. Values are clamped here so blocks saved by // an older release keep working with the shipped defaults. $layout = ($s['layout'] ?? 'grid') === 'slider' ? 'slider' : 'grid'; $shape = ($s['image_shape'] ?? 'square') === 'circle' ? 'circle' : 'square'; $radius = max(0, min(80, (int) ($s['image_radius'] ?? 16))); $ratio = (string) ($s['image_ratio'] ?? '1/1'); $ratio = in_array($ratio, ['1/1', '4/3', '3/4', '16/10'], true) ? $ratio : '1/1'; $fit = ($s['image_fit'] ?? 'cover') === 'contain' ? 'contain' : 'cover'; $caption = ($s['caption_position'] ?? 'below') === 'overlay' ? 'overlay' : 'below'; $columns = max(2, min(6, (int) ($s['columns'] ?? 6))); $align = (string) ($s['align'] ?? 'start'); $align = in_array($align, ['start', 'center', 'end'], true) ? $align : 'start'; $showCount = (bool) ($s['show_count'] ?? true); $zoom = (bool) ($s['hover_zoom'] ?? true); $titleSize = max(10, min(32, (int) ($s['title_size'] ?? 13))); $weight = (string) ($s['title_weight'] ?? '700'); $weight = in_array($weight, ['400', '500', '600', '700', '800'], true) ? $weight : '700'; $fontFamily = trim((string) ($s['title_font'] ?? '')); $font = $fontFamily !== '' ? \App\Models\Font::query()->active()->where('family', $fontFamily)->first() : null; $fontStack = $font ? "'".str_replace("'", '', $font->family)."', var(--font)" : 'inherit'; $cardVars = implode('; ', [ '--cat-radius: '.$radius.'px', '--cat-img-radius: '.$radius.'px', '--cat-ratio: '.$ratio, '--cat-fit: '.$fit, '--cat-align: '.$align, '--cat-title-size: '.$titleSize.'px', '--cat-title-weight: '.$weight, '--cat-font: '.$fontStack, ]); @endphp @include('pages.blocks.partials.font', ['font' => $font]) @if ($categories->isNotEmpty())
@include('pages.blocks.partials.head', [ 'eyebrow' => $block->text('eyebrow'), 'title' => $block->text('title'), 'linkLabel' => $block->text('link_label'), 'linkUrl' => (string) ($s['link_url'] ?? ''), ]) @if ($layout === 'slider')
@foreach ($categories as $category) @include('pages.blocks.partials.category-card', [ 'category' => $category, 'shape' => $shape, 'caption' => $caption, 'align' => $align, 'zoom' => $zoom, 'cardVars' => $cardVars, 'showCount' => $showCount, ]) @endforeach
@else
@foreach ($categories as $category) @include('pages.blocks.partials.category-card', [ 'category' => $category, 'shape' => $shape, 'caption' => $caption, 'align' => $align, 'zoom' => $zoom, 'cardVars' => $cardVars, 'showCount' => $showCount, ]) @endforeach
@endif
@endif