@spunto/design-system 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spunto/design-system",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Spunto's shared design system — warm/flame tokens, color constants, and UI primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,6 +33,10 @@
33
33
  "types": "./src/colors.ts",
34
34
  "import": "./src/colors.ts"
35
35
  },
36
+ "./fonts": {
37
+ "types": "./src/components/fonts.tsx",
38
+ "import": "./src/components/fonts.tsx"
39
+ },
36
40
  "./styles.css": "./styles.css"
37
41
  },
38
42
  "files": [
@@ -0,0 +1,39 @@
1
+ // Font preloads for the design-system typefaces (Geist / Syne / JetBrains Mono).
2
+ //
3
+ // Renders the resource hints that let the browser fetch the fonts early instead
4
+ // of discovering them mid-render through the `@font-face` rules in `styles.css`.
5
+ // The preload URLs MUST match the `src` in those `@font-face` blocks exactly
6
+ // (same gstatic .woff2), otherwise the browser downloads each file twice.
7
+ //
8
+ // We only preload the *latin* subset of each family — the one every Spunto
9
+ // surface actually renders. The other subsets stay lazy (fetched on demand via
10
+ // `unicode-range`), so we don't waste bandwidth preloading Cyrillic/Greek/etc.
11
+ //
12
+ // Under Next 16 / React 19 these <link> elements are hoisted into <head>
13
+ // automatically, so `<FontPreloads/>` can live anywhere in the tree (e.g. the
14
+ // root layout body). In a plain React app, place it high in the tree.
15
+
16
+ // Latin-subset .woff2 for each family — identical to the latin `src` in styles.css.
17
+ const LATIN_WOFF2 = [
18
+ "https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwcGFU.woff2",
19
+ "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2",
20
+ "https://fonts.gstatic.com/s/syne/v24/8vIH7w4qzmVxm2BL9A.woff2",
21
+ ] as const
22
+
23
+ export function FontPreloads() {
24
+ return (
25
+ <>
26
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
27
+ {LATIN_WOFF2.map((href) => (
28
+ <link
29
+ key={href}
30
+ rel="preload"
31
+ as="font"
32
+ type="font/woff2"
33
+ href={href}
34
+ crossOrigin="anonymous"
35
+ />
36
+ ))}
37
+ </>
38
+ )
39
+ }
@@ -110,6 +110,18 @@ const Terminal = forwardRef<TerminalHandle, TerminalProps>(function Terminal(
110
110
  async function init() {
111
111
  const { Terminal: XTermCtor } = await import("@xterm/xterm")
112
112
  const { FitAddon } = await import("@xterm/addon-fit")
113
+ // xterm measures glyph/cell width once, at construction, using whatever
114
+ // font is *actually available* right then. The design system's styles.css
115
+ // declares JetBrains Mono via @font-face (and apps preload it), but a
116
+ // @font-face only downloads lazily on first use — so the terminal can
117
+ // still mount before the file has arrived, measure with a fallback font,
118
+ // then paint JetBrains Mono into cells sized for that fallback once it
119
+ // loads ("same font family, wrong spacing"). Awaiting the load closes
120
+ // that race regardless of how/whether the host app preloads.
121
+ await Promise.all([
122
+ document.fonts.load(`400 ${fontSize}px "JetBrains Mono"`),
123
+ document.fonts.load(`500 ${fontSize}px "JetBrains Mono"`),
124
+ ]).catch(() => {})
113
125
  if (disposed || !mountRef.current) return
114
126
 
115
127
  const term = new XTermCtor({
@@ -118,7 +130,7 @@ const Terminal = forwardRef<TerminalHandle, TerminalProps>(function Terminal(
118
130
  cursorStyle: "block",
119
131
  fontFamily: '"JetBrains Mono", "Fira Code", "Cascadia Code", monospace',
120
132
  fontSize,
121
- lineHeight: 1.4,
133
+ lineHeight: 1.2,
122
134
  scrollback,
123
135
  theme: terminalTheme,
124
136
  })
package/styles.css CHANGED
@@ -10,12 +10,151 @@
10
10
  * `@custom-variant dark` stays in the app (or add it there once).
11
11
  */
12
12
 
13
+ /* ─── Fonts — carried by the design system ──────────────────────────────────
14
+ *
15
+ * Canonical typography (single source of truth, decided 2026-07-23):
16
+ * text = Geist · display = Syne · mono = JetBrains Mono
17
+ *
18
+ * `src` points straight at the versioned .woff2 files on fonts.gstatic.com
19
+ * (absolute → identical everywhere, never hashed). URLs were harvested once from
20
+ * `fonts.googleapis.com/css2?family=…` with a modern User-Agent; we deliberately
21
+ * do NOT link the css2 stylesheet (render-blocking + UA-sniffed). Every subset
22
+ * gstatic serves is declared here — the browser only fetches the ones a page
23
+ * actually uses (via `unicode-range`). `<FontPreloads/>` (`@spunto/design-system/fonts`)
24
+ * preloads the latin subset of each family with matching URLs. `font-display: swap`.
25
+ *
26
+ * Follow-up cards: self-host on design.spunto.net (RGPD), anti-CLS fallback
27
+ * metrics (size-adjust / ascent-override via Fontaine). */
28
+
29
+ /* Geist — variable weight (text). */
30
+ @font-face {
31
+ font-family: "Geist";
32
+ font-style: normal;
33
+ font-weight: 100 900;
34
+ font-display: swap;
35
+ src: url(https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwRGFWfOw.woff2) format("woff2");
36
+ unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
37
+ }
38
+ @font-face {
39
+ font-family: "Geist";
40
+ font-style: normal;
41
+ font-weight: 100 900;
42
+ font-display: swap;
43
+ src: url(https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwYGFWfOw.woff2) format("woff2");
44
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
45
+ }
46
+ @font-face {
47
+ font-family: "Geist";
48
+ font-style: normal;
49
+ font-weight: 100 900;
50
+ font-display: swap;
51
+ src: url(https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwTGFWfOw.woff2) format("woff2");
52
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
53
+ }
54
+ @font-face {
55
+ font-family: "Geist";
56
+ font-style: normal;
57
+ font-weight: 100 900;
58
+ font-display: swap;
59
+ src: url(https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwSGFWfOw.woff2) format("woff2");
60
+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
61
+ }
62
+ @font-face {
63
+ font-family: "Geist";
64
+ font-style: normal;
65
+ font-weight: 100 900;
66
+ font-display: swap;
67
+ src: url(https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwcGFU.woff2) format("woff2");
68
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
69
+ }
70
+
71
+ /* JetBrains Mono — variable weight (mono). */
72
+ @font-face {
73
+ font-family: "JetBrains Mono";
74
+ font-style: normal;
75
+ font-weight: 100 800;
76
+ font-display: swap;
77
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD2OwG_TA.woff2) format("woff2");
78
+ unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
79
+ }
80
+ @font-face {
81
+ font-family: "JetBrains Mono";
82
+ font-style: normal;
83
+ font-weight: 100 800;
84
+ font-display: swap;
85
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD_OwG_TA.woff2) format("woff2");
86
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
87
+ }
88
+ @font-face {
89
+ font-family: "JetBrains Mono";
90
+ font-style: normal;
91
+ font-weight: 100 800;
92
+ font-display: swap;
93
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD4OwG_TA.woff2) format("woff2");
94
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
95
+ }
96
+ @font-face {
97
+ font-family: "JetBrains Mono";
98
+ font-style: normal;
99
+ font-weight: 100 800;
100
+ font-display: swap;
101
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD0OwG_TA.woff2) format("woff2");
102
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
103
+ }
104
+ @font-face {
105
+ font-family: "JetBrains Mono";
106
+ font-style: normal;
107
+ font-weight: 100 800;
108
+ font-display: swap;
109
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD1OwG_TA.woff2) format("woff2");
110
+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
111
+ }
112
+ @font-face {
113
+ font-family: "JetBrains Mono";
114
+ font-style: normal;
115
+ font-weight: 100 800;
116
+ font-display: swap;
117
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2) format("woff2");
118
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
119
+ }
120
+
121
+ /* Syne — variable weight (display, 400–800). */
122
+ @font-face {
123
+ font-family: "Syne";
124
+ font-style: normal;
125
+ font-weight: 400 800;
126
+ font-display: swap;
127
+ src: url(https://fonts.gstatic.com/s/syne/v24/8vIH7w4qzmVxm2NL9Hz_.woff2) format("woff2");
128
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
129
+ }
130
+ @font-face {
131
+ font-family: "Syne";
132
+ font-style: normal;
133
+ font-weight: 400 800;
134
+ font-display: swap;
135
+ src: url(https://fonts.gstatic.com/s/syne/v24/8vIH7w4qzmVxm25L9Hz_.woff2) format("woff2");
136
+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
137
+ }
138
+ @font-face {
139
+ font-family: "Syne";
140
+ font-style: normal;
141
+ font-weight: 400 800;
142
+ font-display: swap;
143
+ src: url(https://fonts.gstatic.com/s/syne/v24/8vIH7w4qzmVxm2BL9A.woff2) format("woff2");
144
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
145
+ }
146
+
147
+ /* Font families — real Tailwind tokens (utilities `font-sans` / `font-mono` /
148
+ * `font-display`), defined directly by the DS. No brand-specific indirection. */
149
+ @theme {
150
+ --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
151
+ --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
152
+ --font-display: "Syne", var(--font-sans);
153
+ }
154
+
13
155
  @theme inline {
14
156
  --color-background: var(--background);
15
157
  --color-foreground: var(--foreground);
16
- --font-sans: var(--font-geist-sans);
17
- --font-mono: var(--font-geist-mono);
18
- --font-syne: var(--font-syne);
19
158
  --color-sidebar-ring: var(--sidebar-ring);
20
159
  --color-sidebar-border: var(--sidebar-border);
21
160
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);