@filipgutica/design-system 1.0.37 → 1.0.39
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/README.md +9 -8
- package/dist/theme-inputs.json +75 -0
- package/dist/themes/catppuccin.css +29 -2
- package/dist/themes/copper.css +7 -2
- package/dist/themes/fern.css +7 -2
- package/dist/themes/github.css +27 -0
- package/dist/themes/graphite-indigo.css +3 -2
- package/dist/themes/iris.css +7 -2
- package/dist/themes/lagoon.css +7 -2
- package/dist/themes/lapis.css +7 -2
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.js +92 -76
- package/dist/tokens.json +92 -76
- package/fonts/{OFL-IBM-Plex-Sans.txt → OFL-Inter.txt} +1 -1
- package/fonts/{OFL-IBM-Plex-Mono.txt → OFL-JetBrains-Mono.txt} +1 -1
- package/fonts/fonts.css +13 -13
- package/fonts/inter-latin-400-normal.woff2 +0 -0
- package/fonts/inter-latin-500-normal.woff2 +0 -0
- package/fonts/inter-latin-600-normal.woff2 +0 -0
- package/fonts/jetbrains-mono-latin-400-normal.woff2 +0 -0
- package/fonts/jetbrains-mono-latin-500-normal.woff2 +0 -0
- package/fonts/jetbrains-mono-latin-600-normal.woff2 +0 -0
- package/language/DESIGN.md +10 -9
- package/language/components.html +49 -28
- package/language/components.md +12 -11
- package/language/decisions.md +11 -6
- package/language/docs.html +7 -10
- package/language/product.html +0 -3
- package/language/reference.html +42 -22
- package/language/tokens.css +151 -13
- package/language/ui-sdk.css +2 -2
- package/package.json +2 -1
- package/theme-mapper/core.js +9 -8
- package/theme-mapper/engine.d.ts +37 -2
- package/theme-mapper/engine.js +49 -4
- package/theme-mapper/index.d.ts +5 -0
- package/theme-mapper/index.js +15 -0
- package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
package/theme-mapper/engine.js
CHANGED
|
@@ -12,13 +12,21 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** @typedef {{ light: string, dark: string }} ModePair */
|
|
14
14
|
/**
|
|
15
|
-
* One theme's inputs, for light and for dark. Fonts and neutrals stay core unless the theme
|
|
15
|
+
* One theme's inputs, for light and for dark. Fonts, the base radius, and neutrals stay core unless the theme
|
|
16
|
+
* names its own.
|
|
16
17
|
* @typedef {object} ThemeInputs
|
|
17
18
|
* @property {ModePair} hue The hue, `--color-project` in light and `--color-project-dark`.
|
|
18
19
|
* @property {{ ui?: string, mono?: string }} [fonts] The two font stacks.
|
|
20
|
+
* @property {string} [radius] The base radius, `--radius-base`, as a CSS length.
|
|
19
21
|
* @property {{ light: Record<string, string>, dark: Record<string, string> }} [neutrals] Every NEUTRALS token, per mode.
|
|
20
22
|
* @property {{ light?: Record<string, string>, dark?: Record<string, string> }} [syntax] Syntax colours by SYNTAX_ROLES
|
|
21
23
|
* role, per mode. A role a theme leaves out stays core.
|
|
24
|
+
* @property {{ light?: Record<string, string>, dark?: Record<string, string> }} [textOnHue] The text on the hue's
|
|
25
|
+
* fills, by TEXT_ON_HUE_TOKENS name, per mode, for a theme that sets its own. Each value is `#rrggbb`, `white`,
|
|
26
|
+
* `black`, or a token reference such as `{color-bg}`; for example `{ light: { 'color-accent-text': '#ffffff' } }`.
|
|
27
|
+
* A token a theme leaves out keeps its default: `color-accent-text` stays `{color-bg}`, which a pale hue can fail,
|
|
28
|
+
* and the selected-fill text tokens take the first candidate that reaches 4.5:1, or the accent when none does.
|
|
29
|
+
* Run checkTheme on the result.
|
|
22
30
|
*/
|
|
23
31
|
/**
|
|
24
32
|
* Every token's resolved value in light and in dark, as getComputedStyle reports it.
|
|
@@ -162,6 +170,34 @@ const TEXT_ON_FILL = {
|
|
|
162
170
|
/** The selected-fill text tokens, which take their readable value from the theme. */
|
|
163
171
|
export const TEXT_ON_FILL_TOKENS = Object.keys(TEXT_ON_FILL)
|
|
164
172
|
const TEXT_CANDIDATES = ['{color-accent}', '{color-text}', 'black', 'white']
|
|
173
|
+
/** The text on the hue's fills, which a theme may set: the primary label and the selected-fill text. */
|
|
174
|
+
export const TEXT_ON_HUE_TOKENS = ['color-accent-text', ...TEXT_ON_FILL_TOKENS]
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The tokens a theme may set, by kind, without their leading dashes. Every other token is core, and a theme
|
|
178
|
+
* never overrides it: the identity group's hue pair, fonts, and base radius; the text on the hue's fills,
|
|
179
|
+
* which a theme sets when its hue cannot carry the default; the neutrals, as a whole set; and the syntax
|
|
180
|
+
* colours, which an imported theme sets.
|
|
181
|
+
* @param {TokenSource} data
|
|
182
|
+
* @returns {{ hue: string[], textOnHue: string[], fonts: string[], radius: string[], neutrals: string[], syntax: string[] }}
|
|
183
|
+
*/
|
|
184
|
+
export const themeInputNames = (data) => {
|
|
185
|
+
const identity = Object.keys(data.groups.find(({ identity: isIdentity }) => isIdentity)?.tokens ?? {})
|
|
186
|
+
/** @param {string} prefix */
|
|
187
|
+
const take = (prefix) => identity.filter((name) => name.startsWith(prefix))
|
|
188
|
+
const inputs = {
|
|
189
|
+
hue: take('color-'),
|
|
190
|
+
textOnHue: [...TEXT_ON_HUE_TOKENS],
|
|
191
|
+
fonts: take('font-'),
|
|
192
|
+
radius: take('radius-'),
|
|
193
|
+
neutrals: [...NEUTRALS],
|
|
194
|
+
syntax: SYNTAX_ROLES.map((role) => `color-syntax-${role}`),
|
|
195
|
+
}
|
|
196
|
+
const sorted = Object.values(inputs).flat()
|
|
197
|
+
const unsorted = identity.filter((name) => !sorted.includes(name))
|
|
198
|
+
if (unsorted.length > 0) throw new Error(`Identity tokens with no input kind: ${unsorted.join(', ')}`)
|
|
199
|
+
return inputs
|
|
200
|
+
}
|
|
165
201
|
|
|
166
202
|
// Sets each TEXT_ON_FILL token to its first candidate that reaches 4.5:1, per mode. When none does, the
|
|
167
203
|
// accent stays, so the contrast tests fail on it rather than on a silently chosen colour.
|
|
@@ -188,8 +224,9 @@ const withReadableText = (data) => {
|
|
|
188
224
|
}
|
|
189
225
|
|
|
190
226
|
/**
|
|
191
|
-
* The core tokens with one theme's inputs filled in. Core leaves the hue pair empty; its font stacks
|
|
192
|
-
* neutrals stay unless the theme names its own. Then each selected-fill text token takes its readable value
|
|
227
|
+
* The core tokens with one theme's inputs filled in. Core leaves the hue pair empty; its font stacks, base
|
|
228
|
+
* radius, and neutrals stay unless the theme names its own. Then each selected-fill text token takes its readable value,
|
|
229
|
+
* and any text on the hue the theme sets replaces it.
|
|
193
230
|
* @template {TokenSource} Data
|
|
194
231
|
* @param {Data} core
|
|
195
232
|
* @param {ThemeInputs} theme
|
|
@@ -205,6 +242,7 @@ export const applyTheme = (core, theme) => {
|
|
|
205
242
|
identity['color-project-dark'] = theme.hue.dark
|
|
206
243
|
if (theme.fonts?.ui) identity['font-ui'] = theme.fonts.ui
|
|
207
244
|
if (theme.fonts?.mono) identity['font-mono'] = theme.fonts.mono
|
|
245
|
+
if (theme.radius) identity['radius-base'] = theme.radius
|
|
208
246
|
const { neutrals } = theme
|
|
209
247
|
if (neutrals) for (const name of NEUTRALS) groupOf(data, name).tokens[name] = [neutrals.light[name], neutrals.dark[name]]
|
|
210
248
|
for (const role of SYNTAX_ROLES) {
|
|
@@ -214,7 +252,14 @@ export const applyTheme = (core, theme) => {
|
|
|
214
252
|
const { tokens } = groupOf(data, name)
|
|
215
253
|
tokens[name] = [light ?? valueFor(tokens, name, LIGHT), dark ?? valueFor(tokens, name, DARK)]
|
|
216
254
|
}
|
|
217
|
-
|
|
255
|
+
withReadableText(data)
|
|
256
|
+
for (const name of TEXT_ON_HUE_TOKENS) {
|
|
257
|
+
const [light, dark] = [theme.textOnHue?.light?.[name], theme.textOnHue?.dark?.[name]]
|
|
258
|
+
if (light === undefined && dark === undefined) continue
|
|
259
|
+
const { tokens } = groupOf(data, name)
|
|
260
|
+
tokens[name] = [light ?? valueFor(tokens, name, LIGHT), dark ?? valueFor(tokens, name, DARK)]
|
|
261
|
+
}
|
|
262
|
+
return data
|
|
218
263
|
}
|
|
219
264
|
|
|
220
265
|
// The contrast checks, as data: each pair is an ink and the fill below it, as language/components.html draws
|
package/theme-mapper/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
export function checkTheme(inputs: ThemeInputs): ThemeCheck[];
|
|
1
2
|
export type VsCodeTheme = import("./vscode.js").VsCodeTheme;
|
|
2
3
|
export type MappedTheme = import("./vscode.js").MappedTheme;
|
|
3
4
|
export type Problem = import("./vscode.js").Problem;
|
|
4
5
|
export type ThemeColours = import("./vscode.js").ThemeColours;
|
|
6
|
+
export type ThemeInputs = import("./engine.js").ThemeInputs;
|
|
7
|
+
export type ThemeCheck = import("./engine.js").CheckResult & {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
};
|
|
5
10
|
export { ThemeValidationError, mapVsCodeTheme, themeVariables } from "./vscode.js";
|
package/theme-mapper/index.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
// @filipgutica/design-system/theme-mapper: maps other theme formats onto the design system's theme inputs,
|
|
2
2
|
// with no framework and no runtime dependencies. Experimental: the API may change in a minor release.
|
|
3
|
+
import { core } from './core.js'
|
|
4
|
+
import { applyTheme, passes, resolveData, themeChecks } from './engine.js'
|
|
5
|
+
|
|
3
6
|
export { ThemeValidationError, mapVsCodeTheme, themeVariables } from './vscode.js'
|
|
4
7
|
|
|
5
8
|
/** @typedef {import('./vscode.js').VsCodeTheme} VsCodeTheme */
|
|
6
9
|
/** @typedef {import('./vscode.js').MappedTheme} MappedTheme */
|
|
7
10
|
/** @typedef {import('./vscode.js').Problem} Problem */
|
|
8
11
|
/** @typedef {import('./vscode.js').ThemeColours} ThemeColours */
|
|
12
|
+
/** @typedef {import('./engine.js').ThemeInputs} ThemeInputs */
|
|
13
|
+
/** @typedef {import('./engine.js').CheckResult & { ok: boolean }} ThemeCheck */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Runs the contrast checks every shipped theme passes, in light and dark, on one theme's inputs: the same
|
|
17
|
+
* checks as the token build. Each result has its lowest ratio per mode, and `ok` when both reach its minimum.
|
|
18
|
+
* Use it to check a theme this package does not ship. Experimental.
|
|
19
|
+
* @param {ThemeInputs} inputs
|
|
20
|
+
* @returns {ThemeCheck[]}
|
|
21
|
+
*/
|
|
22
|
+
export const checkTheme = (inputs) => themeChecks(resolveData(applyTheme(core, inputs)))
|
|
23
|
+
.map((check) => ({ ...check, ok: passes(check.light, check.min) && passes(check.dark, check.min) }))
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|