المعرض
gallery-16
شريط مقسوم: العنوان والوصف في جانب، وشريحتان مربعتان في كل مرة تمتدان خارج حافة الصفحة، مع الأسهم والنقاط في الأسفل.
{{--
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...];
leave src empty to show a placeholder.
Split layout: heading and description on the start side, two square
slides per view on the end side running off the page edge (one on
mobile), the arrow pair and the dots below the slider.
<x-ui.blocks.gallery-16
heading="Our work"
description="A few recent projects."
:images="[
['src' => '/images/gallery/1.jpg', 'alt' => 'Photo 1'],
['src' => '/images/gallery/2.jpg', 'alt' => 'Photo 2'],
['src' => '/images/gallery/3.jpg', 'alt' => 'Photo 3'],
]"
previous-label="Previous image"
next-label="Next image"
/>
--}}
@props([
'heading' => 'Image Gallery',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'images' => [
['src' => null, 'alt' => 'Placeholder image 1'],
['src' => null, 'alt' => 'Placeholder image 2'],
['src' => null, 'alt' => 'Placeholder image 3'],
['src' => null, 'alt' => 'Placeholder image 4'],
['src' => null, 'alt' => 'Placeholder image 5'],
['src' => null, 'alt' => 'Placeholder image 6'],
['src' => null, 'alt' => 'Placeholder image 7'],
],
'previousLabel' => 'Previous slide',
'nextLabel' => 'Next slide',
'dotLabel' => 'Go to slide',
])
{{-- The slider column is a size container: slides are sized in cqw (its
width), while the carousel itself is pulled out to the page edge with a
negative end margin so the slides run off it. The controls row is held
back to the column width. --}}
<section {{ $attributes->merge(['class' => 'w-full overflow-hidden bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto grid max-w-7xl grid-cols-1 gap-12 md:grid-cols-2 md:gap-20">
<div class="flex flex-col justify-center gap-3 md:gap-4 md:pb-24">
<h2 class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
<p class="text-muted-foreground md:text-lg">{{ $description }}</p>
</div>
<div class="@container min-w-0">
<x-ui.carousel :arrows="false" track="gap-6 md:gap-8"
class="-me-[max(5vw,calc((100vw_-_80rem)/2))]">
@foreach ($images as $image)
<x-ui.carousel.item
class="relative aspect-square basis-[84cqw] overflow-hidden bg-muted md:basis-[calc(50cqw_-_1.25rem)]">
@if (!empty($image['src']))
<img src="{{ $image['src'] }}" alt="{{ $image['alt'] ?? '' }}"
loading="lazy" class="absolute inset-0 size-full object-cover">
@else
<div role="img" aria-label="{{ $image['alt'] ?? '' }}"
class="absolute inset-0 flex items-center justify-center text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round"
class="size-10 md:size-12" aria-hidden="true">
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
<circle cx="9" cy="9" r="2" />
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
</svg>
</div>
@endif
</x-ui.carousel.item>
@endforeach
<x-slot:controls>
<div class="mt-8 flex w-[100cqw] md:mt-12 items-center justify-between gap-4">
<div class="flex gap-4">
<x-ui.button variant="outline" size="icon" data-ui-carousel-prev
aria-label="{{ $previousLabel }}" class="size-12 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="size-6 rtl:rotate-180" aria-hidden="true">
<path d="m12 19-7-7 7-7" />
<path d="M19 12H5" />
</svg>
</x-ui.button>
<x-ui.button variant="outline" size="icon" data-ui-carousel-next
aria-label="{{ $nextLabel }}" class="size-12 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="size-6 rtl:rotate-180" aria-hidden="true">
<path d="M5 12h14" />
<path d="m12 5 7 7-7 7" />
</svg>
</x-ui.button>
</div>
<div data-ui-carousel-dots data-label="{{ $dotLabel }}"
class="flex flex-wrap justify-end gap-2"></div>
</div>
</x-slot:controls>
</x-ui.carousel>
</div>
</div>
</section>
التثبيت
php artisan ui:add-block gallery-16
أمر واحد يثبّت ملف Blade الخاص بالقالب وكل مكوّن يعتمد عليه. اعرضه في تخطيطك كالتالي
<x-ui.blocks.gallery-16
/>.
1. ثبّت المكونات المطلوبة
php artisan ui:add button carousel
2. حزم خارجية
- composer:
gehrisandro/tailwind-merge-laravel
3.
انسخ كود القالب إلى
resources/views/components/ui/
resources/views/components/ui/blocks/gallery-16.blade.php
{{--
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...];
leave src empty to show a placeholder.
Split layout: heading and description on the start side, two square
slides per view on the end side running off the page edge (one on
mobile), the arrow pair and the dots below the slider.
<x-ui.blocks.gallery-16
heading="Our work"
description="A few recent projects."
:images="[
['src' => '/images/gallery/1.jpg', 'alt' => 'Photo 1'],
['src' => '/images/gallery/2.jpg', 'alt' => 'Photo 2'],
['src' => '/images/gallery/3.jpg', 'alt' => 'Photo 3'],
]"
previous-label="Previous image"
next-label="Next image"
/>
--}}
@props([
'heading' => 'Image Gallery',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'images' => [
['src' => null, 'alt' => 'Placeholder image 1'],
['src' => null, 'alt' => 'Placeholder image 2'],
['src' => null, 'alt' => 'Placeholder image 3'],
['src' => null, 'alt' => 'Placeholder image 4'],
['src' => null, 'alt' => 'Placeholder image 5'],
['src' => null, 'alt' => 'Placeholder image 6'],
['src' => null, 'alt' => 'Placeholder image 7'],
],
'previousLabel' => 'Previous slide',
'nextLabel' => 'Next slide',
'dotLabel' => 'Go to slide',
])
{{-- The slider column is a size container: slides are sized in cqw (its
width), while the carousel itself is pulled out to the page edge with a
negative end margin so the slides run off it. The controls row is held
back to the column width. --}}
<section {{ $attributes->merge(['class' => 'w-full overflow-hidden bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto grid max-w-7xl grid-cols-1 gap-12 md:grid-cols-2 md:gap-20">
<div class="flex flex-col justify-center gap-3 md:gap-4 md:pb-24">
<h2 class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
<p class="text-muted-foreground md:text-lg">{{ $description }}</p>
</div>
<div class="@container min-w-0">
<x-ui.carousel :arrows="false" track="gap-6 md:gap-8"
class="-me-[max(5vw,calc((100vw_-_80rem)/2))]">
@foreach ($images as $image)
<x-ui.carousel.item
class="relative aspect-square basis-[84cqw] overflow-hidden bg-muted md:basis-[calc(50cqw_-_1.25rem)]">
@if (!empty($image['src']))
<img src="{{ $image['src'] }}" alt="{{ $image['alt'] ?? '' }}"
loading="lazy" class="absolute inset-0 size-full object-cover">
@else
<div role="img" aria-label="{{ $image['alt'] ?? '' }}"
class="absolute inset-0 flex items-center justify-center text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round"
class="size-10 md:size-12" aria-hidden="true">
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
<circle cx="9" cy="9" r="2" />
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
</svg>
</div>
@endif
</x-ui.carousel.item>
@endforeach
<x-slot:controls>
<div class="mt-8 flex w-[100cqw] md:mt-12 items-center justify-between gap-4">
<div class="flex gap-4">
<x-ui.button variant="outline" size="icon" data-ui-carousel-prev
aria-label="{{ $previousLabel }}" class="size-12 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="size-6 rtl:rotate-180" aria-hidden="true">
<path d="m12 19-7-7 7-7" />
<path d="M19 12H5" />
</svg>
</x-ui.button>
<x-ui.button variant="outline" size="icon" data-ui-carousel-next
aria-label="{{ $nextLabel }}" class="size-12 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="size-6 rtl:rotate-180" aria-hidden="true">
<path d="M5 12h14" />
<path d="m12 5 7 7-7 7" />
</svg>
</x-ui.button>
</div>
<div data-ui-carousel-dots data-label="{{ $dotLabel }}"
class="flex flex-wrap justify-end gap-2"></div>
</div>
</x-slot:controls>
</x-ui.carousel>
</div>
</div>
</section>
الاستخدام
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...]; leave src empty to show a placeholder. Split layout: heading and description on the start side, two square slides per view on the end side running off the page edge (one on mobile), the arrow pair and the dots below the slider.
<x-ui.blocks.gallery-16
heading="Our work"
description="A few recent projects."
:images="[
['src' => '/images/gallery/1.jpg', 'alt' => 'Photo 1'],
['src' => '/images/gallery/2.jpg', 'alt' => 'Photo 2'],
['src' => '/images/gallery/3.jpg', 'alt' => 'Photo 3'],
]"
previous-label="Previous image"
next-label="Next image"
/>
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة PHP.
@props([
'heading' => 'Image Gallery',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'images' => [
['src' => null, 'alt' => 'Placeholder image 1'],
['src' => null, 'alt' => 'Placeholder image 2'],
['src' => null, 'alt' => 'Placeholder image 3'],
['src' => null, 'alt' => 'Placeholder image 4'],
['src' => null, 'alt' => 'Placeholder image 5'],
['src' => null, 'alt' => 'Placeholder image 6'],
['src' => null, 'alt' => 'Placeholder image 7'],
],
'previousLabel' => 'Previous slide',
'nextLabel' => 'Next slide',
'dotLabel' => 'Go to slide',
])