mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem The design system repeats inline-code styles and does not document the new shared defaults. ## Solution Import the shared styles from #51980 and document how sizing, colour, weight and wrapping work. Add examples of bare and linked code, tables, long values, Tailwind overrides and `data-code-style="plain"`. Remove repeated styles from existing examples. Highlighted code blocks keep an explicit `text-sm` size so removing inline-code classes does not enlarge them. ## Review instructions This PR changes the design-system app only. 1. Open the [Layout page](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/layout). Check the inline-code examples at narrow and desktop widths in both themes. 2. Check code in headings, long values, explicit size overrides and the plain display example. Code should use the default foreground colour and follow the surrounding weight unless a class overrides it. 3. Check the [chart palette example](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/charts). CSS variable names should remain `<code>` elements with their own display styles. | Before | After | | --- | --- | | <img width="1666" height="770" alt="CleanShot 2026-10-20 at 16 37 20@2x" src="https://github.com/user-attachments/assets/2ac87442-12a9-49ab-8e4f-f82436308567" /> | <img width="1680" height="782" alt="CleanShot 2026-10-20 at 16 36 12@2x" src="https://github.com/user-attachments/assets/b0074844-3431-4fb9-827b-c6fd0de889fe" /> | | _Layout ([live](https://supabase.com/design-system/docs/ui-patterns/layout))_ | _Layout ([preview](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/layout))_ | | <img width="1072" height="476" alt="CleanShot 2026-10-20 at 16 35 14@2x" src="https://github.com/user-attachments/assets/242bf850-58fa-4b29-a978-bd0e296c2e8b" /> | <img width="1072" height="484" alt="CleanShot 2026-10-20 at 16 34 47@2x" src="https://github.com/user-attachments/assets/962adef0-05b7-47ed-8fdc-5229a3a332e1" /> | | _Charts ([live](https://supabase.com/design-system/docs/ui-patterns/charts))_ | _Charts ([preview](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/charts)): no visual changes as `data-code-style="plain"` has been used_ |
141 lines
4.0 KiB
TypeScript
141 lines
4.0 KiB
TypeScript
import { ReactNode } from 'react'
|
|
|
|
const SLOTS = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
const STATUS = [
|
|
{ name: '--chart-status-success', muted: '--chart-status-success-muted', note: 'Healthy, ok' },
|
|
{
|
|
name: '--chart-status-warning',
|
|
muted: '--chart-status-warning-muted',
|
|
note: 'Threshold breach',
|
|
},
|
|
{
|
|
name: '--chart-status-destructive',
|
|
muted: '--chart-status-destructive-muted',
|
|
note: 'Error, failure',
|
|
},
|
|
]
|
|
|
|
const DEFAULTS = [
|
|
{ name: '--chart-in', note: 'Pinned: network in, disk read' },
|
|
{ name: '--chart-out', note: 'Pinned: network out, disk write' },
|
|
{ name: '--chart-reference', note: 'Reference lines, max values' },
|
|
{ name: '--chart-muted', note: 'Headroom, idle, unused capacity' },
|
|
]
|
|
|
|
function Swatch({ token, label }: { token: string; label: string }) {
|
|
return (
|
|
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
|
|
<div
|
|
className="border-default h-12 w-full rounded-md border"
|
|
style={{ background: `var(${token})` }}
|
|
/>
|
|
<span className="text-foreground-lighter text-xs">{label}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function TokenCard({
|
|
title,
|
|
token,
|
|
note,
|
|
children,
|
|
}: {
|
|
title: ReactNode
|
|
token: string
|
|
note?: string
|
|
children: ReactNode
|
|
}) {
|
|
return (
|
|
<div className="border-default bg-surface-100 flex flex-col gap-4 rounded-lg border p-4">
|
|
<div className="flex flex-col gap-1">
|
|
<div className="text-foreground text-sm">{title}</div>
|
|
<code
|
|
data-code-style="plain"
|
|
className="text-foreground-lighter break-all font-mono text-xs"
|
|
>
|
|
{token}
|
|
</code>
|
|
</div>
|
|
<div className="flex gap-3">{children}</div>
|
|
{note && <p className="text-foreground-lighter text-xs">{note}</p>}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function Section({
|
|
title,
|
|
description,
|
|
children,
|
|
className,
|
|
}: {
|
|
title: string
|
|
description: string
|
|
children: ReactNode
|
|
className: string
|
|
}) {
|
|
return (
|
|
<section className="flex flex-col gap-4">
|
|
<div className="flex flex-col gap-1">
|
|
<h3 className="text-foreground text-sm">{title}</h3>
|
|
<p className="text-foreground-lighter max-w-prose text-xs">{description}</p>
|
|
</div>
|
|
<div className={className}>{children}</div>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export default function ChartPalette() {
|
|
return (
|
|
<div className="flex w-full flex-col gap-10 p-6">
|
|
<Section
|
|
title="Categorical slots"
|
|
description="Assigned in fixed order, never cycled. A ninth series folds into “Other”."
|
|
className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"
|
|
>
|
|
{SLOTS.map((n) => (
|
|
<TokenCard key={n} title={`Slot ${n}`} token={`--chart-${n}`}>
|
|
<Swatch token={`--chart-${n}`} label="Stroke" />
|
|
<Swatch token={`--chart-${n}-fill`} label="Fill" />
|
|
</TokenCard>
|
|
))}
|
|
</Section>
|
|
|
|
<Section
|
|
title="Status"
|
|
description="Reserved meaning. These point at the same tokens the rest of the UI uses and always ship with an icon or label, so state is never carried by color alone. Never assign one to a series."
|
|
className="grid grid-cols-1 gap-4 sm:grid-cols-3"
|
|
>
|
|
{STATUS.map((d) => (
|
|
<TokenCard
|
|
key={d.name}
|
|
title={d.name.replace('--chart-status-', '')}
|
|
token={d.name}
|
|
note={d.note}
|
|
>
|
|
<Swatch token={d.name} label="Base" />
|
|
<Swatch token={d.muted} label="Muted" />
|
|
</TokenCard>
|
|
))}
|
|
</Section>
|
|
|
|
<Section
|
|
title="Pinned pairs and rendering defaults"
|
|
description="Chart authors do not pick these. Reference lines and headroom are applied by the chart."
|
|
className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"
|
|
>
|
|
{DEFAULTS.map((d) => (
|
|
<TokenCard
|
|
key={d.name}
|
|
title={d.name.replace('--chart-', '')}
|
|
token={d.name}
|
|
note={d.note}
|
|
>
|
|
<Swatch token={d.name} label="Color" />
|
|
</TokenCard>
|
|
))}
|
|
</Section>
|
|
</div>
|
|
)
|
|
}
|