import { router } from '@inertiajs/react'; import { LayoutTemplate } from 'lucide-react'; import { useState } from 'react'; import SectionLayoutController from '@/actions/App/Http/Controllers/SectionLayoutController'; import type { LayoutSection, Store } from '@/types'; const fieldClass = 'h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 md:text-sm'; /** Section types and layouts in plain words. Unknown ones fall back to their code name. */ const typeNames: Record = { header: 'Header', trust_bar: 'Trust row', product_grid: 'Products', featured_product: 'Featured product', about: 'About', testimonials: 'Reviews', faq: 'FAQ', newsletter: 'Newsletter', contact: 'Contact', footer: 'Footer', }; const layoutNames: Record> = { header: { simple: 'Logo on the left', centered: 'Logo in the middle' }, trust_bar: { row: 'Icon row', boxed: 'Small cards' }, product_grid: { grid: 'Grid', minimal: 'Centred grid', carousel: 'Sliding row', large: 'Large cards', }, featured_product: { 'image-left': 'Photo on the left', 'image-right': 'Photo on the right', stacked: 'Wide photo on top', }, about: { simple: 'Centred text', 'with-stats': 'Text with numbers', statement: 'One big statement', }, testimonials: { cards: 'Cards', single: 'One big quote', wall: 'Wall of quotes', }, faq: { list: 'Fold-open list', 'two-column': 'Two columns', cards: 'All answers in cards', }, newsletter: { banner: 'Colour banner', card: 'Colour card', split: 'Heading beside the form', }, contact: { simple: 'Simple', card: 'Card' }, footer: { simple: 'One line', centered: 'Centred', columns: 'Columns' }, }; /** * The Design tab's Layouts box: the layout of every section, header and footer included. * Heroes have their own box. */ export default function LayoutPicker({ store, sections, options, busy, }: { store: Store; sections: LayoutSection[]; options: Record; busy: boolean; }) { const [saving, setSaving] = useState(null); if (sections.length === 0) { return null; } function choose(section: LayoutSection, variant: string) { router.put( SectionLayoutController.update.url({ slug: store.slug, sectionId: section.section_id, }), { variant }, { preserveScroll: true, onStart: () => setSaving(section.section_id), onFinish: () => setSaving(null), }, ); } return (

Layouts

How each part of your store is arranged. Open to change one.

    {sections.map((section) => { const id = `layout-${section.section_id}`; const names = layoutNames[section.type] ?? {}; return (
  • ); })}
); }