/** * Globals Preview — live preview panel showing all tokens in context * * Renders sample UI elements (buttons, headings, body text, cards, badges) * styled with the current global tokens so the user can see changes in real-time. */ import { Card, CardContent } from '@/components/ui/card' import { GlobalStyles, GlobalColor, GlobalTypography } from '../config' import { getAllGoogleFontsPreviewUrls } from '@/lib/google-fonts' interface GlobalsPreviewProps { settings: GlobalStyles } export function GlobalsPreview({ settings }: GlobalsPreviewProps) { const { colors, typography } = settings const getColor = (id: string) => colors.find((c: GlobalColor) => c.id === id)?.value ?? '#888' const getTypo = (id: string) => typography.find((t: GlobalTypography) => t.id === id) const headingTypo = getTypo('headings') const bodyTypo = getTypo('body') const headingStyle: React.CSSProperties = { fontFamily: headingTypo?.fontFamily || 'inherit', fontWeight: Number(headingTypo?.fontWeight || 600), fontSize: headingTypo?.fontSize ? `${headingTypo.fontSize}px` : undefined, lineHeight: headingTypo?.lineHeight || undefined, letterSpacing: headingTypo?.letterSpacing || undefined, textTransform: (headingTypo?.textTransform || 'none') as React.CSSProperties['textTransform'], color: getColor('text'), } const bodyStyle: React.CSSProperties = { fontFamily: bodyTypo?.fontFamily || 'inherit', fontWeight: Number(bodyTypo?.fontWeight || 400), fontSize: bodyTypo?.fontSize ? `${bodyTypo.fontSize}px` : '14px', lineHeight: bodyTypo?.lineHeight || '1.6', letterSpacing: bodyTypo?.letterSpacing || undefined, textTransform: (bodyTypo?.textTransform || 'none') as React.CSSProperties['textTransform'], color: getColor('text'), } return (
{/* Google Fonts */} {getAllGoogleFontsPreviewUrls().map((url, i) => ( ))} {/* ── Color Swatches ────────────────────────────────── */}

Color Palette

{colors.map((c: GlobalColor) => (
{c.name} {c.value}
))}
{/* ── Typography Preview ────────────────────────────── */}

Typography Preview

{/* Heading samples */}

Heading Level 1

Heading Level 2

Heading Level 3

{/* Body sample */}

This is how your body text will appear across all Swift Commerce features. The quick brown fox jumps over the lazy dog. Typography settings include font family, weight, size, line height, letter spacing, and text transform.

Secondary body text with reduced emphasis. Product descriptions, form labels, and notification messages will use this typography.

{/* ── UI Components Sample ──────────────────────────── */}

UI Components Preview

{/* Buttons */}
{/* Badges */}
In Stock Out of Stock Featured
{/* Sample card */}

Sample Product

Product description text

{/* ── Custom Typography Tokens ──────────────────────── */} {typography.filter((t: GlobalTypography) => !t.isDefault).length > 0 && (

Custom Typography

{typography .filter((t: GlobalTypography) => !t.isDefault) .map((t: GlobalTypography) => (

{t.name}

The quick brown fox jumps over the lazy dog.

))}
)}
) }