المعرض
gallery-02
معرض صور بعنوان ووصف في المنتصف فوق صورتين مربعتين متجاورتين، وتتراصّان عموديًا على الجوال.
{{--
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...];
leave src empty to show a placeholder.
Square images in two columns, one column on mobile.
<x-ui.blocks.gallery-02
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'],
]"
/>
--}}
@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'],
],
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="mx-auto mb-12 flex max-w-3xl flex-col gap-5 text-center md:mb-20 md:gap-6">
<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="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8">
@foreach ($images as $image)
<x-ui.aspect-ratio ratio="1/1" class="overflow-hidden bg-muted">
@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.aspect-ratio>
@endforeach
</div>
</div>
</section>
التثبيت
php artisan ui:add-block gallery-02
أمر واحد يثبّت ملف Blade الخاص بالقالب وكل مكوّن يعتمد عليه. اعرضه في تخطيطك كالتالي
<x-ui.blocks.gallery-02
/>.
المكونات المضمّنة
1. ثبّت المكونات المطلوبة
php artisan ui:add aspect-ratio
2. حزم خارجية
- composer:
gehrisandro/tailwind-merge-laravel
3.
انسخ كود القالب إلى
resources/views/components/ui/
resources/views/components/ui/blocks/gallery-02.blade.php
{{--
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...];
leave src empty to show a placeholder.
Square images in two columns, one column on mobile.
<x-ui.blocks.gallery-02
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'],
]"
/>
--}}
@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'],
],
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="mx-auto mb-12 flex max-w-3xl flex-col gap-5 text-center md:mb-20 md:gap-6">
<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="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8">
@foreach ($images as $image)
<x-ui.aspect-ratio ratio="1/1" class="overflow-hidden bg-muted">
@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.aspect-ratio>
@endforeach
</div>
</div>
</section>
الاستخدام
Every piece of content is a prop. An image is ['src' => ..., 'alt' => ...]; leave src empty to show a placeholder. Square images in two columns, one column on mobile.
<x-ui.blocks.gallery-02
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'],
]"
/>
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة 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'],
],
])