الأسئلة الشائعة
faq-02
أسئلة شائعة بمحاذاة البداية: عنوان، وأكورديون أسئلة بعرض كامل، ودعوة للتواصل أسفله.
{{--
Left-aligned FAQ: title block, a full-width accordion of questions and a
"Still have questions?" contact prompt. Every piece of content is a prop.
Each item is ['question' => ..., 'answer' => ...]. Set :schema="true" to
print FAQPage JSON-LD for search engines.
<x-ui.blocks.faq-02
heading="Frequently asked questions"
description="Everything you need to know about billing and accounts."
:items="[
['question' => 'Can I cancel at any time?', 'answer' => 'Yes. Cancel from your billing page and you keep access until the period ends.'],
['question' => 'Do you offer refunds?', 'answer' => 'We refund any payment made in the last 14 days.'],
]"
cta-heading="Still have questions?"
cta-text="Our team answers within one working day."
cta-label="Contact us"
cta-href="/contact"
:schema="true"
/>
--}}
@props([
'heading' => 'FAQs',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.',
'items' => array_fill(0, 5, [
'question' => 'Question text goes here',
'answer' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.',
]),
'ctaHeading' => 'Still have questions?',
'ctaText' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'ctaLabel' => 'Contact',
'ctaHref' => '#',
'schema' => false,
])
<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="mb-12 flex max-w-3xl flex-col gap-5 md:mb-18 md:gap-6 lg:mb-20">
<h2 class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
<p class="md:text-lg">{{ $description }}</p>
</div>
<x-ui.accordion :items="array_column($items, 'question')"
class="w-full border-y border-border [&_[data-ui-accordion-trigger]]:py-4 [&_[data-ui-accordion-trigger]]:text-base [&_[data-ui-accordion-trigger]]:font-bold md:[&_[data-ui-accordion-trigger]]:py-5 md:[&_[data-ui-accordion-trigger]]:text-lg [&_[data-ui-accordion-content]]:pb-5 [&_[data-ui-accordion-content]]:text-base md:[&_[data-ui-accordion-content]]:pb-6">
@foreach ($items as $i => $item)
<x-slot :name="'item_' . $i">{{ $item['answer'] ?? '' }}</x-slot>
@endforeach
</x-ui.accordion>
<div class="mt-12 flex max-w-xl flex-col items-start gap-6 md:mt-18 lg:mt-20">
<div class="flex flex-col gap-3 md:gap-4">
<h3 class="text-2xl font-bold leading-[1.3] md:text-[2rem]">{{ $ctaHeading }}</h3>
<p class="md:text-lg">{{ $ctaText }}</p>
</div>
<x-ui.button variant="outline" :href="$ctaHref">{{ $ctaLabel }}</x-ui.button>
</div>
</div>
@if ($schema)
@php
// Built in a php block: Blade would read the '@context' key below as a directive anywhere else.
$faqSchema = [
'@context' => 'https://schema.org',
'@type' => 'FAQPage',
'mainEntity' => array_map(fn ($item) => [
'@type' => 'Question',
'name' => $item['question'] ?? '',
'acceptedAnswer' => ['@type' => 'Answer', 'text' => $item['answer'] ?? ''],
], array_values($items)),
];
@endphp
<script type="application/ld+json">{!! json_encode($faqSchema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}</script>
@endif
</section>
التثبيت
php artisan ui:add-block faq-02
أمر واحد يثبّت ملف Blade الخاص بالقالب وكل مكوّن يعتمد عليه. اعرضه في تخطيطك كالتالي
<x-ui.blocks.faq-02
/>.
1. ثبّت المكونات المطلوبة
php artisan ui:add accordion button
2. حزم خارجية
- composer:
gehrisandro/tailwind-merge-laravel
3.
انسخ كود القالب إلى
resources/views/components/ui/
resources/views/components/ui/blocks/faq-02.blade.php
{{--
Left-aligned FAQ: title block, a full-width accordion of questions and a
"Still have questions?" contact prompt. Every piece of content is a prop.
Each item is ['question' => ..., 'answer' => ...]. Set :schema="true" to
print FAQPage JSON-LD for search engines.
<x-ui.blocks.faq-02
heading="Frequently asked questions"
description="Everything you need to know about billing and accounts."
:items="[
['question' => 'Can I cancel at any time?', 'answer' => 'Yes. Cancel from your billing page and you keep access until the period ends.'],
['question' => 'Do you offer refunds?', 'answer' => 'We refund any payment made in the last 14 days.'],
]"
cta-heading="Still have questions?"
cta-text="Our team answers within one working day."
cta-label="Contact us"
cta-href="/contact"
:schema="true"
/>
--}}
@props([
'heading' => 'FAQs',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.',
'items' => array_fill(0, 5, [
'question' => 'Question text goes here',
'answer' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.',
]),
'ctaHeading' => 'Still have questions?',
'ctaText' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'ctaLabel' => 'Contact',
'ctaHref' => '#',
'schema' => false,
])
<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="mb-12 flex max-w-3xl flex-col gap-5 md:mb-18 md:gap-6 lg:mb-20">
<h2 class="text-4xl font-bold leading-[1.2] md:text-5xl">{{ $heading }}</h2>
<p class="md:text-lg">{{ $description }}</p>
</div>
<x-ui.accordion :items="array_column($items, 'question')"
class="w-full border-y border-border [&_[data-ui-accordion-trigger]]:py-4 [&_[data-ui-accordion-trigger]]:text-base [&_[data-ui-accordion-trigger]]:font-bold md:[&_[data-ui-accordion-trigger]]:py-5 md:[&_[data-ui-accordion-trigger]]:text-lg [&_[data-ui-accordion-content]]:pb-5 [&_[data-ui-accordion-content]]:text-base md:[&_[data-ui-accordion-content]]:pb-6">
@foreach ($items as $i => $item)
<x-slot :name="'item_' . $i">{{ $item['answer'] ?? '' }}</x-slot>
@endforeach
</x-ui.accordion>
<div class="mt-12 flex max-w-xl flex-col items-start gap-6 md:mt-18 lg:mt-20">
<div class="flex flex-col gap-3 md:gap-4">
<h3 class="text-2xl font-bold leading-[1.3] md:text-[2rem]">{{ $ctaHeading }}</h3>
<p class="md:text-lg">{{ $ctaText }}</p>
</div>
<x-ui.button variant="outline" :href="$ctaHref">{{ $ctaLabel }}</x-ui.button>
</div>
</div>
@if ($schema)
@php
// Built in a php block: Blade would read the '@context' key below as a directive anywhere else.
$faqSchema = [
'@context' => 'https://schema.org',
'@type' => 'FAQPage',
'mainEntity' => array_map(fn ($item) => [
'@type' => 'Question',
'name' => $item['question'] ?? '',
'acceptedAnswer' => ['@type' => 'Answer', 'text' => $item['answer'] ?? ''],
], array_values($items)),
];
@endphp
<script type="application/ld+json">{!! json_encode($faqSchema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}</script>
@endif
</section>
الاستخدام
Left-aligned FAQ: title block, a full-width accordion of questions and a "Still have questions?" contact prompt. Every piece of content is a prop. Each item is ['question' => ..., 'answer' => ...]. Set :schema="true" to print FAQPage JSON-LD for search engines.
<x-ui.blocks.faq-02
heading="Frequently asked questions"
description="Everything you need to know about billing and accounts."
:items="[
['question' => 'Can I cancel at any time?', 'answer' => 'Yes. Cancel from your billing page and you keep access until the period ends.'],
['question' => 'Do you offer refunds?', 'answer' => 'We refund any payment made in the last 14 days.'],
]"
cta-heading="Still have questions?"
cta-text="Our team answers within one working day."
cta-label="Contact us"
cta-href="/contact"
:schema="true"
/>
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة PHP.
@props([
'heading' => 'FAQs',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.',
'items' => array_fill(0, 5, [
'question' => 'Question text goes here',
'answer' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.',
]),
'ctaHeading' => 'Still have questions?',
'ctaText' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'ctaLabel' => 'Contact',
'ctaHref' => '#',
'schema' => false,
])