Skip to content

Commit ab50d90

Browse files
OneHunnidclaude
andcommitted
feat(tokens): load Sora in Storybook + fix editorial heading tags
Storybook now demonstrates the actual Sora editorial type instead of silently falling back to Inter: the Editorial specimens render with font-family var(--lp-font-family-sora) ("Sora, Inter, ..."), but no Sora webfont was loaded in the preview, so they rendered in Inter. - preview-head.html: load Sora from Google Fonts (OFL) for Storybook specimens only. The in-product @font-face/preload ships in Phase 2 (gonfalon), so this stays scoped to the docs surface. - typography.stories.tsx: map editorial-h1/h2/h3 to real h1/h2/h3 tags in getSemanticElement (previously fell through to a generic div); drop a stray per-token console.log. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1316c55 commit ab50d90

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

.storybook/preview-head.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
<link rel="preconnect" href="https://fonts.googleapis.com" />
12
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
23
<link rel="preload" href="./static/assets/Audimat3000-Regulier.var-subset.woff2" as="font" crossorigin />
34
<link rel="preload" href="./static/assets/Inter.var-subset.woff2" as="font" crossorigin />
45

6+
<!-- Sora (editorial type family) loaded from Google Fonts for Storybook specimens only.
7+
The in-product @font-face/preload ships separately in Phase 2 (gonfalon). -->
8+
<link
9+
href="https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&display=swap"
10+
rel="stylesheet"
11+
/>
12+
513
<link href="./styles.css" rel="stylesheet" />
614
<link href="./static/fonts.css" rel="stylesheet" />

packages/tokens/stories/typography.stories.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,24 @@ const getSemanticElement = (token: string, font: string) => {
8181
const category = parts[0]; // heading, body, etc.
8282
const size = parts[1]; // 1, 2, etc.
8383

84-
console.log({ category, token });
84+
// Editorial tokens are keyed as editorial-<variant>[-modifier] (e.g. editorial-h1-alt),
85+
// so the heading level lives in parts[1]. Map it to the matching tag instead of falling
86+
// through to the generic div below.
87+
if (category === 'editorial') {
88+
const variant = parts[1]; // display, h1, h2, h3
89+
const match = /^h(\d+)$/.exec(variant);
90+
if (match) {
91+
const Tag = `h${match[1]}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
92+
return {
93+
element: Tag,
94+
render: (text: string) => <Tag style={{ font }}>{text}</Tag>,
95+
};
96+
}
97+
return {
98+
element: 'div',
99+
render: (text: string) => <div style={{ font }}>{text}</div>,
100+
};
101+
}
85102

86103
switch (category) {
87104
case 'display':

0 commit comments

Comments
 (0)