@filipgutica/design-system 1.0.0 → 2.0.0

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.
Files changed (37) hide show
  1. package/README.md +20 -8
  2. package/dist/class/base.css +188 -0
  3. package/dist/class/themes/graphite-indigo.css +133 -0
  4. package/dist/themes/graphite-indigo.css +9 -0
  5. package/dist/tokens.d.ts +117 -0
  6. package/dist/tokens.js +222 -0
  7. package/dist/tokens.json +218 -0
  8. package/fonts/OFL-IBM-Plex-Mono.txt +93 -0
  9. package/fonts/OFL-IBM-Plex-Sans.txt +93 -0
  10. package/fonts/fonts.css +55 -0
  11. package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  12. package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  13. package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  14. package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  15. package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  16. package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  17. package/language/DESIGN.md +29 -29
  18. package/language/components.html +189 -189
  19. package/language/components.md +55 -55
  20. package/language/decisions.md +96 -18
  21. package/language/docs.html +20 -20
  22. package/language/product.html +22 -22
  23. package/language/reference.html +213 -213
  24. package/language/tokens.css +142 -143
  25. package/language/visualizations/build-count-report.mjs +4 -2
  26. package/language/visualizations/report.css +2 -2
  27. package/package.json +33 -6
  28. package/scripts/build-tokens.mjs +0 -236
  29. package/tokens/graphite-indigo.json +0 -298
  30. /package/language/{themes → editor-themes}/graphite-indigo/LICENSE +0 -0
  31. /package/language/{themes → editor-themes}/graphite-indigo/README.md +0 -0
  32. /package/language/{themes → editor-themes}/graphite-indigo/SOURCE.json +0 -0
  33. /package/language/{themes → editor-themes}/graphite-indigo/THIRD_PARTY_NOTICES.md +0 -0
  34. /package/language/{themes → editor-themes}/graphite-indigo/graphite-indigo.t3-theme.json +0 -0
  35. /package/language/{themes → editor-themes}/graphite-indigo/package.json +0 -0
  36. /package/language/{themes → editor-themes}/graphite-indigo/themes/graphite-indigo-dark-color-theme.json +0 -0
  37. /package/language/{themes → editor-themes}/graphite-indigo/themes/graphite-indigo-light-color-theme.json +0 -0
