*/ 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'], // centered: text only. split: text beside a photo. image-full: a full-width photo with the text on it. 'hero' => ['centered', 'split', 'image-full'], // A row of short reassurances, such as free shipping and secure payment. row: a band. boxed: small cards. 'trust_bar' => ['row', 'boxed'], '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'], ]; /** * Section types a page may contain. The header and footer are not here: * they live once at the top of the plan and appear on every page. * * @return array> */ public static function pageSections(): array { return array_diff_key(self::SECTIONS, ['header' => true, 'footer' => true]); } /** What a trust row item can be. */ public const array TRUST_KINDS = ['shipping', 'payment', 'whatsapp', 'custom']; /** Icons a trust row item may use. */ public const array TRUST_ICONS = ['truck', 'shield', 'chat', 'refresh', 'leaf', 'star', 'gift', 'clock', 'heart', 'award', 'map-pin', 'package']; /** Sections per page. */ public const int MAX_SECTIONS = 20; public const int MAX_PAGES = 10; /** * Addresses inside a store that are not pages of the plan but still exist, so links to them are fine. * * @var list */ public const array BUILT_IN_PATHS = ['shop', 'products', 'cart']; /** The first page of every plan. */ public const string HOME_PAGE = 'home'; /** * Page ids the AI and merchants may not use, because the app has its own pages at these addresses. * * @var list */ public const array RESERVED_PAGE_IDS = ['shop', 'products', 'cart', 'checkout', 'orders', 'account', 'search']; /** * 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 PRODUCT_SLUG_PATTERN = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/'; /** Used for both section ids and page ids. */ 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], // "upload:12" (a photo uploaded in the Design tab) or "product:web-address-name" (a product's main photo). // Null means automatic: the store's own product photos are used. 'image' => ['nullable', 'string', 'max:140', 'regex:'.HeroImages::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, // The web-address name of one of the store's real products. When set, the store shows that // product's real name, price and photo instead of "name" and "price" above. 'productSlug' => ['nullable', 'string', 'max:120', 'regex:'.self::PRODUCT_SLUG_PATTERN], ], 'about' => [ 'heading' => $text(80), 'body' => $text(1200), 'stats' => ['present', 'array', 'max:4'], 'stats.*.value' => $text(12), 'stats.*.label' => $text(40), ], 'trust_bar' => [ 'items' => ['required', 'array', 'min:2', 'max:4'], // shipping, payment and whatsapp are written by the store itself from its real settings, so they // stay true when the merchant changes them. custom uses the title and text below. 'items.*.kind' => ['required', 'string', 'in:'.implode(',', self::TRUST_KINDS)], 'items.*.icon' => ['nullable', 'string', 'in:'.implode(',', self::TRUST_ICONS)], 'items.*.title' => ['required_if:items.*.kind,custom', 'nullable', 'string', 'max:40'], 'items.*.text' => ['nullable', 'string', 'max:80'], ], '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 => [], }; } }