This commit is contained in:
49
resources/views/partials/home-slider.blade.php
Normal file
49
resources/views/partials/home-slider.blade.php
Normal file
@@ -0,0 +1,49 @@
|
||||
@php
|
||||
$slides = $slides ?? collect();
|
||||
$isSingle = $slides->count() <= 1;
|
||||
@endphp
|
||||
|
||||
<div class="pc-home-slider {{ $sliderClass ?? '' }}" data-home-slider>
|
||||
<div class="pc-home-slider-track">
|
||||
@forelse ($slides as $slide)
|
||||
@php
|
||||
$hasTitle = $slide->show_title && !empty($slide->title);
|
||||
$hasSubtitle = $slide->show_subtitle && !empty($slide->subtitle);
|
||||
$hasButton = $slide->show_button && !empty($slide->button_text) && !empty($slide->button_url);
|
||||
$hasContent = $hasTitle || $hasSubtitle || $hasButton;
|
||||
$altText = $hasTitle ? $slide->title : 'Слайд на главной странице';
|
||||
@endphp
|
||||
<article class="pc-home-slide {{ $loop->first ? 'is-active' : '' }}" data-home-slide>
|
||||
<img src="{{ $slide->image_url }}" alt="{{ $altText }}" loading="{{ $loop->first ? 'eager' : 'lazy' }}">
|
||||
<div class="pc-home-slide-overlay"></div>
|
||||
@if ($hasContent)
|
||||
<div class="pc-home-slide-content">
|
||||
@if ($hasTitle)
|
||||
<h2>{{ $slide->title }}</h2>
|
||||
@endif
|
||||
@if ($hasSubtitle)
|
||||
<p>{{ $slide->subtitle }}</p>
|
||||
@endif
|
||||
@if ($hasButton)
|
||||
<a class="pc-btn primary" href="{{ $slide->button_url }}">{{ $slide->button_text }}</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</article>
|
||||
@empty
|
||||
<article class="pc-home-slide is-active is-fallback" data-home-slide>
|
||||
<div class="pc-home-slide-overlay"></div>
|
||||
<div class="pc-home-slide-content">
|
||||
<h2>{{ $fallbackTitle ?? 'Собирайте ПК быстрее' }}</h2>
|
||||
<p>{{ $fallbackText ?? 'Загрузите баннеры в админке, чтобы вывести акции и подборки товаров на главной странице.' }}</p>
|
||||
@if (!empty($fallbackUrl))
|
||||
<a class="pc-btn primary" href="{{ $fallbackUrl }}">{{ $fallbackButton ?? 'Открыть каталог' }}</a>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<button class="pc-home-slider-btn is-prev" type="button" data-home-slider-prev aria-label="Предыдущий слайд" @disabled($isSingle)>‹</button>
|
||||
<button class="pc-home-slider-btn is-next" type="button" data-home-slider-next aria-label="Следующий слайд" @disabled($isSingle)>›</button>
|
||||
</div>
|
||||
Reference in New Issue
Block a user