import { router } from '@inertiajs/react'; import { ChevronDown, LayoutTemplate } from 'lucide-react'; import { useState } from 'react'; import SectionLayoutController from '@/actions/App/Http/Controllers/SectionLayoutController'; import { SectionName } from '@/components/stores/preview-highlight'; import { typeNames } from '@/components/stores/section-names'; 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'; const layoutNames: Record> = { header: { simple: 'Logo on the left', centered: 'Logo in the middle' }, trust_bar: { row: 'Icon row', boxed: 'Small cards' }, shop_by: { circles: 'Round photos', tiles: 'Photo tiles' }, bento: { mosaic: 'One big tile and smaller ones', even: 'Equal tiles' }, video: { wide: 'Wide video', split: 'Words beside the video' }, 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 (
  • {typeNames[section.type] ?? section.type} {section.label && !['header', 'footer'].includes( section.type, ) && ( {' '} · “{section.label}” )} {section.page_id && section.page_id !== 'home' && ( {' '} on {section.page_title} )}
  • ); })}
); }