@rcooler/tokens 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roman Derevianko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ # @rcooler/tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Colour roles for light and dark as `--rc-*` custom properties bound to Bootstrap 5.3 variables
4
+ (`tokens.css`), the same values as `tokens.json`, and `followSystemColorScheme()`. No runtime
5
+ dependencies.
6
+
7
+ ```sh
8
+ npm install @rcooler/tokens
9
+ ```
10
+
11
+ ```ts
12
+ import "bootstrap/dist/css/bootstrap.min.css";
13
+ import "@rcooler/tokens/tokens.css"; // after Bootstrap
14
+ import { followSystemColorScheme } from "@rcooler/tokens";
15
+
16
+ followSystemColorScheme(); // keeps data-bs-theme in step with the system setting
17
+ ```
18
+
19
+ ESM with type declarations. Part of [web-kit](https://github.com/RCooLeR/web-kit): the
20
+ [README](https://github.com/RCooLeR/web-kit#readme) there describes every package, and the
21
+ [changelog](https://github.com/RCooLeR/web-kit/blob/main/CHANGELOG.md) lists the changes.
22
+
23
+ ## Licence
24
+
25
+ [MIT](LICENSE)
@@ -0,0 +1,19 @@
1
+ export type ColorScheme = "light" | "dark";
2
+ /** The attribute Bootstrap 5.3 reads the colour scheme from. */
3
+ export declare const SCHEME_ATTRIBUTE = "data-bs-theme";
4
+ /** The part of an element this module needs; `document.documentElement` fits. */
5
+ export interface SchemeRoot {
6
+ setAttribute(name: string, value: string): void;
7
+ }
8
+ /** The part of a MediaQueryList this module needs. */
9
+ export interface SchemeQuery {
10
+ readonly matches: boolean;
11
+ addEventListener(type: "change", listener: () => void): void;
12
+ removeEventListener(type: "change", listener: () => void): void;
13
+ }
14
+ /**
15
+ * Sets `data-bs-theme` on `root` to the system's scheme now and whenever the system changes it.
16
+ * Call it once at start, before the first paint if a flash of the wrong scheme matters.
17
+ * @returns a function that stops following; the attribute keeps its last value.
18
+ */
19
+ export declare function followSystemColorScheme(root?: SchemeRoot, query?: SchemeQuery): () => void;
@@ -0,0 +1,20 @@
1
+ // Follows the operating system's light or dark setting. Bootstrap switches on the data-bs-theme
2
+ // attribute, not on the media query, so something has to copy one to the other.
3
+ /** The attribute Bootstrap 5.3 reads the colour scheme from. */
4
+ export const SCHEME_ATTRIBUTE = "data-bs-theme";
5
+ /**
6
+ * Sets `data-bs-theme` on `root` to the system's scheme now and whenever the system changes it.
7
+ * Call it once at start, before the first paint if a flash of the wrong scheme matters.
8
+ * @returns a function that stops following; the attribute keeps its last value.
9
+ */
10
+ export function followSystemColorScheme(root = document.documentElement, query = window.matchMedia("(prefers-color-scheme: dark)")) {
11
+ const apply = () => {
12
+ const scheme = query.matches ? "dark" : "light";
13
+ root.setAttribute(SCHEME_ATTRIBUTE, scheme);
14
+ };
15
+ apply();
16
+ query.addEventListener("change", apply);
17
+ return () => {
18
+ query.removeEventListener("change", apply);
19
+ };
20
+ }
package/dist/css.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { type HexColor } from "./theme.js";
2
+ /** The prefix of the role custom properties: `--rc-accent`, `--rc-surface-raised`. */
3
+ export declare const ROLE_PREFIX = "--rc-";
4
+ /** `"#2a78d6"` to `"42, 120, 214"`, the form Bootstrap's `*-rgb` variables hold. Alpha is dropped. */
5
+ export declare function rgbTriplet(color: HexColor): string;
6
+ /**
7
+ * Returns the stylesheet. Load it after Bootstrap's own CSS. Light is the default; an element
8
+ * with `data-bs-theme="dark"` (normally `<html>`) switches itself and everything inside to dark.
9
+ * The output depends on the theme values alone, so the same version always gives the same bytes.
10
+ */
11
+ export declare function renderCss(): string;
package/dist/css.js ADDED
@@ -0,0 +1,230 @@
1
+ // Renders the theme as one stylesheet: every role as an --rc-* custom property, and the
2
+ // Bootstrap 5.3 variables bound to those roles. Pure string building, no DOM.
3
+ //
4
+ // Only Bootstrap variables that have a matching role are set; the rest keep Bootstrap's own
5
+ // values. Bootstrap compiles the colours of some components (buttons, pagination, form focus)
6
+ // into literals instead of reading --bs-primary, so those components are re-bound below.
7
+ import { base, dark, light } from "./theme.js";
8
+ /** The prefix of the role custom properties: `--rc-accent`, `--rc-surface-raised`. */
9
+ export const ROLE_PREFIX = "--rc-";
10
+ /** `"#2a78d6"` to `"42, 120, 214"`, the form Bootstrap's `*-rgb` variables hold. Alpha is dropped. */
11
+ export function rgbTriplet(color) {
12
+ const channel = (offset) => Number.parseInt(color.slice(offset, offset + 2), 16);
13
+ return `${channel(1)}, ${channel(3)}, ${channel(5)}`;
14
+ }
15
+ /** `surfaceRaised` to `surface-raised`. */
16
+ function kebab(name) {
17
+ return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
18
+ }
19
+ function roleDeclarations(scheme) {
20
+ const declarations = [];
21
+ for (const [role, value] of Object.entries(scheme.color)) {
22
+ if (typeof value === "string") {
23
+ declarations.push([`${ROLE_PREFIX}${kebab(role)}`, value]);
24
+ }
25
+ }
26
+ scheme.color.series.forEach((color, index) => {
27
+ declarations.push([`${ROLE_PREFIX}series-${index + 1}`, color]);
28
+ });
29
+ declarations.push([`${ROLE_PREFIX}shadow-card`, scheme.shadow.card]);
30
+ declarations.push([`${ROLE_PREFIX}shadow-pop`, scheme.shadow.pop]);
31
+ return declarations;
32
+ }
33
+ /** A Bootstrap colour variable together with its `-rgb` twin. */
34
+ function withRgb(variable, color) {
35
+ return [
36
+ [variable, color],
37
+ [`${variable}-rgb`, rgbTriplet(color)],
38
+ ];
39
+ }
40
+ /** One of Bootstrap's theme colours: the fill, its text form and its tinted background. */
41
+ function themeColor(name, fill, text, subtle) {
42
+ return [
43
+ ...withRgb(`--bs-${name}`, fill),
44
+ [`--bs-${name}-text-emphasis`, text],
45
+ [`--bs-${name}-bg-subtle`, subtle],
46
+ ];
47
+ }
48
+ function bootstrapDeclarations(color) {
49
+ return [
50
+ ...withRgb("--bs-body-bg", color.page),
51
+ ...withRgb("--bs-body-color", color.text),
52
+ ...withRgb("--bs-emphasis-color", color.text),
53
+ ...withRgb("--bs-secondary-color", color.textSecondary),
54
+ ...withRgb("--bs-secondary-bg", color.surfaceSunken),
55
+ ...withRgb("--bs-tertiary-color", color.textMuted),
56
+ ...withRgb("--bs-tertiary-bg", color.surface),
57
+ ["--bs-border-color", color.border],
58
+ ["--bs-border-color-translucent", color.border],
59
+ ...themeColor("primary", color.accent, color.accentText, color.accentSoft),
60
+ ["--bs-primary-border-subtle", color.trackOk],
61
+ ...themeColor("info", color.accent, color.accentText, color.noticeInfo),
62
+ ["--bs-info-border-subtle", color.trackOk],
63
+ ...themeColor("success", color.statusGood, color.statusGoodText, color.noticeGood),
64
+ ...themeColor("warning", color.statusWarning, color.statusWarningText, color.noticeWarning),
65
+ ["--bs-warning-border-subtle", color.trackWarning],
66
+ ...themeColor("danger", color.statusCritical, color.statusCriticalText, color.noticeError),
67
+ ["--bs-danger-border-subtle", color.trackCritical],
68
+ ...withRgb("--bs-link-color", color.accentText),
69
+ ...withRgb("--bs-link-hover-color", color.accentStrong),
70
+ ["--bs-focus-ring-color", `rgba(${rgbTriplet(color.accent)}, 0.25)`],
71
+ ];
72
+ }
73
+ /** Declarations that are the same in both schemes. */
74
+ function baseDeclarations() {
75
+ return [
76
+ [`${ROLE_PREFIX}radius-card`, base.radius.card],
77
+ [`${ROLE_PREFIX}radius-control`, base.radius.control],
78
+ [`${ROLE_PREFIX}gap`, base.spacing.gap],
79
+ ["--bs-border-radius", base.radius.control],
80
+ ["--bs-border-radius-lg", base.radius.card],
81
+ ["--bs-font-sans-serif", base.font.family],
82
+ ["--bs-body-font-size", base.font.size],
83
+ ["--bs-body-line-height", base.font.lineHeight],
84
+ ["--bs-box-shadow-sm", `var(${ROLE_PREFIX}shadow-card)`],
85
+ ["--bs-box-shadow", `var(${ROLE_PREFIX}shadow-pop)`],
86
+ ];
87
+ }
88
+ function block(selector, declarations) {
89
+ const lines = declarations.map(([property, value]) => ` ${property}: ${value};`);
90
+ return `${selector} {\n${lines.join("\n")}\n}\n`;
91
+ }
92
+ function schemeBlock(selector, name, scheme) {
93
+ return block(selector, [
94
+ ["color-scheme", name],
95
+ ...roleDeclarations(scheme),
96
+ ...bootstrapDeclarations(scheme.color),
97
+ ]);
98
+ }
99
+ const focusRing = [
100
+ ["border-color", "var(--rc-accent)"],
101
+ ["box-shadow", "0 0 0 0.25rem var(--bs-focus-ring-color)"],
102
+ ];
103
+ /** Components whose colours Bootstrap fixes at compile time, re-bound to the roles. */
104
+ const components = [
105
+ [
106
+ ".btn-primary",
107
+ [
108
+ ["--bs-btn-color", "var(--rc-on-accent)"],
109
+ ["--bs-btn-bg", "var(--rc-accent)"],
110
+ ["--bs-btn-border-color", "var(--rc-accent)"],
111
+ ["--bs-btn-hover-color", "var(--rc-on-accent)"],
112
+ ["--bs-btn-hover-bg", "var(--rc-accent-strong)"],
113
+ ["--bs-btn-hover-border-color", "var(--rc-accent-strong)"],
114
+ ["--bs-btn-focus-shadow-rgb", "var(--bs-primary-rgb)"],
115
+ ["--bs-btn-active-color", "var(--rc-on-accent)"],
116
+ ["--bs-btn-active-bg", "var(--rc-accent-strong)"],
117
+ ["--bs-btn-active-border-color", "var(--rc-accent-strong)"],
118
+ ["--bs-btn-disabled-color", "var(--rc-on-accent)"],
119
+ ["--bs-btn-disabled-bg", "var(--rc-accent)"],
120
+ ["--bs-btn-disabled-border-color", "var(--rc-accent)"],
121
+ ],
122
+ ],
123
+ [
124
+ ".btn-outline-primary",
125
+ [
126
+ ["--bs-btn-color", "var(--rc-accent-text)"],
127
+ ["--bs-btn-border-color", "var(--rc-accent)"],
128
+ ["--bs-btn-hover-color", "var(--rc-on-accent)"],
129
+ ["--bs-btn-hover-bg", "var(--rc-accent)"],
130
+ ["--bs-btn-hover-border-color", "var(--rc-accent)"],
131
+ ["--bs-btn-focus-shadow-rgb", "var(--bs-primary-rgb)"],
132
+ ["--bs-btn-active-color", "var(--rc-on-accent)"],
133
+ ["--bs-btn-active-bg", "var(--rc-accent)"],
134
+ ["--bs-btn-active-border-color", "var(--rc-accent)"],
135
+ ["--bs-btn-disabled-color", "var(--rc-accent-text)"],
136
+ ["--bs-btn-disabled-border-color", "var(--rc-accent)"],
137
+ ],
138
+ ],
139
+ [
140
+ ".card",
141
+ [
142
+ ["--bs-card-bg", "var(--rc-surface)"],
143
+ ["--bs-card-border-color", "var(--rc-border)"],
144
+ ["--bs-card-border-radius", "var(--rc-radius-card)"],
145
+ ["--bs-card-inner-border-radius", "calc(var(--rc-radius-card) - var(--bs-border-width))"],
146
+ ["box-shadow", "var(--rc-shadow-card)"],
147
+ ],
148
+ ],
149
+ [
150
+ ".modal",
151
+ [
152
+ ["--bs-modal-bg", "var(--rc-surface-raised)"],
153
+ ["--bs-modal-border-color", "var(--rc-border)"],
154
+ ["--bs-modal-border-radius", "var(--rc-radius-card)"],
155
+ ["--bs-modal-box-shadow", "var(--rc-shadow-pop)"],
156
+ ],
157
+ ],
158
+ [
159
+ ".modal-backdrop",
160
+ [
161
+ // The role already carries its transparency.
162
+ ["--bs-backdrop-bg", "var(--rc-backdrop)"],
163
+ ["--bs-backdrop-opacity", "1"],
164
+ ],
165
+ ],
166
+ [
167
+ ".dropdown-menu",
168
+ [
169
+ ["--bs-dropdown-bg", "var(--rc-surface-raised)"],
170
+ ["--bs-dropdown-border-color", "var(--rc-border)"],
171
+ ["--bs-dropdown-link-active-color", "var(--rc-on-accent)"],
172
+ ["--bs-dropdown-link-active-bg", "var(--rc-accent)"],
173
+ ],
174
+ ],
175
+ [
176
+ ".nav-pills",
177
+ [
178
+ ["--bs-nav-pills-link-active-color", "var(--rc-on-accent)"],
179
+ ["--bs-nav-pills-link-active-bg", "var(--rc-accent)"],
180
+ ],
181
+ ],
182
+ [
183
+ ".list-group",
184
+ [
185
+ ["--bs-list-group-bg", "var(--rc-surface)"],
186
+ ["--bs-list-group-border-color", "var(--rc-border)"],
187
+ ["--bs-list-group-active-color", "var(--rc-on-accent)"],
188
+ ["--bs-list-group-active-bg", "var(--rc-accent)"],
189
+ ["--bs-list-group-active-border-color", "var(--rc-accent)"],
190
+ ],
191
+ ],
192
+ [
193
+ ".pagination",
194
+ [
195
+ ["--bs-pagination-active-color", "var(--rc-on-accent)"],
196
+ ["--bs-pagination-active-bg", "var(--rc-accent)"],
197
+ ["--bs-pagination-active-border-color", "var(--rc-accent)"],
198
+ ],
199
+ ],
200
+ [
201
+ ".progress,\n.progress-stacked",
202
+ [
203
+ ["--bs-progress-bg", "var(--rc-track-ok)"],
204
+ ["--bs-progress-bar-color", "var(--rc-on-accent)"],
205
+ ["--bs-progress-bar-bg", "var(--rc-accent)"],
206
+ ],
207
+ ],
208
+ [".form-control:focus,\n.form-select:focus,\n.form-check-input:focus", focusRing],
209
+ [
210
+ ".form-check-input:checked",
211
+ [
212
+ ["background-color", "var(--rc-accent)"],
213
+ ["border-color", "var(--rc-accent)"],
214
+ ],
215
+ ],
216
+ ];
217
+ /**
218
+ * Returns the stylesheet. Load it after Bootstrap's own CSS. Light is the default; an element
219
+ * with `data-bs-theme="dark"` (normally `<html>`) switches itself and everything inside to dark.
220
+ * The output depends on the theme values alone, so the same version always gives the same bytes.
221
+ */
222
+ export function renderCss() {
223
+ return [
224
+ "/* Generated by @rcooler/tokens from src/theme.ts. Do not edit. */\n",
225
+ schemeBlock(':root,\n[data-bs-theme="light"]', "light", light),
226
+ schemeBlock('[data-bs-theme="dark"]', "dark", dark),
227
+ block(":root", baseDeclarations()),
228
+ ...components.map(([selector, declarations]) => block(selector, declarations)),
229
+ ].join("\n");
230
+ }
@@ -0,0 +1,5 @@
1
+ export { base, dark, light, tokens } from "./theme.js";
2
+ export type { ColorRoles, HexColor, Scheme } from "./theme.js";
3
+ export { renderCss, rgbTriplet, ROLE_PREFIX } from "./css.js";
4
+ export { followSystemColorScheme, SCHEME_ATTRIBUTE } from "./color-scheme.js";
5
+ export type { ColorScheme, SchemeQuery, SchemeRoot } from "./color-scheme.js";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // @rcooler/tokens: the shared theme. Import the stylesheet with
2
+ // `import "@rcooler/tokens/tokens.css"` after Bootstrap's CSS; this module gives the same values
3
+ // to code (charts, canvas) and the helper that follows the system's colour scheme.
4
+ export { base, dark, light, tokens } from "./theme.js";
5
+ export { renderCss, rgbTriplet, ROLE_PREFIX } from "./css.js";
6
+ export { followSystemColorScheme, SCHEME_ATTRIBUTE } from "./color-scheme.js";
@@ -0,0 +1,102 @@
1
+ /** A colour as `#rrggbb` or, when translucent, `#rrggbbaa`: valid CSS and easy to turn into ARGB. */
2
+ export type HexColor = `#${string}`;
3
+ /** The colour roles of one scheme. */
4
+ export interface ColorRoles {
5
+ /** Page background behind everything. */
6
+ page: HexColor;
7
+ /** Background of cards and panels. */
8
+ surface: HexColor;
9
+ /** Background of what floats above a surface: dialogs, menus. */
10
+ surfaceRaised: HexColor;
11
+ /** Background of wells, table headers and inactive tracks. */
12
+ surfaceSunken: HexColor;
13
+ text: HexColor;
14
+ textSecondary: HexColor;
15
+ textMuted: HexColor;
16
+ border: HexColor;
17
+ borderStrong: HexColor;
18
+ /** Chart grid lines and axes. */
19
+ grid: HexColor;
20
+ axis: HexColor;
21
+ /** The brand colour: primary buttons, active navigation, focus. */
22
+ accent: HexColor;
23
+ /** Hover and pressed state of an accent surface. */
24
+ accentStrong: HexColor;
25
+ /** Accent as text on a surface: links. */
26
+ accentText: HexColor;
27
+ /** A tinted background for accent-related notices and selections. */
28
+ accentSoft: HexColor;
29
+ /** Text and icons on an accent surface. */
30
+ onAccent: HexColor;
31
+ /** Chart series in the order to use them; `seriesOther` is the remainder bucket. */
32
+ series: readonly [HexColor, HexColor, HexColor, HexColor, HexColor, HexColor, HexColor, HexColor];
33
+ seriesOther: HexColor;
34
+ /** Status as a fill (dots, bars) and as text on a surface. */
35
+ statusGood: HexColor;
36
+ statusGoodText: HexColor;
37
+ statusWarning: HexColor;
38
+ statusWarningText: HexColor;
39
+ statusCritical: HexColor;
40
+ statusCriticalText: HexColor;
41
+ /** Unfilled part of a progress track, by state. */
42
+ trackOk: HexColor;
43
+ trackWarning: HexColor;
44
+ trackCritical: HexColor;
45
+ /** Background of an inline notice, by kind. */
46
+ noticeError: HexColor;
47
+ noticeWarning: HexColor;
48
+ noticeInfo: HexColor;
49
+ noticeGood: HexColor;
50
+ /** The dimmed layer behind a dialog. */
51
+ backdrop: HexColor;
52
+ }
53
+ /** One colour scheme: its colours and the shadows that go with them. */
54
+ export interface Scheme {
55
+ color: ColorRoles;
56
+ shadow: {
57
+ /** Resting cards. */
58
+ card: string;
59
+ /** Dialogs and menus. */
60
+ pop: string;
61
+ };
62
+ }
63
+ export declare const light: Scheme;
64
+ export declare const dark: Scheme;
65
+ /** Values that do not change with the colour scheme. */
66
+ export declare const base: {
67
+ readonly radius: {
68
+ /** Cards, dialogs. */
69
+ readonly card: "16px";
70
+ /** Buttons, inputs. */
71
+ readonly control: "10px";
72
+ };
73
+ readonly spacing: {
74
+ /** The gap between cards and between form rows. */
75
+ readonly gap: "16px";
76
+ };
77
+ readonly font: {
78
+ readonly family: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
79
+ readonly size: "16px";
80
+ readonly lineHeight: "1.45";
81
+ };
82
+ };
83
+ /** Everything the theme defines; this object is the JSON export. */
84
+ export declare const tokens: {
85
+ readonly radius: {
86
+ /** Cards, dialogs. */
87
+ readonly card: "16px";
88
+ /** Buttons, inputs. */
89
+ readonly control: "10px";
90
+ };
91
+ readonly spacing: {
92
+ /** The gap between cards and between form rows. */
93
+ readonly gap: "16px";
94
+ };
95
+ readonly font: {
96
+ readonly family: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
97
+ readonly size: "16px";
98
+ readonly lineHeight: "1.45";
99
+ };
100
+ readonly light: Scheme;
101
+ readonly dark: Scheme;
102
+ };
package/dist/theme.js ADDED
@@ -0,0 +1,125 @@
1
+ // The theme values: colour roles for light and dark, shadows, radii, spacing and the font. This
2
+ // file is the single source; the CSS and the JSON export are generated from it.
3
+ //
4
+ // The colours are a validated set (colour-blind separation of the series, contrast of text and
5
+ // status colours against `surface` in both schemes). Change a series, a status colour or
6
+ // `surface` only together with the others, and validate again. Native apps read the same roles
7
+ // from the JSON export.
8
+ export const light = {
9
+ color: {
10
+ page: "#f1f3f8",
11
+ surface: "#fcfcfb",
12
+ surfaceRaised: "#ffffff",
13
+ surfaceSunken: "#e9ecf3",
14
+ text: "#0f1420",
15
+ textSecondary: "#474c59",
16
+ textMuted: "#5f6675",
17
+ border: "#0f142017",
18
+ borderStrong: "#0f142033",
19
+ grid: "#e1e0d9",
20
+ axis: "#c3c2b7",
21
+ accent: "#2a78d6",
22
+ accentStrong: "#1c5cab",
23
+ accentText: "#1c5cab",
24
+ accentSoft: "#e3eefc",
25
+ onAccent: "#ffffff",
26
+ series: [
27
+ "#2a78d6",
28
+ "#eb6834",
29
+ "#1baf7a",
30
+ "#eda100",
31
+ "#e87ba4",
32
+ "#008300",
33
+ "#6250d6",
34
+ "#e34948",
35
+ ],
36
+ seriesOther: "#898781",
37
+ statusGood: "#0ca30c",
38
+ statusGoodText: "#006300",
39
+ statusWarning: "#fab219",
40
+ statusWarningText: "#7a5200",
41
+ statusCritical: "#d03b3b",
42
+ statusCriticalText: "#a82525",
43
+ trackOk: "#cde2fb",
44
+ trackWarning: "#fdeccb",
45
+ trackCritical: "#f6d5d5",
46
+ noticeError: "#fbe9e9",
47
+ noticeWarning: "#fdf3dc",
48
+ noticeInfo: "#e6f0fd",
49
+ noticeGood: "#e3f4e3",
50
+ backdrop: "#090d1680",
51
+ },
52
+ shadow: {
53
+ card: "0 1px 2px rgba(15, 20, 32, 0.04), 0 2px 10px rgba(15, 20, 32, 0.04)",
54
+ pop: "0 12px 32px rgba(15, 20, 32, 0.18)",
55
+ },
56
+ };
57
+ export const dark = {
58
+ color: {
59
+ page: "#0d0e11",
60
+ surface: "#1a1a19",
61
+ surfaceRaised: "#232322",
62
+ surfaceSunken: "#27282b",
63
+ text: "#f0efec",
64
+ textSecondary: "#c3c2b7",
65
+ textMuted: "#a3a199",
66
+ border: "#ffffff1a",
67
+ borderStrong: "#ffffff3d",
68
+ grid: "#2c2c2a",
69
+ axis: "#383835",
70
+ accent: "#3987e5",
71
+ accentStrong: "#5a9cec",
72
+ accentText: "#86b6ef",
73
+ accentSoft: "#12294a",
74
+ onAccent: "#ffffff",
75
+ series: [
76
+ "#3987e5",
77
+ "#d95926",
78
+ "#199e70",
79
+ "#c98500",
80
+ "#d55181",
81
+ "#0ca30c",
82
+ "#9085e9",
83
+ "#e66767",
84
+ ],
85
+ seriesOther: "#898781",
86
+ statusGood: "#0ca30c",
87
+ statusGoodText: "#4fc24f",
88
+ statusWarning: "#fab219",
89
+ statusWarningText: "#f3c35b",
90
+ statusCritical: "#d03b3b",
91
+ statusCriticalText: "#ee8a8a",
92
+ trackOk: "#0d366b",
93
+ trackWarning: "#4a3a10",
94
+ trackCritical: "#4a1a1a",
95
+ noticeError: "#3a1717",
96
+ noticeWarning: "#3a2f10",
97
+ noticeInfo: "#12294a",
98
+ noticeGood: "#123312",
99
+ backdrop: "#00000099",
100
+ },
101
+ shadow: {
102
+ card: "none",
103
+ pop: "0 12px 32px rgba(0, 0, 0, 0.5)",
104
+ },
105
+ };
106
+ /** Values that do not change with the colour scheme. */
107
+ export const base = {
108
+ radius: {
109
+ /** Cards, dialogs. */
110
+ card: "16px",
111
+ /** Buttons, inputs. */
112
+ control: "10px",
113
+ },
114
+ spacing: {
115
+ /** The gap between cards and between form rows. */
116
+ gap: "16px",
117
+ },
118
+ font: {
119
+ family: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
120
+ size: "16px",
121
+ lineHeight: "1.45",
122
+ },
123
+ };
124
+ /** Everything the theme defines; this object is the JSON export. */
125
+ export const tokens = { light, dark, ...base };
@@ -0,0 +1,290 @@
1
+ /* Generated by @rcooler/tokens from src/theme.ts. Do not edit. */
2
+
3
+ :root,
4
+ [data-bs-theme="light"] {
5
+ color-scheme: light;
6
+ --rc-page: #f1f3f8;
7
+ --rc-surface: #fcfcfb;
8
+ --rc-surface-raised: #ffffff;
9
+ --rc-surface-sunken: #e9ecf3;
10
+ --rc-text: #0f1420;
11
+ --rc-text-secondary: #474c59;
12
+ --rc-text-muted: #5f6675;
13
+ --rc-border: #0f142017;
14
+ --rc-border-strong: #0f142033;
15
+ --rc-grid: #e1e0d9;
16
+ --rc-axis: #c3c2b7;
17
+ --rc-accent: #2a78d6;
18
+ --rc-accent-strong: #1c5cab;
19
+ --rc-accent-text: #1c5cab;
20
+ --rc-accent-soft: #e3eefc;
21
+ --rc-on-accent: #ffffff;
22
+ --rc-series-other: #898781;
23
+ --rc-status-good: #0ca30c;
24
+ --rc-status-good-text: #006300;
25
+ --rc-status-warning: #fab219;
26
+ --rc-status-warning-text: #7a5200;
27
+ --rc-status-critical: #d03b3b;
28
+ --rc-status-critical-text: #a82525;
29
+ --rc-track-ok: #cde2fb;
30
+ --rc-track-warning: #fdeccb;
31
+ --rc-track-critical: #f6d5d5;
32
+ --rc-notice-error: #fbe9e9;
33
+ --rc-notice-warning: #fdf3dc;
34
+ --rc-notice-info: #e6f0fd;
35
+ --rc-notice-good: #e3f4e3;
36
+ --rc-backdrop: #090d1680;
37
+ --rc-series-1: #2a78d6;
38
+ --rc-series-2: #eb6834;
39
+ --rc-series-3: #1baf7a;
40
+ --rc-series-4: #eda100;
41
+ --rc-series-5: #e87ba4;
42
+ --rc-series-6: #008300;
43
+ --rc-series-7: #6250d6;
44
+ --rc-series-8: #e34948;
45
+ --rc-shadow-card: 0 1px 2px rgba(15, 20, 32, 0.04), 0 2px 10px rgba(15, 20, 32, 0.04);
46
+ --rc-shadow-pop: 0 12px 32px rgba(15, 20, 32, 0.18);
47
+ --bs-body-bg: #f1f3f8;
48
+ --bs-body-bg-rgb: 241, 243, 248;
49
+ --bs-body-color: #0f1420;
50
+ --bs-body-color-rgb: 15, 20, 32;
51
+ --bs-emphasis-color: #0f1420;
52
+ --bs-emphasis-color-rgb: 15, 20, 32;
53
+ --bs-secondary-color: #474c59;
54
+ --bs-secondary-color-rgb: 71, 76, 89;
55
+ --bs-secondary-bg: #e9ecf3;
56
+ --bs-secondary-bg-rgb: 233, 236, 243;
57
+ --bs-tertiary-color: #5f6675;
58
+ --bs-tertiary-color-rgb: 95, 102, 117;
59
+ --bs-tertiary-bg: #fcfcfb;
60
+ --bs-tertiary-bg-rgb: 252, 252, 251;
61
+ --bs-border-color: #0f142017;
62
+ --bs-border-color-translucent: #0f142017;
63
+ --bs-primary: #2a78d6;
64
+ --bs-primary-rgb: 42, 120, 214;
65
+ --bs-primary-text-emphasis: #1c5cab;
66
+ --bs-primary-bg-subtle: #e3eefc;
67
+ --bs-primary-border-subtle: #cde2fb;
68
+ --bs-info: #2a78d6;
69
+ --bs-info-rgb: 42, 120, 214;
70
+ --bs-info-text-emphasis: #1c5cab;
71
+ --bs-info-bg-subtle: #e6f0fd;
72
+ --bs-info-border-subtle: #cde2fb;
73
+ --bs-success: #0ca30c;
74
+ --bs-success-rgb: 12, 163, 12;
75
+ --bs-success-text-emphasis: #006300;
76
+ --bs-success-bg-subtle: #e3f4e3;
77
+ --bs-warning: #fab219;
78
+ --bs-warning-rgb: 250, 178, 25;
79
+ --bs-warning-text-emphasis: #7a5200;
80
+ --bs-warning-bg-subtle: #fdf3dc;
81
+ --bs-warning-border-subtle: #fdeccb;
82
+ --bs-danger: #d03b3b;
83
+ --bs-danger-rgb: 208, 59, 59;
84
+ --bs-danger-text-emphasis: #a82525;
85
+ --bs-danger-bg-subtle: #fbe9e9;
86
+ --bs-danger-border-subtle: #f6d5d5;
87
+ --bs-link-color: #1c5cab;
88
+ --bs-link-color-rgb: 28, 92, 171;
89
+ --bs-link-hover-color: #1c5cab;
90
+ --bs-link-hover-color-rgb: 28, 92, 171;
91
+ --bs-focus-ring-color: rgba(42, 120, 214, 0.25);
92
+ }
93
+
94
+ [data-bs-theme="dark"] {
95
+ color-scheme: dark;
96
+ --rc-page: #0d0e11;
97
+ --rc-surface: #1a1a19;
98
+ --rc-surface-raised: #232322;
99
+ --rc-surface-sunken: #27282b;
100
+ --rc-text: #f0efec;
101
+ --rc-text-secondary: #c3c2b7;
102
+ --rc-text-muted: #a3a199;
103
+ --rc-border: #ffffff1a;
104
+ --rc-border-strong: #ffffff3d;
105
+ --rc-grid: #2c2c2a;
106
+ --rc-axis: #383835;
107
+ --rc-accent: #3987e5;
108
+ --rc-accent-strong: #5a9cec;
109
+ --rc-accent-text: #86b6ef;
110
+ --rc-accent-soft: #12294a;
111
+ --rc-on-accent: #ffffff;
112
+ --rc-series-other: #898781;
113
+ --rc-status-good: #0ca30c;
114
+ --rc-status-good-text: #4fc24f;
115
+ --rc-status-warning: #fab219;
116
+ --rc-status-warning-text: #f3c35b;
117
+ --rc-status-critical: #d03b3b;
118
+ --rc-status-critical-text: #ee8a8a;
119
+ --rc-track-ok: #0d366b;
120
+ --rc-track-warning: #4a3a10;
121
+ --rc-track-critical: #4a1a1a;
122
+ --rc-notice-error: #3a1717;
123
+ --rc-notice-warning: #3a2f10;
124
+ --rc-notice-info: #12294a;
125
+ --rc-notice-good: #123312;
126
+ --rc-backdrop: #00000099;
127
+ --rc-series-1: #3987e5;
128
+ --rc-series-2: #d95926;
129
+ --rc-series-3: #199e70;
130
+ --rc-series-4: #c98500;
131
+ --rc-series-5: #d55181;
132
+ --rc-series-6: #0ca30c;
133
+ --rc-series-7: #9085e9;
134
+ --rc-series-8: #e66767;
135
+ --rc-shadow-card: none;
136
+ --rc-shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
137
+ --bs-body-bg: #0d0e11;
138
+ --bs-body-bg-rgb: 13, 14, 17;
139
+ --bs-body-color: #f0efec;
140
+ --bs-body-color-rgb: 240, 239, 236;
141
+ --bs-emphasis-color: #f0efec;
142
+ --bs-emphasis-color-rgb: 240, 239, 236;
143
+ --bs-secondary-color: #c3c2b7;
144
+ --bs-secondary-color-rgb: 195, 194, 183;
145
+ --bs-secondary-bg: #27282b;
146
+ --bs-secondary-bg-rgb: 39, 40, 43;
147
+ --bs-tertiary-color: #a3a199;
148
+ --bs-tertiary-color-rgb: 163, 161, 153;
149
+ --bs-tertiary-bg: #1a1a19;
150
+ --bs-tertiary-bg-rgb: 26, 26, 25;
151
+ --bs-border-color: #ffffff1a;
152
+ --bs-border-color-translucent: #ffffff1a;
153
+ --bs-primary: #3987e5;
154
+ --bs-primary-rgb: 57, 135, 229;
155
+ --bs-primary-text-emphasis: #86b6ef;
156
+ --bs-primary-bg-subtle: #12294a;
157
+ --bs-primary-border-subtle: #0d366b;
158
+ --bs-info: #3987e5;
159
+ --bs-info-rgb: 57, 135, 229;
160
+ --bs-info-text-emphasis: #86b6ef;
161
+ --bs-info-bg-subtle: #12294a;
162
+ --bs-info-border-subtle: #0d366b;
163
+ --bs-success: #0ca30c;
164
+ --bs-success-rgb: 12, 163, 12;
165
+ --bs-success-text-emphasis: #4fc24f;
166
+ --bs-success-bg-subtle: #123312;
167
+ --bs-warning: #fab219;
168
+ --bs-warning-rgb: 250, 178, 25;
169
+ --bs-warning-text-emphasis: #f3c35b;
170
+ --bs-warning-bg-subtle: #3a2f10;
171
+ --bs-warning-border-subtle: #4a3a10;
172
+ --bs-danger: #d03b3b;
173
+ --bs-danger-rgb: 208, 59, 59;
174
+ --bs-danger-text-emphasis: #ee8a8a;
175
+ --bs-danger-bg-subtle: #3a1717;
176
+ --bs-danger-border-subtle: #4a1a1a;
177
+ --bs-link-color: #86b6ef;
178
+ --bs-link-color-rgb: 134, 182, 239;
179
+ --bs-link-hover-color: #5a9cec;
180
+ --bs-link-hover-color-rgb: 90, 156, 236;
181
+ --bs-focus-ring-color: rgba(57, 135, 229, 0.25);
182
+ }
183
+
184
+ :root {
185
+ --rc-radius-card: 16px;
186
+ --rc-radius-control: 10px;
187
+ --rc-gap: 16px;
188
+ --bs-border-radius: 10px;
189
+ --bs-border-radius-lg: 16px;
190
+ --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
191
+ --bs-body-font-size: 16px;
192
+ --bs-body-line-height: 1.45;
193
+ --bs-box-shadow-sm: var(--rc-shadow-card);
194
+ --bs-box-shadow: var(--rc-shadow-pop);
195
+ }
196
+
197
+ .btn-primary {
198
+ --bs-btn-color: var(--rc-on-accent);
199
+ --bs-btn-bg: var(--rc-accent);
200
+ --bs-btn-border-color: var(--rc-accent);
201
+ --bs-btn-hover-color: var(--rc-on-accent);
202
+ --bs-btn-hover-bg: var(--rc-accent-strong);
203
+ --bs-btn-hover-border-color: var(--rc-accent-strong);
204
+ --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
205
+ --bs-btn-active-color: var(--rc-on-accent);
206
+ --bs-btn-active-bg: var(--rc-accent-strong);
207
+ --bs-btn-active-border-color: var(--rc-accent-strong);
208
+ --bs-btn-disabled-color: var(--rc-on-accent);
209
+ --bs-btn-disabled-bg: var(--rc-accent);
210
+ --bs-btn-disabled-border-color: var(--rc-accent);
211
+ }
212
+
213
+ .btn-outline-primary {
214
+ --bs-btn-color: var(--rc-accent-text);
215
+ --bs-btn-border-color: var(--rc-accent);
216
+ --bs-btn-hover-color: var(--rc-on-accent);
217
+ --bs-btn-hover-bg: var(--rc-accent);
218
+ --bs-btn-hover-border-color: var(--rc-accent);
219
+ --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
220
+ --bs-btn-active-color: var(--rc-on-accent);
221
+ --bs-btn-active-bg: var(--rc-accent);
222
+ --bs-btn-active-border-color: var(--rc-accent);
223
+ --bs-btn-disabled-color: var(--rc-accent-text);
224
+ --bs-btn-disabled-border-color: var(--rc-accent);
225
+ }
226
+
227
+ .card {
228
+ --bs-card-bg: var(--rc-surface);
229
+ --bs-card-border-color: var(--rc-border);
230
+ --bs-card-border-radius: var(--rc-radius-card);
231
+ --bs-card-inner-border-radius: calc(var(--rc-radius-card) - var(--bs-border-width));
232
+ box-shadow: var(--rc-shadow-card);
233
+ }
234
+
235
+ .modal {
236
+ --bs-modal-bg: var(--rc-surface-raised);
237
+ --bs-modal-border-color: var(--rc-border);
238
+ --bs-modal-border-radius: var(--rc-radius-card);
239
+ --bs-modal-box-shadow: var(--rc-shadow-pop);
240
+ }
241
+
242
+ .modal-backdrop {
243
+ --bs-backdrop-bg: var(--rc-backdrop);
244
+ --bs-backdrop-opacity: 1;
245
+ }
246
+
247
+ .dropdown-menu {
248
+ --bs-dropdown-bg: var(--rc-surface-raised);
249
+ --bs-dropdown-border-color: var(--rc-border);
250
+ --bs-dropdown-link-active-color: var(--rc-on-accent);
251
+ --bs-dropdown-link-active-bg: var(--rc-accent);
252
+ }
253
+
254
+ .nav-pills {
255
+ --bs-nav-pills-link-active-color: var(--rc-on-accent);
256
+ --bs-nav-pills-link-active-bg: var(--rc-accent);
257
+ }
258
+
259
+ .list-group {
260
+ --bs-list-group-bg: var(--rc-surface);
261
+ --bs-list-group-border-color: var(--rc-border);
262
+ --bs-list-group-active-color: var(--rc-on-accent);
263
+ --bs-list-group-active-bg: var(--rc-accent);
264
+ --bs-list-group-active-border-color: var(--rc-accent);
265
+ }
266
+
267
+ .pagination {
268
+ --bs-pagination-active-color: var(--rc-on-accent);
269
+ --bs-pagination-active-bg: var(--rc-accent);
270
+ --bs-pagination-active-border-color: var(--rc-accent);
271
+ }
272
+
273
+ .progress,
274
+ .progress-stacked {
275
+ --bs-progress-bg: var(--rc-track-ok);
276
+ --bs-progress-bar-color: var(--rc-on-accent);
277
+ --bs-progress-bar-bg: var(--rc-accent);
278
+ }
279
+
280
+ .form-control:focus,
281
+ .form-select:focus,
282
+ .form-check-input:focus {
283
+ border-color: var(--rc-accent);
284
+ box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
285
+ }
286
+
287
+ .form-check-input:checked {
288
+ background-color: var(--rc-accent);
289
+ border-color: var(--rc-accent);
290
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "light": {
3
+ "color": {
4
+ "page": "#f1f3f8",
5
+ "surface": "#fcfcfb",
6
+ "surfaceRaised": "#ffffff",
7
+ "surfaceSunken": "#e9ecf3",
8
+ "text": "#0f1420",
9
+ "textSecondary": "#474c59",
10
+ "textMuted": "#5f6675",
11
+ "border": "#0f142017",
12
+ "borderStrong": "#0f142033",
13
+ "grid": "#e1e0d9",
14
+ "axis": "#c3c2b7",
15
+ "accent": "#2a78d6",
16
+ "accentStrong": "#1c5cab",
17
+ "accentText": "#1c5cab",
18
+ "accentSoft": "#e3eefc",
19
+ "onAccent": "#ffffff",
20
+ "series": [
21
+ "#2a78d6",
22
+ "#eb6834",
23
+ "#1baf7a",
24
+ "#eda100",
25
+ "#e87ba4",
26
+ "#008300",
27
+ "#6250d6",
28
+ "#e34948"
29
+ ],
30
+ "seriesOther": "#898781",
31
+ "statusGood": "#0ca30c",
32
+ "statusGoodText": "#006300",
33
+ "statusWarning": "#fab219",
34
+ "statusWarningText": "#7a5200",
35
+ "statusCritical": "#d03b3b",
36
+ "statusCriticalText": "#a82525",
37
+ "trackOk": "#cde2fb",
38
+ "trackWarning": "#fdeccb",
39
+ "trackCritical": "#f6d5d5",
40
+ "noticeError": "#fbe9e9",
41
+ "noticeWarning": "#fdf3dc",
42
+ "noticeInfo": "#e6f0fd",
43
+ "noticeGood": "#e3f4e3",
44
+ "backdrop": "#090d1680"
45
+ },
46
+ "shadow": {
47
+ "card": "0 1px 2px rgba(15, 20, 32, 0.04), 0 2px 10px rgba(15, 20, 32, 0.04)",
48
+ "pop": "0 12px 32px rgba(15, 20, 32, 0.18)"
49
+ }
50
+ },
51
+ "dark": {
52
+ "color": {
53
+ "page": "#0d0e11",
54
+ "surface": "#1a1a19",
55
+ "surfaceRaised": "#232322",
56
+ "surfaceSunken": "#27282b",
57
+ "text": "#f0efec",
58
+ "textSecondary": "#c3c2b7",
59
+ "textMuted": "#a3a199",
60
+ "border": "#ffffff1a",
61
+ "borderStrong": "#ffffff3d",
62
+ "grid": "#2c2c2a",
63
+ "axis": "#383835",
64
+ "accent": "#3987e5",
65
+ "accentStrong": "#5a9cec",
66
+ "accentText": "#86b6ef",
67
+ "accentSoft": "#12294a",
68
+ "onAccent": "#ffffff",
69
+ "series": [
70
+ "#3987e5",
71
+ "#d95926",
72
+ "#199e70",
73
+ "#c98500",
74
+ "#d55181",
75
+ "#0ca30c",
76
+ "#9085e9",
77
+ "#e66767"
78
+ ],
79
+ "seriesOther": "#898781",
80
+ "statusGood": "#0ca30c",
81
+ "statusGoodText": "#4fc24f",
82
+ "statusWarning": "#fab219",
83
+ "statusWarningText": "#f3c35b",
84
+ "statusCritical": "#d03b3b",
85
+ "statusCriticalText": "#ee8a8a",
86
+ "trackOk": "#0d366b",
87
+ "trackWarning": "#4a3a10",
88
+ "trackCritical": "#4a1a1a",
89
+ "noticeError": "#3a1717",
90
+ "noticeWarning": "#3a2f10",
91
+ "noticeInfo": "#12294a",
92
+ "noticeGood": "#123312",
93
+ "backdrop": "#00000099"
94
+ },
95
+ "shadow": {
96
+ "card": "none",
97
+ "pop": "0 12px 32px rgba(0, 0, 0, 0.5)"
98
+ }
99
+ },
100
+ "radius": {
101
+ "card": "16px",
102
+ "control": "10px"
103
+ },
104
+ "spacing": {
105
+ "gap": "16px"
106
+ },
107
+ "font": {
108
+ "family": "system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif",
109
+ "size": "16px",
110
+ "lineHeight": "1.45"
111
+ }
112
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@rcooler/tokens",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "A theme as Bootstrap 5 variable overrides, light and dark, with a JSON export.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "*.css"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "@rcooler/source": "./src/index.ts",
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./tokens.css": "./dist/tokens.css",
17
+ "./tokens.json": "./dist/tokens.json"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "engines": {
23
+ "node": ">=24"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/RCooLeR/web-kit.git",
28
+ "directory": "packages/tokens"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org"
33
+ },
34
+ "scripts": {
35
+ "build": "node ../../node_modules/@typescript/native/bin/tsc -p tsconfig.build.json && node scripts/write-assets.mjs",
36
+ "typecheck": "node ../../node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.json"
37
+ }
38
+ }