@cueplusplus/tokens 0.13.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.
package/dist/tokens.js ADDED
@@ -0,0 +1,240 @@
1
+ /**
2
+ * @cueplusplus/tokens — the runtime half of the public contract.
3
+ * Generated by build.mjs. Do not edit by hand.
4
+ *
5
+ * The typed half is `tokens.d.ts`, beside this file and generated with it:
6
+ * `Density`, `Mode`, `ColorToken`, `GeometryToken`, `FontToken`, `FontName`,
7
+ * `FontDelivery` and `FontPairing` are declared there. This file is plain
8
+ * JavaScript because Node refuses to strip types under `node_modules`, so a
9
+ * `.ts` entry is one a registry consumer cannot load.
10
+ */
11
+
12
+ /**
13
+ * There is no `THEMES`, and no `ThemeName`, in this package any more.
14
+ *
15
+ * A palette is a package: `ThemeName` is `@cueplusplus/theme-base`'s, and it is
16
+ * the keys of a registry interface every installed theme package augments —
17
+ * open by construction, where a tuple baked into this build could only ever
18
+ * name the ten that happened to live here. `@cueplusplus/ui` re-exports it.
19
+ */
20
+
21
+ /** Every density level, in ladder order. */
22
+ export const DENSITIES = ["ultra-compact", "compact", "normal", "large", "ultra-large"];
23
+
24
+ /** Color-scheme modes. `system` tracks `prefers-color-scheme`. */
25
+ export const MODES = ["dark", "light", "system"];
26
+
27
+ /**
28
+ * The values the ThemeProvider falls back to on the two axes this package still
29
+ * owns. There is no `DEFAULT_THEME`: with no preset shipped here there is no
30
+ * default palette to name, and a page that registers nothing paints
31
+ * `@cueplusplus/theme-base`'s blank base rather than somebody's brand.
32
+ */
33
+ export const DEFAULT_DENSITY = "compact";
34
+ export const DEFAULT_MODE = "dark";
35
+
36
+ /** The colour tokens every theme block declares, in emission order. */
37
+ export const COLOR_CONTRACT = ["bg", "sunken", "surface-1", "surface-2", "surface-3", "fg", "fg-muted", "fg-subtle", "border", "border-strong", "border-overlay", "accent", "accent-hover", "accent-fg", "ok", "busy", "warn", "warn-fg", "danger", "danger-fg", "info", "stream", "selection", "focus", "data-ground", "scrim"];
38
+
39
+ /** The geometry tokens every density block declares, in emission order. */
40
+ export const GEOMETRY_CONTRACT = ["control-sm", "control-md", "control-lg", "chip-h", "icon-sm", "icon-md", "text-micro", "text-label", "text-ui", "text-body", "text-emphasis", "text-title", "radius-control", "radius-surface", "radius-overlay", "pad-row-y", "pad-row-x", "space-1", "space-2", "space-3", "space-4", "space-5", "space-6", "space-7", "space-8", "chrome-toolbar", "chrome-statusbar", "chrome-titlebar", "density", "radius-scale"];
41
+
42
+ /** The three type stacks a pairing may name. */
43
+ export const FONT_TOKENS = ["font-sans", "font-mono", "font-display"];
44
+
45
+ /**
46
+ * The page-composition tokens `:root` declares, in emission order.
47
+ *
48
+ * The `:root` slice, which is wider than a set's: `leading-ui` and the three
49
+ * page widths are here and belong to no set (a set that moved either would
50
+ * restyle every settings page and form in the library while claiming to compose
51
+ * a page), and `style-display` is the other way round — a set may declare it and
52
+ * `:root` must not, so a page under no set renders a hero's own literal through
53
+ * the `var()` fallback.
54
+ */
55
+ export const STYLE_CONTRACT = ["leading-prose", "leading-ui", "measure-narrow", "measure-wide", "measure-broad", "measure-prose", "band-y", "band-rule", "band-ground"];
56
+
57
+ /** The page-composition tokens every `[data-style]` block declares. */
58
+ export const STYLE_SET_CONTRACT = ["measure-prose", "leading-prose", "band-y", "band-rule", "band-ground"];
59
+
60
+ /**
61
+ * Style sets, in menu order — the fourth composable axis.
62
+ *
63
+ * `console` restates the `:root` defaults exactly (the build refuses it if one
64
+ * value differs), so switching to it changes nothing; it exists because a picker
65
+ * needs a row to point at and a subtree inside an `editorial` page needs a block
66
+ * to reset to.
67
+ */
68
+ export const STYLE_SETS = ["console", "editorial", "marketing"];
69
+
70
+ /**
71
+ * The set that costs nothing.
72
+ *
73
+ * NOT what a `<ThemeProvider>` opens on: the provider stamps no `data-style` at
74
+ * all, because a style set is opt-in page composition. This is the set a subtree
75
+ * stamps to declare itself ordinary inside a page that is not.
76
+ */
77
+ export const DEFAULT_STYLE_SET = "console";
78
+
79
+ /*
80
+ * `THEME_SUPPORTS_LIGHT` is gone with the presets: whether a theme ships a light
81
+ * block is now `supportsLight` on its own `manifest.json`, which is the only
82
+ * place that can answer it for a theme this build never saw.
83
+ */
84
+
85
+ /** Every font pairing, in menu order. `system` is the default and costs nothing. */
86
+ export const FONTS = ["system", "geist", "inter", "plex", "roboto", "source", "apple", "office"];
87
+
88
+ /**
89
+ * The pairing an app that never touched the axis renders at.
90
+ *
91
+ * It declares no `--cue-font-mono`, so a preset's own monospace survives it.
92
+ * Every other pairing was chosen by a person and outranks the preset on both
93
+ * families — see the `[data-font]` blocks at the end of `theme.css`.
94
+ */
95
+ export const DEFAULT_FONT = "system";
96
+
97
+ /**
98
+ * How a pairing reaches a reader's screen.
99
+ *
100
+ * - `none` — the platform's own faces. Nothing to download, resolves everywhere.
101
+ * - `webfont` — freely redistributable; the app self-hosts it and assigns the
102
+ * `faces` properties. Undelivered, the stack still resolves: a local install
103
+ * first, then the platform.
104
+ * - `system` — licensed such that it CANNOT be served (SF Pro, Calibri). It
105
+ * lights up where installed and falls through cleanly where it is not, and no
106
+ * app may bundle it.
107
+ *
108
+ * @typedef {"none" | "webfont" | "system"} FontDelivery
109
+ */
110
+
111
+ /**
112
+ * One pairing, for a picker row, a docs table and a delivery wiring.
113
+ *
114
+ * @typedef {object} FontPairing
115
+ * @property {string} label Menu label.
116
+ * @property {string} sans The sans family this pairing names.
117
+ * @property {string | null} mono The mono family, or `null` for the default pairing, which leaves the theme's.
118
+ * @property {FontDelivery} delivery How it reaches a screen.
119
+ * @property {readonly string[]} faces Custom properties an app assigns to deliver it. Empty unless `delivery` is `"webfont"`.
120
+ * @property {string} note The licensing and fallback facts, in one sentence a docs page can print.
121
+ */
122
+
123
+ /**
124
+ * Every pairing's families, delivery and licensing note, keyed by id.
125
+ *
126
+ * @type {Record<FontName, FontPairing>}
127
+ */
128
+ export const FONT_PAIRINGS = {
129
+ "system": {
130
+ "label": "System",
131
+ "sans": "Platform UI sans",
132
+ "mono": null,
133
+ "delivery": "none",
134
+ "faces": [],
135
+ "note": "SF Pro on Apple platforms, Segoe UI on Windows, Roboto on Android, whatever the desktop is set to on Linux. Zero bytes, and it resolves everywhere. Monospace is left to the theme: a preset that names one keeps it."
136
+ },
137
+ "geist": {
138
+ "label": "Geist",
139
+ "sans": "Geist",
140
+ "mono": "JetBrains Mono",
141
+ "delivery": "webfont",
142
+ "faces": [
143
+ "--cue-face-geist",
144
+ "--cue-face-jetbrains-mono"
145
+ ],
146
+ "note": "Vercel's Geist (SIL OFL 1.1) with JetBrains Mono (SIL OFL 1.1). Both are freely redistributable, so an app may self-host them."
147
+ },
148
+ "inter": {
149
+ "label": "Inter",
150
+ "sans": "Inter",
151
+ "mono": "IBM Plex Mono",
152
+ "delivery": "webfont",
153
+ "faces": [
154
+ "--cue-face-inter",
155
+ "--cue-face-ibm-plex-mono"
156
+ ],
157
+ "note": "Inter (SIL OFL 1.1) with IBM Plex Mono (SIL OFL 1.1). Both are freely redistributable, so an app may self-host them."
158
+ },
159
+ "plex": {
160
+ "label": "Plex",
161
+ "sans": "IBM Plex Sans",
162
+ "mono": "IBM Plex Mono",
163
+ "delivery": "webfont",
164
+ "faces": [
165
+ "--cue-face-ibm-plex-sans",
166
+ "--cue-face-ibm-plex-mono"
167
+ ],
168
+ "note": "IBM Plex Sans and IBM Plex Mono (both SIL OFL 1.1). Freely redistributable, so an app may self-host them."
169
+ },
170
+ "roboto": {
171
+ "label": "Roboto",
172
+ "sans": "Roboto",
173
+ "mono": "Roboto Mono",
174
+ "delivery": "webfont",
175
+ "faces": [
176
+ "--cue-face-roboto",
177
+ "--cue-face-roboto-mono"
178
+ ],
179
+ "note": "Roboto and Roboto Mono (both Apache 2.0). Freely redistributable, so an app may self-host them."
180
+ },
181
+ "source": {
182
+ "label": "Source",
183
+ "sans": "Source Sans 3",
184
+ "mono": "Source Code Pro",
185
+ "delivery": "webfont",
186
+ "faces": [
187
+ "--cue-face-source-sans-3",
188
+ "--cue-face-source-code-pro"
189
+ ],
190
+ "note": "Source Sans 3 and Source Code Pro (both SIL OFL 1.1). Freely redistributable, so an app may self-host them. \"Source Sans Pro\" is the family's former name and stays in the stack for machines that have the old install."
191
+ },
192
+ "apple": {
193
+ "label": "Apple",
194
+ "sans": "SF Pro Text",
195
+ "mono": "SF Mono",
196
+ "delivery": "system",
197
+ "faces": [],
198
+ "note": "SF Pro and SF Mono are Apple-licensed. Their licence permits use on Apple platforms and does NOT permit redistribution as a webfont, so this pairing is a stack and nothing else: it lights up on macOS and iOS and falls through to the platform sans anywhere else."
199
+ },
200
+ "office": {
201
+ "label": "Office",
202
+ "sans": "Calibri",
203
+ "mono": "Cascadia Mono",
204
+ "delivery": "system",
205
+ "faces": [],
206
+ "note": "Calibri is Microsoft-licensed and cannot be served as a webfont; Carlito is its metric-compatible libre twin (SIL OFL 1.1) and is what most Linux machines resolve this to. Cascadia Mono is MIT-licensed and Consolas is not, so the stack names both and serves neither."
207
+ }
208
+ };
209
+
210
+ /**
211
+ * Every face an app must self-host to deliver the webfont pairings, as
212
+ * `custom property -> family name`. Assign each one the family your bundler
213
+ * generated; `next/font` hashes family names, so the literal never matches.
214
+ *
215
+ * @type {Record<string, string>}
216
+ */
217
+ export const FONT_FACES = {
218
+ "--cue-face-geist": "Geist",
219
+ "--cue-face-jetbrains-mono": "JetBrains Mono",
220
+ "--cue-face-inter": "Inter",
221
+ "--cue-face-ibm-plex-mono": "IBM Plex Mono",
222
+ "--cue-face-ibm-plex-sans": "IBM Plex Sans",
223
+ "--cue-face-roboto": "Roboto",
224
+ "--cue-face-roboto-mono": "Roboto Mono",
225
+ "--cue-face-source-sans-3": "Source Sans 3",
226
+ "--cue-face-source-code-pro": "Source Code Pro"
227
+ };
228
+
229
+ /**
230
+ * The custom property that delivers one face.
231
+ * @example faceProperty("IBM Plex Mono") // "--cue-face-ibm-plex-mono"
232
+ */
233
+ export const faceProperty = (family) =>
234
+ `--cue-face-${family.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`;
235
+
236
+ /**
237
+ * Reference a semantic token as a CSS value.
238
+ * @example token("accent") // "var(--cue-accent)"
239
+ */
240
+ export const token = (name) => `var(--cue-${name})`;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@cueplusplus/tokens",
3
+ "version": "0.13.0",
4
+ "description": "DTCG design tokens for the CUE++ design system: 5 density levels and 8 font pairings, compiled to attribute-scoped CSS custom properties. Colour lives in a theme package.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/cueplusplus/cue-ui",
10
+ "directory": "packages/tokens"
11
+ },
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org",
14
+ "access": "public"
15
+ },
16
+ "sideEffects": [
17
+ "**/*.css"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/tokens.d.ts",
25
+ "default": "./dist/tokens.js"
26
+ },
27
+ "./theme.css": "./dist/theme.css",
28
+ "./tailwind.css": "./dist/tailwind.css",
29
+ "./axes.css": "./dist/axes.css",
30
+ "./base.json": "./dist/base.json",
31
+ "./primitives.tokens.json": "./dist/primitives.tokens.json",
32
+ "./registry/token-layer.json": "./dist/registry/token-layer.json"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "CHANGELOG.md"
38
+ ],
39
+ "devDependencies": {
40
+ "eslint": "^9.17.0",
41
+ "publint": "^0.3.23",
42
+ "style-dictionary": "^5.5.1",
43
+ "@repo/eslint-config": "0.0.0"
44
+ },
45
+ "scripts": {
46
+ "build": "node build.mjs",
47
+ "check:publish": "publint",
48
+ "lint": "eslint . --max-warnings 0",
49
+ "test": "node --test \"test/*.test.mjs\""
50
+ }
51
+ }