*/ public const array COLORS = [ 'background', 'surface', 'foreground', 'muted', 'primary', 'primaryForeground', 'accent', 'border', ]; /** * Fonts the storefront can load. Key is what the plan stores, value is the font family name. * * @var array */ public const array FONTS = [ 'inter' => 'Inter', 'dm-sans' => 'DM Sans', 'poppins' => 'Poppins', 'manrope' => 'Manrope', 'space-grotesk' => 'Space Grotesk', 'playfair-display' => 'Playfair Display', 'lora' => 'Lora', 'fraunces' => 'Fraunces', ]; /** * How rounded corners are. * * @var list */ public const array RADII = ['none', 'small', 'medium', 'large', 'full']; /** * Section types and the layout variants each one supports. * * @var array> */ public const array SECTIONS = [ 'header' => ['simple', 'centered'], 'hero' => ['centered', 'split'], 'product_grid' => ['grid', 'minimal'], 'featured_product' => ['image-left', 'image-right'], 'about' => ['simple', 'with-stats'], 'testimonials' => ['cards', 'single'], 'faq' => ['list', 'two-column'], 'newsletter' => ['banner', 'card'], 'contact' => ['simple', 'card'], 'footer' => ['simple', 'centered'], ]; public const int MAX_SECTIONS = 20; /** * Links may only point inside the page, inside the site, or to safe outside targets. * This blocks things like "javascript:" links. */ public const string LINK_PATTERN = '/^(#[A-Za-z0-9_-]*|\/(?!\/)[^\s]*|https:\/\/[^\s]+|mailto:[^\s]+|tel:[0-9+\-\s]+)$/'; public const string COLOR_PATTERN = '/^#[0-9A-Fa-f]{6}$/'; public const string SECTION_ID_PATTERN = '/^[a-z][a-z0-9-]{0,39}$/'; /** * Validation rules for the content of one section type. * Keys are relative to the section's "content" object. * * @return array> */ public static function contentRules(string $type): array { $text = fn (int $max) => ['required', 'string', 'max:'.$max]; $optionalText = fn (int $max) => ['nullable', 'string', 'max:'.$max]; $link = ['required', 'string', 'max:300', 'regex:'.self::LINK_PATTERN]; $price = ['required', 'numeric', 'min:0', 'max:999999']; return match ($type) { 'header' => [ 'logoText' => $text(40), 'links' => ['present', 'array', 'max:6'], 'links.*.label' => $text(30), 'links.*.href' => $link, 'cta' => ['nullable', 'array'], 'cta.label' => ['required_with:cta', 'string', 'max:30'], 'cta.href' => ['required_with:cta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN], ], 'hero' => [ 'eyebrow' => $optionalText(60), 'headline' => $text(120), 'subheadline' => $text(300), 'primaryCta' => ['required', 'array'], 'primaryCta.label' => $text(30), 'primaryCta.href' => $link, 'secondaryCta' => ['nullable', 'array'], 'secondaryCta.label' => ['required_with:secondaryCta', 'string', 'max:30'], 'secondaryCta.href' => ['required_with:secondaryCta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN], ], 'product_grid' => [ 'heading' => $text(80), 'subheading' => $optionalText(200), 'items' => ['required', 'array', 'min:2', 'max:8'], 'items.*.name' => $text(80), 'items.*.price' => $price, 'items.*.badge' => $optionalText(20), ], 'featured_product' => [ 'eyebrow' => $optionalText(60), 'name' => $text(80), 'description' => $text(500), 'price' => $price, 'bullets' => ['present', 'array', 'max:5'], 'bullets.*' => $text(100), 'cta' => ['required', 'array'], 'cta.label' => $text(30), 'cta.href' => $link, ], 'about' => [ 'heading' => $text(80), 'body' => $text(1200), 'stats' => ['present', 'array', 'max:4'], 'stats.*.value' => $text(12), 'stats.*.label' => $text(40), ], 'testimonials' => [ 'heading' => $text(80), 'items' => ['required', 'array', 'min:1', 'max:6'], 'items.*.quote' => $text(400), 'items.*.name' => $text(60), 'items.*.role' => $optionalText(60), ], 'faq' => [ 'heading' => $text(80), 'items' => ['required', 'array', 'min:1', 'max:10'], 'items.*.question' => $text(160), 'items.*.answer' => $text(600), ], 'newsletter' => [ 'heading' => $text(80), 'body' => $optionalText(240), 'placeholder' => $text(40), 'buttonLabel' => $text(30), ], 'contact' => [ 'heading' => $text(80), 'body' => $optionalText(300), 'email' => ['nullable', 'email', 'max:120'], 'phone' => $optionalText(30), 'whatsapp' => ['nullable', 'string', 'regex:/^[0-9]{8,15}$/'], 'address' => $optionalText(200), ], 'footer' => [ 'text' => $text(160), 'links' => ['present', 'array', 'max:8'], 'links.*.label' => $text(30), 'links.*.href' => $link, ], default => [], }; } }