// CodeCompare — side-by-side "before / after" code panels. Common // landing-page pattern for dev tooling: left = the messy world, // right = your product's clean replacement. The dividing label sits // in the centre on desktop, between the two panels on mobile. // // The two corner tags are `eyebrow`, and they are a PROP with an English // default rather than a hardcoded string: this kit renders a bilingual site, and // a component that prints "Before" over German copy is the same defect as a // hardcoded label anywhere else. The default keeps every existing call working. import type { ReactNode } from 'react' import { cn } from '../cn' import { HighlightedCode, type ShikiLang } from '../primitives/highlightedCode' interface CodeComparePanelProps { readonly label: ReactNode /** Pre-highlighted HTML (Shiki) — skips internal highlighting. */ readonly html?: string /** Plain code text. When `lang` is also provided, the panel * runs Shiki syntax highlighting automatically. */ readonly code?: string /** Shiki language. Triggers syntax highlighting on `code`. */ readonly lang?: ShikiLang /** Visual treatment — `'muted'` is dimmed (the "before"), * `'highlight'` keeps the full styling + adds a primary border. */ readonly tone?: 'muted' | 'highlight' /** The corner tag. Pass a translated string on a localised page. */ readonly eyebrow?: string } interface CodeCompareProps { readonly before: CodeComparePanelProps readonly after: CodeComparePanelProps readonly className?: string } const Panel = ({ label, html, code, lang, tone = 'muted', eyebrow }: CodeComparePanelProps): ReactNode => (
{label}
{eyebrow ?? (tone === 'highlight' ? 'With Voltro' : 'Before')}
{html ? (
) : code && lang ? ( ) : (
{code}
)}
) export const CodeCompare = ({ before, after, className, }: CodeCompareProps): ReactNode => (
{/* Arrow / divider — sits between the two panels */}