-
Heading 1
-
Heading 2
-
Heading 3
-
Heading 4
-
Body paragraph text.
-
Body strong paragraph text.
-
Small supporting text.
-
Caption text.
-
const scale = "type";
+
+
+ Heading 0
+ Heading 1
+ Heading 2
+ Heading 3
+ Heading 4
+
+
+ {#each paragraphSizes as size (size)}
+ {#each weights as weight (weight)}
+
+ Paragraph {size} / {weight}
+
+ {/each}
+ {/each}
+
+
+ Monospace Large
+ Monospace Regular
+ Monospace Small
+
diff --git a/web/src/lib/components/ui/Typography.svelte b/web/src/lib/components/ui/Typography.svelte
index 1c3ae50d..0e106a68 100644
--- a/web/src/lib/components/ui/Typography.svelte
+++ b/web/src/lib/components/ui/Typography.svelte
@@ -2,42 +2,55 @@
import { tv, type VariantProps } from "tailwind-variants";
import type { SvelteHTMLElements } from "svelte/elements";
- // Scale sourced from Figma "Font Styles" (node 1:134): Heading 1-4 map to
- // h1-h4, the "Paragraph Regular" size maps to body/body-strong (weight
- // axis only), "Paragraph Small"/"Paragraph Mini" map to small/caption, and
- // the monospace specimen maps to mono.
export const typography = tv({
base: "font-sans text-foreground-default",
variants: {
variant: {
- h1: "text-2xl font-bold leading-tight",
- h2: "text-xl font-bold leading-tight",
- h3: "text-lg font-semibold leading-snug",
- h4: "text-base font-semibold leading-snug",
- body: "text-base font-normal leading-normal",
- "body-strong": "text-base font-semibold leading-normal",
- small: "text-sm font-normal leading-normal text-foreground-muted",
- caption: "text-xs font-normal leading-normal text-foreground-subtle",
- mono: "font-mono text-sm font-normal leading-normal"
+ h0: "text-heading-0",
+ h1: "text-heading-1",
+ h2: "text-heading-2",
+ h3: "text-heading-3",
+ h4: "text-heading-4",
+ large: "text-paragraph-large",
+ regular: "text-paragraph-regular",
+ small: "text-paragraph-small",
+ mini: "text-paragraph-mini",
+ "mono-large": "font-mono text-monospace-large font-normal",
+ mono: "font-mono text-monospace-regular font-normal",
+ "mono-small": "font-mono text-monospace-small font-normal"
+ },
+ weight: {
+ regular: "",
+ semibold: "",
+ bold: ""
}
},
+ compoundVariants: (["large", "regular", "small", "mini"] as const).flatMap((variant) => [
+ { variant, weight: "regular" as const, class: "font-normal" },
+ { variant, weight: "semibold" as const, class: "font-medium" },
+ { variant, weight: "bold" as const, class: "font-semibold" }
+ ]),
defaultVariants: {
- variant: "body"
+ variant: "regular",
+ weight: "regular"
}
});
export type TypographyVariants = VariantProps
;
const defaultTag = {
+ h0: "h1",
h1: "h1",
h2: "h2",
h3: "h3",
h4: "h4",
- body: "p",
- "body-strong": "p",
+ large: "p",
+ regular: "p",
small: "span",
- caption: "span",
- mono: "code"
+ mini: "span",
+ "mono-large": "code",
+ mono: "code",
+ "mono-small": "code"
} as const satisfies Record, keyof SvelteHTMLElements>;
@@ -46,15 +59,16 @@
interface Props {
variant?: TypographyVariants["variant"];
+ weight?: TypographyVariants["weight"];
as?: keyof SvelteHTMLElements;
class?: string;
children: Snippet;
}
- let { variant = "body", as, class: className, children }: Props = $props();
+ let { variant = "regular", weight = "regular", as, class: className, children }: Props = $props();
- const tag = $derived(as ?? defaultTag[variant ?? "body"]);
- const classes = $derived(typography({ variant, class: className }));
+ const tag = $derived(as ?? defaultTag[variant ?? "regular"]);
+ const classes = $derived(typography({ variant, weight, class: className }));