التواصل
contact-17
قائمة مواقع بجانب صورة: اختر مكتبًا من القائمة فتظهر صورته بجانبها. بلغة CSS فقط، دون أي سكربت.
{{--
Locations list beside a photo. Picking an office in the list shows its
photo next to it. It works with no script: each office is a visually
hidden radio, so the list is keyboard friendly (Tab in, arrow keys to
move) and the selected photo follows `:checked` in CSS. Every piece of
content is a prop. A location is ['name' => ..., 'address' => ...] plus
an optional 'image' => ['src' => ..., 'alt' => ...]; without a src the
panel shows a placeholder. Give each instance on a page its own `id`.
<x-ui.blocks.contact-17
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'image' => ['src' => '/img/sydney.jpg', 'alt' => 'Sydney studio']],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010', 'image' => ['src' => '/img/auckland.jpg', 'alt' => 'Auckland studio']],
]"
action-label="See the studio"
/>
--}}
@props([
'id' => 'contact-17',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Office',
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto flex max-w-7xl flex-col gap-12 md:gap-20">
<div class="flex w-full max-w-3xl flex-col gap-3 md:gap-4">
@if ($tagline)
<p class="font-semibold">{{ $tagline }}</p>
@endif
<div class="flex flex-col gap-5 md:gap-6">
<h2 id="{{ $id }}-heading" class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="md:text-lg">{{ $description }}</p>
@endif
</div>
</div>
{{-- The panels sit absolutely in the right column (below the list on
mobile), so each one can stay a sibling of its own radio. The
bottom padding reserves the 3:2 panel on mobile. --}}
<div class="relative pb-[calc(66.6667%+3rem)] md:min-h-[400px] md:pb-0">
<div role="radiogroup" aria-labelledby="{{ $id }}-heading"
class="flex flex-col gap-10 md:w-[calc(50%-2.5rem)] lg:w-[480px]">
@foreach ($locations as $i => $location)
@php($image = $location['image'] ?? [])
<div>
<x-ui.radio id="{{ $id }}-{{ $i }}" name="{{ $id }}" value="{{ $i }}"
:checked="$i === 0" class="peer sr-only" />
<label for="{{ $id }}-{{ $i }}"
class="flex cursor-pointer flex-col gap-5 border-s border-transparent ps-8 transition-colors peer-checked:border-foreground peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/50 md:gap-6">
<span class="flex flex-col gap-3 md:gap-4">
<span class="text-xl font-bold leading-[1.4] md:text-2xl">{{ $location['name'] ?? '' }}</span>
<span>{{ $location['address'] ?? '' }}</span>
</span>
@if ($actionLabel)
<span class="font-semibold">{{ $actionLabel }}</span>
@endif
</label>
<div
class="absolute inset-x-0 bottom-0 hidden aspect-[3/2] overflow-hidden bg-muted peer-checked:block md:top-0 md:start-[calc(50%+2.5rem)] md:aspect-auto lg:start-[560px]">
@if (!empty($image['src']))
<img src="{{ $image['src'] }}" alt="{{ $image['alt'] ?? '' }}" loading="lazy"
class="size-full object-cover">
@else
<div class="flex size-full 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="1.5" stroke-linecap="round"
stroke-linejoin="round" class="size-12 md:size-24" 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
</div>
</div>
@endforeach
</div>
</div>
</div>
</section>
التثبيت
php artisan ui:add-block contact-17
أمر واحد يثبّت ملف Blade الخاص بالقالب وكل مكوّن يعتمد عليه. اعرضه في تخطيطك كالتالي
<x-ui.blocks.contact-17
/>.
المكونات المضمّنة
1. ثبّت المكونات المطلوبة
php artisan ui:add radio
2. حزم خارجية
- composer:
gehrisandro/tailwind-merge-laravel
3.
انسخ كود القالب إلى
resources/views/components/ui/
resources/views/components/ui/blocks/contact-17.blade.php
{{--
Locations list beside a photo. Picking an office in the list shows its
photo next to it. It works with no script: each office is a visually
hidden radio, so the list is keyboard friendly (Tab in, arrow keys to
move) and the selected photo follows `:checked` in CSS. Every piece of
content is a prop. A location is ['name' => ..., 'address' => ...] plus
an optional 'image' => ['src' => ..., 'alt' => ...]; without a src the
panel shows a placeholder. Give each instance on a page its own `id`.
<x-ui.blocks.contact-17
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'image' => ['src' => '/img/sydney.jpg', 'alt' => 'Sydney studio']],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010', 'image' => ['src' => '/img/auckland.jpg', 'alt' => 'Auckland studio']],
]"
action-label="See the studio"
/>
--}}
@props([
'id' => 'contact-17',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Office',
])
<section {{ $attributes->merge(['class' => 'w-full bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto flex max-w-7xl flex-col gap-12 md:gap-20">
<div class="flex w-full max-w-3xl flex-col gap-3 md:gap-4">
@if ($tagline)
<p class="font-semibold">{{ $tagline }}</p>
@endif
<div class="flex flex-col gap-5 md:gap-6">
<h2 id="{{ $id }}-heading" class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
@if ($description)
<p class="md:text-lg">{{ $description }}</p>
@endif
</div>
</div>
{{-- The panels sit absolutely in the right column (below the list on
mobile), so each one can stay a sibling of its own radio. The
bottom padding reserves the 3:2 panel on mobile. --}}
<div class="relative pb-[calc(66.6667%+3rem)] md:min-h-[400px] md:pb-0">
<div role="radiogroup" aria-labelledby="{{ $id }}-heading"
class="flex flex-col gap-10 md:w-[calc(50%-2.5rem)] lg:w-[480px]">
@foreach ($locations as $i => $location)
@php($image = $location['image'] ?? [])
<div>
<x-ui.radio id="{{ $id }}-{{ $i }}" name="{{ $id }}" value="{{ $i }}"
:checked="$i === 0" class="peer sr-only" />
<label for="{{ $id }}-{{ $i }}"
class="flex cursor-pointer flex-col gap-5 border-s border-transparent ps-8 transition-colors peer-checked:border-foreground peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/50 md:gap-6">
<span class="flex flex-col gap-3 md:gap-4">
<span class="text-xl font-bold leading-[1.4] md:text-2xl">{{ $location['name'] ?? '' }}</span>
<span>{{ $location['address'] ?? '' }}</span>
</span>
@if ($actionLabel)
<span class="font-semibold">{{ $actionLabel }}</span>
@endif
</label>
<div
class="absolute inset-x-0 bottom-0 hidden aspect-[3/2] overflow-hidden bg-muted peer-checked:block md:top-0 md:start-[calc(50%+2.5rem)] md:aspect-auto lg:start-[560px]">
@if (!empty($image['src']))
<img src="{{ $image['src'] }}" alt="{{ $image['alt'] ?? '' }}" loading="lazy"
class="size-full object-cover">
@else
<div class="flex size-full 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="1.5" stroke-linecap="round"
stroke-linejoin="round" class="size-12 md:size-24" 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
</div>
</div>
@endforeach
</div>
</div>
</div>
</section>
الاستخدام
Locations list beside a photo. Picking an office in the list shows its photo next to it. It works with no script: each office is a visually hidden radio, so the list is keyboard friendly (Tab in, arrow keys to move) and the selected photo follows `:checked` in CSS. Every piece of content is a prop. A location is ['name' => ..., 'address' => ...] plus an optional 'image' => ['src' => ..., 'alt' => ...]; without a src the panel shows a placeholder. Give each instance on a page its own `id`.
<x-ui.blocks.contact-17
id="offices"
tagline="Offices"
heading="Where to find us"
description="Pick a studio to see it."
:locations="[
['name' => 'Sydney', 'address' => '1 Market St, Sydney NSW 2000', 'image' => ['src' => '/img/sydney.jpg', 'alt' => 'Sydney studio']],
['name' => 'Auckland', 'address' => '2 Queen St, Auckland 1010', 'image' => ['src' => '/img/auckland.jpg', 'alt' => 'Auckland studio']],
]"
action-label="See the studio"
/>
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة PHP.
@props([
'id' => 'contact-17',
'tagline' => 'Tagline',
'heading' => 'Locations',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'locations' => [
['name' => 'Sydney', 'address' => '123 Sample St, Sydney NSW 2000 AU'],
['name' => 'New York', 'address' => '123 Sample St, New York NY 10000 USA'],
['name' => 'London', 'address' => '123 Sample St, London W1C 1DE, United Kingdom'],
],
'actionLabel' => 'View Office',
])