@@ -1,236 +0,0 @@
1
- // Emits the Graphite Indigo theme from tokens/graphite-indigo.json, the only place its values live.
2
- //
3
- // node scripts/build-tokens.mjs write both files
4
- // node scripts/build-tokens.mjs --check fail when a file is stale
5
- // node scripts/build-tokens.mjs --tokens-out <path> write the standalone tokens elsewhere
6
- //
7
- // Library theme: --color-* roles for @filipgutica/ui, opt-in through
8
- // @filipgutica/ui/themes/graphite-indigo.css. Standalone tokens: the design-language
9
- // vocabulary (--bg, --text, ...) for pages that do not use the library. Each standalone
10
- // token line names the library variables for the same value, so --check also fails when
11
- // that map is stale, names a variable the library does not define, or names a
12
- // hand-written theme.css variable whose value differs from the token.
13
- import { readFileSync, writeFileSync } from 'node:fs'
14
- import { fileURLToPath, pathToFileURL } from 'node:url'
15
-
16
- const LIGHT = 0
17
- const DARK = 1
18
- const reference = /\{([\w-]+)\}/g
19
-
20
- const flatTokens = (data) => Object.fromEntries(data.groups.flatMap(({ tokens }) => Object.entries(tokens)))
21
-
22
- const valueFor = (tokens, name, mode) => {
23
- const value = tokens[name]
24
- if (value === undefined) throw new Error(`Unknown token "${name}"`)
25
- return Array.isArray(value) ? value[mode] : value
26
- }
27
-
28
- const block = (indent, declarations) => declarations.map(([name, value]) => `${indent}${name}: ${value};`)
29
-
30
- const variablesIn = (css) => new Set([...css.matchAll(/(--[\w-]+)\s*:/g)].map(([, name]) => name))
31
-
32
- // Dark blocks list only what differs from light, compared after references resolve.
33
- const darkOverrides = (names, resolve) => names
34
- .map((name) => [name, resolve(name, LIGHT), resolve(name, DARK)])
35
- .filter(([, light, dark]) => light !== dark)
36
- .map(([name, , dark]) => [name, dark])
37
-
38
- export const renderLibraryTheme = (data) => {
39
- const tokens = flatTokens(data)
40
- const { roles, extras } = data.library
41
- const roleOfToken = new Map()
42
- for (const [role, token] of Object.entries(roles)) if (!roleOfToken.has(token)) roleOfToken.set(token, role)
43
-
44
- // A reference stays a live var() when its target has a role, so custom themes flow
45
- // through derived values. Otherwise the target's value is inlined.
46
- const resolve = (name, mode) => valueFor(tokens, name, mode).replace(
47
- reference,
48
- (_, target) => roleOfToken.has(target) ? `var(${roleOfToken.get(target)})` : resolve(target, mode),
49
- )
50
- const roleNames = Object.keys(roles)
51
- const resolveRole = (role, mode) => {
52
- const canonicalRole = roleOfToken.get(roles[role])
53
- return canonicalRole === role ? resolve(roles[role], mode) : `var(${canonicalRole})`
54
- }
55
-
56
- const light = [
57
- ...roleNames.map((role) => [role, resolveRole(role, LIGHT)]),
58
- ...extras.map((name) => [`--${name}`, resolve(name, LIGHT)]),
59
- ]
60
- // Repeat every role in dark mode: theme.css's :root.dark otherwise outranks
61
- // this theme's light :root aliases and values shared by both modes.
62
- const dark = roleNames.map((role) => [role, resolveRole(role, DARK)])
63
-
64
- return [
65
- '/* Generated from themes/graphite-indigo.json by scripts/graphite-indigo.mjs. Do not edit.',
66
- ' * Opt-in Graphite Indigo roles for @filipgutica/ui. Import after theme.css.',
67
- ' * Dark mode uses the same .dark class as theme.css. Keep exactly one :root.dark block:',
68
- ' * sites copy it into a <noscript> prefers-color-scheme rule. */',
69
- '',
70
- ':root {',
71
- ' color-scheme: light;',
72
- ...block(' ', light),
73
- '}',
74
- '',
75
- ':root.dark {',
76
- ' color-scheme: dark;',
77
- ...block(' ', dark),
78
- '}',
79
- '',
80
- ].join('\n')
81
- }
82
-
83
- const standaloneHeader = `/*
84
- * Design language tokens. Generated from themes/graphite-indigo.json in
85
- * @filipgutica/ui; edit that file and run \`pnpm themes:build\`. Values live there.
86
- * DESIGN.md names these tokens; it never repeats their values.
87
- *
88
- * Standalone HTML: import or inline this file.
89
- * Inline visuals: inherit the host font and theme variables; see DESIGN.md.
90
- * Repos: map these names onto the repository's own token system.
91
- * Sites on @filipgutica/ui: use the variable named in each line's "ui:" comment.
92
- * When a line names several, use the first; the others are component roles with the same value.
93
- *
94
- * Theme states: bare :root is light. prefers-color-scheme picks dark unless
95
- * data-theme="light" is set. data-theme="dark" forces dark.
96
- */
97
- `
98
-
99
- const standaloneBase = `/* Minimal base. Component styles live in reference.html. */
100
- *, *::before, *::after { box-sizing: border-box; }
101
- [hidden] { display: none !important; }
102
- body {
103
- margin: 0;
104
- background: var(--bg);
105
- color: var(--text);
106
- font: var(--weight-regular) var(--text-md) / var(--leading) var(--font-sans);
107
- -webkit-font-smoothing: antialiased;
108
- }
109
- h1, h2, h3, h4, p { margin: 0; }
110
- h1, h2, h3, h4 { font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); text-wrap: balance; }
111
- code, kbd, pre { font-family: var(--font-mono); }
112
- table, .num { font-variant-numeric: tabular-nums; }
113
- a { color: var(--link); text-decoration: none; }
114
- a:hover { text-decoration: underline; }
115
- p a, dd a { text-decoration: underline; text-underline-offset: 0.18em; }
116
- :focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
117
- @media (prefers-reduced-motion: reduce) {
118
- *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
119
- }
120
- `
121
-
122
- // The library variables that carry each token: its roles, a fixed alias for a renamed
123
- // token, or a variable of the same name. libraryCss is theme.css, the library's base theme.
124
- const libraryNamesFor = (data, libraryCss) => {
125
- const defined = new Set([...variablesIn(libraryCss), ...variablesIn(renderLibraryTheme(data))])
126
- const { roles, aliases } = data.library
127
- const tokens = flatTokens(data)
128
- // Aliases and same-name variables take their values from the hand-written theme.css, not
129
- // from this file, so compare them: 1rem is 16px, and quote style does not matter.
130
- const handWritten = {}
131
- for (const [, variable, value] of libraryCss.matchAll(/(--[\w-]+)\s*:\s*([^;]+);/g)) handWritten[variable] ??= value.trim()
132
- const normalize = (value) => value.replace(/'/g, '"').replace(/([\d.]+)rem\b/g, (_, rem) => `${Number(rem) * 16}px`)
133
- const assertSameValue = (name, variable) => {
134
- const value = handWritten[variable]
135
- const token = valueFor(tokens, name, LIGHT)
136
- if (value !== undefined && normalize(value) !== normalize(token)) {
137
- throw new Error(`Token "${name}" is ${token}, but ${variable} in theme.css is ${value}`)
138
- }
139
- }
140
- return (name) => {
141
- // The general variable leads; the rest are component roles that share its value.
142
- const names = Object.entries(roles).filter(([, token]) => token === name).map(([role]) => role)
143
- .sort((a, b) => Number(b === `--color-${name}`) - Number(a === `--color-${name}`))
144
- const alias = aliases[name]
145
- if (alias !== undefined) {
146
- if (!defined.has(alias)) throw new Error(`Alias for "${name}" names ${alias}, which the library does not define`)
147
- assertSameValue(name, alias)
148
- names.push(alias)
149
- }
150
- if (names.length === 0 && defined.has(`--${name}`)) {
151
- assertSameValue(name, `--${name}`)
152
- names.push(`--${name}`)
153
- }
154
- // A token sites cannot reach through the library does not belong in the shared vocabulary.
155
- if (names.length === 0) {
156
- throw new Error(`Token "${name}" has no library variable; add a role, an alias, or an extra`)
157
- }
158
- return names.join(', ')
159
- }
160
- }
161
-
162
- export const renderStandaloneTokens = ({ data, libraryCss }) => {
163
- const tokens = flatTokens(data)
164
- const resolve = (name, mode) => valueFor(tokens, name, mode).replace(reference, (_, target) => `var(--${target})`)
165
- const names = Object.keys(tokens)
166
- const dark = darkOverrides(names, resolve).map(([name, value]) => [`--${name}`, value])
167
- const libraryNames = libraryNamesFor(data, libraryCss)
168
-
169
- const groups = data.groups.map(({ comment, tokens: group }) => [
170
- '',
171
- ` /* ${comment} */`,
172
- ...Object.keys(group).map((name) => ` --${name}: ${resolve(name, LIGHT)}; /* ui: ${libraryNames(name)} */`),
173
- ])
174
- const darkLines = (indent) => block(indent, dark)
175
-
176
- return [
177
- standaloneHeader,
178
- ':root {',
179
- ' color-scheme: light;',
180
- ...groups.flat(),
181
- '}',
182
- '',
183
- '@media (prefers-color-scheme: dark) {',
184
- ' :root:not([data-theme="light"]) {',
185
- ' color-scheme: dark;',
186
- ...darkLines(' '),
187
- ' }',
188
- '}',
189
- '',
190
- ':root[data-theme="dark"] {',
191
- ' color-scheme: dark;',
192
- ...darkLines(' '),
193
- '}',
194
- '',
195
- standaloneBase,
196
- ].join('\n')
197
- }
198
-
199
- const run = () => {
200
- const root = fileURLToPath(new URL('..', import.meta.url))
201
- const libraryPath = `${root}src/themes/graphite-indigo.css`
202
- const tokensPath = `${root}themes/graphite-indigo.tokens.css`
203
- const args = process.argv.slice(2)
204
- const check = args.includes('--check')
205
- const outIndex = args.indexOf('--tokens-out')
206
- const tokensOut = outIndex === -1 ? tokensPath : args[outIndex + 1]
207
- if (!tokensOut) throw new Error('--tokens-out needs a path')
208
-
209
- const data = JSON.parse(readFileSync(`${root}tokens/graphite-indigo.json`, 'utf8'))
210
- const libraryCss = readFileSync(`${root}src/theme.css`, 'utf8')
211
- const outputs = [
212
- [libraryPath, renderLibraryTheme(data)],
213
- [tokensOut, renderStandaloneTokens({ data, libraryCss })],
214
- ]
215
-
216
- const stale = []
217
- for (const [path, content] of outputs) {
218
- if (!check) {
219
- writeFileSync(path, content)
220
- continue
221
- }
222
- let current
223
- try {
224
- current = readFileSync(path, 'utf8')
225
- } catch {
226
- // A missing file is stale.
227
- }
228
- if (current !== content) stale.push(path)
229
- }
230
- if (stale.length > 0) {
231
- console.error(`Stale generated files. Run "pnpm themes:build":\n${stale.map((path) => ` ${path}`).join('\n')}`)
232
- process.exitCode = 1
233
- }
234
- }
235
-
236
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) run()
@@ -1,298 +0,0 @@
1
- {
2
- "groups": [
3
- {
4
- "comment": "Neutral paper and graphite surfaces.",
5
- "tokens": {
6
- "bg": [
7
- "#f4f5f6",
8
- "#0d1012"
9
- ],
10
- "surface": [
11
- "#e9ebed",
12
- "#13171a"
13
- ],
14
- "surface-raised": [
15
- "#fbfbfc",
16
- "#181d21"
17
- ],
18
- "surface-hover": [
19
- "#e2e5e8",
20
- "#20262b"
21
- ],
22
- "row-hover": [
23
- "#e2e5e8",
24
- "#20262b"
25
- ],
26
- "row-selected": "{surface-raised}",
27
- "border-subtle": [
28
- "#d3d8dd",
29
- "#262d33"
30
- ],
31
- "border": [
32
- "#6d747b",
33
- "#78818a"
34
- ],
35
- "text": [
36
- "#101315",
37
- "#e6e9eb"
38
- ],
39
- "text-muted": [
40
- "#50575e",
41
- "#9aa3ab"
42
- ]
43
- }
44
- },
45
- {
46
- "comment": "Project hue for primary actions, selection, and the one focus ring; links stay separate.",
47
- "tokens": {
48
- "project": [
49
- "#4b45d1",
50
- "#a5a1ff"
51
- ],
52
- "project-dark": "#a5a1ff",
53
- "accent": "{project}",
54
- "accent-text": "{bg}",
55
- "accent-hover": "{text}",
56
- "link": [
57
- "#0b5f7c",
58
- "#67c1df"
59
- ],
60
- "focus": "{accent}",
61
- "focus-width": "2px",
62
- "focus-offset": "3px",
63
- "button-hover": "color-mix(in srgb, {accent} 85%, {text})"
64
- }
65
- },
66
- {
67
- "comment": "Status: only for state, never for decoration.",
68
- "tokens": {
69
- "success": [
70
- "#157249",
71
- "#4cc38a"
72
- ],
73
- "warning": [
74
- "#86532e",
75
- "#e2a54b"
76
- ],
77
- "danger": [
78
- "#bd342b",
79
- "#f0776c"
80
- ],
81
- "info": [
82
- "#175cd3",
83
- "#84adff"
84
- ],
85
- "success-soft": [
86
- "#d9e5e1",
87
- "#172d25"
88
- ],
89
- "warning-soft": [
90
- "#e7e2de",
91
- "#2f281b"
92
- ],
93
- "danger-soft": [
94
- "#efe4e4",
95
- "#312020"
96
- ],
97
- "info-soft": [
98
- "#d9e3f2",
99
- "#202938"
100
- ]
101
- }
102
- },
103
- {
104
- "comment": "Code",
105
- "tokens": {
106
- "command-bg": [
107
- "color-mix(in srgb, {project} 25%, #101010)",
108
- "color-mix(in srgb, {project} 16%, black)"
109
- ],
110
- "command-border": [
111
- "transparent",
112
- "color-mix(in srgb, {project} 28%, black)"
113
- ],
114
- "terminal": "#0a0c0e",
115
- "terminal-text": "#e6e9eb",
116
- "terminal-border": "#2a3036",
117
- "terminal-caption": "#13171a",
118
- "terminal-caption-text": "#c9d0d6",
119
- "code-bg": "{surface}",
120
- "code-text": "{text}",
121
- "code-key": [
122
- "#715b42",
123
- "#d8c2a5"
124
- ],
125
- "code-string": [
126
- "#346347",
127
- "#a8bd9c"
128
- ],
129
- "code-number": [
130
- "#86532e",
131
- "#d5b98c"
132
- ],
133
- "code-comment": [
134
- "#626772",
135
- "#a0a6b1"
136
- ]
137
- }
138
- },
139
- {
140
- "comment": "Self-hosted IBM Plex latin faces (OFL); system fallbacks.",
141
- "tokens": {
142
- "font-sans": "\"IBM Plex Sans\", -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"Segoe UI\", system-ui, sans-serif",
143
- "font-mono": "\"IBM Plex Mono\", ui-monospace, \"SF Mono\", SFMono-Regular, Menlo, Consolas, monospace",
144
- "text-xs": "0.75rem",
145
- "text-sm": "0.8125rem",
146
- "text-md": "0.875rem",
147
- "text-lg": "1rem",
148
- "text-xl": "1.25rem",
149
- "text-2xl": "1.5rem",
150
- "text-3xl": "2.75rem",
151
- "text-reading": "1rem",
152
- "text-display": "3.5rem",
153
- "text-display-sm": "2.125rem",
154
- "leading-tight": "1.25",
155
- "leading": "1.6",
156
- "weight-regular": "400",
157
- "weight-medium": "500",
158
- "weight-semibold": "600",
159
- "tracking-tight": "-0.03em",
160
- "text-code": "0.84375rem"
161
- }
162
- },
163
- {
164
- "comment": "Space: 4px rhythm.",
165
- "tokens": {
166
- "space-1": "0.25rem",
167
- "space-2": "0.5rem",
168
- "space-3": "0.75rem",
169
- "space-4": "1rem",
170
- "space-5": "1.25rem",
171
- "space-6": "1.5rem",
172
- "space-8": "2rem",
173
- "space-12": "3rem",
174
- "space-16": "4rem",
175
- "space-20": "5rem",
176
- "space-24": "6rem"
177
- }
178
- },
179
- {
180
- "comment": "Size",
181
- "tokens": {
182
- "control-sm": "2rem",
183
- "control-md": "2.25rem",
184
- "control-lg": "2.75rem",
185
- "row": "2.25rem",
186
- "measure": "68ch",
187
- "page-max": "960px",
188
- "page-wide": "1120px",
189
- "sidebar": "224px"
190
- }
191
- },
192
- {
193
- "comment": "Shape",
194
- "tokens": {
195
- "radius-sm": "6px",
196
- "radius-md": "999px",
197
- "radius-field": "10px",
198
- "radius-lg": "16px",
199
- "radius-pill": "999px"
200
- }
201
- },
202
- {
203
- "comment": "Elevation: floating layers only (menus, popovers, dialogs).",
204
- "tokens": {
205
- "shadow-popover": [
206
- "0 8px 24px rgb(16 16 24 / 12%), 0 0 0 1px {border-subtle}",
207
- "0 8px 24px rgb(0 0 0 / 45%), 0 0 0 1px {border-subtle}"
208
- ]
209
- }
210
- },
211
- {
212
- "comment": "Motion",
213
- "tokens": {
214
- "duration-fast": "120ms",
215
- "duration": "180ms",
216
- "ease-out": "cubic-bezier(0.2, 0.8, 0.2, 1)"
217
- }
218
- }
219
- ],
220
- "library": {
221
- "roles": {
222
- "--color-project": "project",
223
- "--color-project-dark": "project-dark",
224
- "--color-bg": "bg",
225
- "--color-surface": "surface",
226
- "--color-surface-raised": "surface-raised",
227
- "--color-surface-muted": "surface-hover",
228
- "--color-text": "text",
229
- "--color-muted": "text-muted",
230
- "--color-link": "link",
231
- "--color-accent": "accent",
232
- "--color-accent-text": "accent-text",
233
- "--color-focus": "focus",
234
- "--color-border": "border",
235
- "--color-border-subtle": "border-subtle",
236
- "--color-button-bg": "accent",
237
- "--color-button-text": "accent-text",
238
- "--color-button-hover": "button-hover",
239
- "--color-input-bg": "surface-raised",
240
- "--color-input-text": "text",
241
- "--color-input-border": "border",
242
- "--color-input-placeholder": "text-muted",
243
- "--color-row-hover": "row-hover",
244
- "--color-row-selected": "row-selected",
245
- "--color-row-selected-text": "text",
246
- "--color-code": "code-bg",
247
- "--color-code-text": "code-text",
248
- "--color-syntax-comment": "code-comment",
249
- "--color-syntax-keyword": "code-key",
250
- "--color-syntax-string": "code-string",
251
- "--color-syntax-number": "code-number",
252
- "--color-syntax-function": "code-key",
253
- "--color-syntax-type": "code-number",
254
- "--color-syntax-variable": "code-text",
255
- "--color-syntax-operator": "text-muted",
256
- "--color-syntax-punctuation": "text-muted",
257
- "--color-syntax-tag": "code-key",
258
- "--color-syntax-attribute": "code-number",
259
- "--color-error": "danger",
260
- "--color-warning": "warning",
261
- "--color-success": "success",
262
- "--color-info": "info",
263
- "--color-progress": "accent",
264
- "--color-error-surface": "danger-soft",
265
- "--color-warning-surface": "warning-soft",
266
- "--color-success-surface": "success-soft",
267
- "--color-info-surface": "info-soft",
268
- "--shadow-dialog": "shadow-popover",
269
- "--color-status-text": "text",
270
- "--color-terminal": "terminal",
271
- "--color-terminal-text": "terminal-text",
272
- "--color-terminal-border": "terminal-border",
273
- "--color-terminal-caption": "terminal-caption",
274
- "--color-terminal-caption-text": "terminal-caption-text",
275
- "--color-accent-hover": "accent-hover",
276
- "--color-command-bg": "command-bg",
277
- "--color-command-border": "command-border"
278
- },
279
- "aliases": {
280
- "font-sans": "--font-ui",
281
- "radius-sm": "--radius-inline",
282
- "radius-md": "--radius-control",
283
- "radius-field": "--radius-field",
284
- "radius-lg": "--radius-panel"
285
- },
286
- "extras": [
287
- "text-3xl",
288
- "text-reading",
289
- "text-display",
290
- "text-display-sm",
291
- "tracking-tight",
292
- "space-20",
293
- "space-24",
294
- "row",
295
- "page-wide"
296
- ]
297
- }
298
- }