@stealthscale/plugin-theming 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/accessibility-Dg5Dh35o.js +409 -0
- package/dist/attributes-vx1W0PiK.js +26 -0
- package/dist/breakpoints-CJjhy79u.js +83 -0
- package/dist/code-DcoH6hCX.js +69 -0
- package/dist/conditions-CjjQwqro.js +338 -0
- package/dist/corners-CH5jyCks.js +92 -0
- package/dist/cursors-hl00ix41.js +54 -0
- package/dist/cyclonedx/bom.json +1 -0
- package/dist/density-DEW_j0I5.js +207 -0
- package/dist/depth-DCn3mAAJ.js +143 -0
- package/dist/doc-page-BQXdbP_h.js +439 -0
- package/dist/extending-CY7ry7Y4.js +31 -0
- package/dist/faces-D76c_Ryh.js +65 -0
- package/dist/gate-CoX2Yr9x.js +199 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +39 -0
- package/dist/layers-BxdWdfPg.js +53 -0
- package/dist/looks-BrROho5Y.js +107 -0
- package/dist/measure-uwF7Fmpy.js +137 -0
- package/dist/mode-colors-Cf_ZPo3g.js +260 -0
- package/dist/mode-panels-Bmh0ec0U.js +54 -0
- package/dist/motion-DRbsuZZo.js +202 -0
- package/dist/overview-BbE82N2c.js +192 -0
- package/dist/palettes-CZo2HrNT.js +49 -0
- package/dist/parts-BVmqVMgo.js +25 -0
- package/dist/recipes-C88xVIGB.js +32 -0
- package/dist/rows-Dv8c7jye.js +18 -0
- package/dist/sampler-Ue67PX2n.js +27 -0
- package/dist/series-AvSZjk2b.js +63 -0
- package/dist/setting-BsgJKTlh.js +12 -0
- package/dist/sizes-B7LgvyBS.js +98 -0
- package/dist/spacing-DMyyV6vX.js +75 -0
- package/dist/surfaces-Db0HjMwB.js +76 -0
- package/dist/text-styles-BZnXaigP.js +233 -0
- package/dist/theme.d.ts +12 -0
- package/dist/theme.js +23 -0
- package/dist/themes-yClyRA9e.js +305 -0
- package/dist/theming-text.recipe-Dvcza4j1.js +308 -0
- package/dist/token-table-yrZh5kLy.js +182 -0
- package/dist/tokens-7Pm-eLiZ.js +138 -0
- package/dist/use-readings-D56mNtEc.js +77 -0
- package/dist/variables-ymFs3Bzn.js +43 -0
- package/dist/worn-D4HEJsJ2.js +15 -0
- package/dist/writing-b05oSPB2.js +31 -0
- package/package.json +124 -3
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { a as pixelsOf, c as tidyNumbers } from "./measure-uwF7Fmpy.js";
|
|
2
|
+
import { n as useWords } from "./doc-page-BQXdbP_h.js";
|
|
3
|
+
import { t as useReadings } from "./use-readings-D56mNtEc.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { Table } from "@stealthscale/component-collections";
|
|
7
|
+
import { Code } from "@stealthscale/component-typography";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/blocks/token-table.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Renders a table of tokens: each token's name, an optional sample, its value as the stylesheet
|
|
12
|
+
* resolves it, and the pixels a length comes to.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Returns the words a value cell writes: nothing before the token is read, the value, or the word
|
|
16
|
+
* for a token the stylesheet does not declare.
|
|
17
|
+
*/
|
|
18
|
+
function written(reading, missing) {
|
|
19
|
+
if (reading === void 0) return "";
|
|
20
|
+
return reading.value === "" ? missing : tidyNumbers(reading.value);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a row's name cell: the token's name in code.
|
|
24
|
+
*/
|
|
25
|
+
function nameCell({ name }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(Code, { children: name });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders the table, reading every token inside the table's viewport.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* The sample column renders where a row states a sample, and the pixels column where the tokens
|
|
33
|
+
* are lengths. A table inside a mode panel reads that panel's mode.
|
|
34
|
+
*/
|
|
35
|
+
function TokenTable(t0) {
|
|
36
|
+
const $ = c(36);
|
|
37
|
+
const { caption, lengths: t1, rows } = t0;
|
|
38
|
+
const lengths = t1 === void 0 ? false : t1;
|
|
39
|
+
const { t } = useWords();
|
|
40
|
+
const [box, setBox] = useState(null);
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[0] !== rows) {
|
|
43
|
+
t2 = rows.map(_temp);
|
|
44
|
+
$[0] = rows;
|
|
45
|
+
$[1] = t2;
|
|
46
|
+
} else t2 = $[1];
|
|
47
|
+
const readings = useReadings(box, t2);
|
|
48
|
+
let t3;
|
|
49
|
+
if ($[2] !== rows) {
|
|
50
|
+
t3 = rows.some(_temp2);
|
|
51
|
+
$[2] = rows;
|
|
52
|
+
$[3] = t3;
|
|
53
|
+
} else t3 = $[3];
|
|
54
|
+
const sampled = t3;
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[4] !== caption || $[5] !== t) {
|
|
57
|
+
t4 = t("blocks.tableOf", { name: caption });
|
|
58
|
+
$[4] = caption;
|
|
59
|
+
$[5] = t;
|
|
60
|
+
$[6] = t4;
|
|
61
|
+
} else t4 = $[6];
|
|
62
|
+
let t5;
|
|
63
|
+
if ($[7] !== t) {
|
|
64
|
+
t5 = t("blocks.name");
|
|
65
|
+
$[7] = t;
|
|
66
|
+
$[8] = t5;
|
|
67
|
+
} else t5 = $[8];
|
|
68
|
+
let t6;
|
|
69
|
+
if ($[9] !== t5) {
|
|
70
|
+
t6 = {
|
|
71
|
+
cell: nameCell,
|
|
72
|
+
key: "name",
|
|
73
|
+
label: t5,
|
|
74
|
+
rowHeader: true
|
|
75
|
+
};
|
|
76
|
+
$[9] = t5;
|
|
77
|
+
$[10] = t6;
|
|
78
|
+
} else t6 = $[10];
|
|
79
|
+
let t7;
|
|
80
|
+
if ($[11] !== sampled || $[12] !== t) {
|
|
81
|
+
t7 = sampled ? [{
|
|
82
|
+
cell: _temp3,
|
|
83
|
+
key: "sample",
|
|
84
|
+
label: t("blocks.sample")
|
|
85
|
+
}] : [];
|
|
86
|
+
$[11] = sampled;
|
|
87
|
+
$[12] = t;
|
|
88
|
+
$[13] = t7;
|
|
89
|
+
} else t7 = $[13];
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[14] !== readings || $[15] !== t) {
|
|
92
|
+
t8 = (t9) => {
|
|
93
|
+
const { variable: variable_0 } = t9;
|
|
94
|
+
return written(readings.get(variable_0), t("blocks.missing"));
|
|
95
|
+
};
|
|
96
|
+
$[14] = readings;
|
|
97
|
+
$[15] = t;
|
|
98
|
+
$[16] = t8;
|
|
99
|
+
} else t8 = $[16];
|
|
100
|
+
let t9;
|
|
101
|
+
if ($[17] !== t) {
|
|
102
|
+
t9 = t("blocks.value");
|
|
103
|
+
$[17] = t;
|
|
104
|
+
$[18] = t9;
|
|
105
|
+
} else t9 = $[18];
|
|
106
|
+
let t10;
|
|
107
|
+
if ($[19] !== t8 || $[20] !== t9) {
|
|
108
|
+
t10 = {
|
|
109
|
+
cell: t8,
|
|
110
|
+
key: "value",
|
|
111
|
+
label: t9
|
|
112
|
+
};
|
|
113
|
+
$[19] = t8;
|
|
114
|
+
$[20] = t9;
|
|
115
|
+
$[21] = t10;
|
|
116
|
+
} else t10 = $[21];
|
|
117
|
+
let t11;
|
|
118
|
+
if ($[22] !== lengths || $[23] !== readings || $[24] !== t) {
|
|
119
|
+
t11 = lengths ? [{
|
|
120
|
+
cell: (t12) => {
|
|
121
|
+
const { variable: variable_1 } = t12;
|
|
122
|
+
return pixelsOf(readings.get(variable_1)) ?? "";
|
|
123
|
+
},
|
|
124
|
+
key: "pixels",
|
|
125
|
+
label: t("blocks.pixels"),
|
|
126
|
+
numeric: true
|
|
127
|
+
}] : [];
|
|
128
|
+
$[22] = lengths;
|
|
129
|
+
$[23] = readings;
|
|
130
|
+
$[24] = t;
|
|
131
|
+
$[25] = t11;
|
|
132
|
+
} else t11 = $[25];
|
|
133
|
+
let t12;
|
|
134
|
+
if ($[26] !== t10 || $[27] !== t11 || $[28] !== t6 || $[29] !== t7) {
|
|
135
|
+
t12 = [
|
|
136
|
+
t6,
|
|
137
|
+
...t7,
|
|
138
|
+
t10,
|
|
139
|
+
...t11
|
|
140
|
+
];
|
|
141
|
+
$[26] = t10;
|
|
142
|
+
$[27] = t11;
|
|
143
|
+
$[28] = t6;
|
|
144
|
+
$[29] = t7;
|
|
145
|
+
$[30] = t12;
|
|
146
|
+
} else t12 = $[30];
|
|
147
|
+
let t13;
|
|
148
|
+
if ($[31] !== caption || $[32] !== rows || $[33] !== t12 || $[34] !== t4) {
|
|
149
|
+
t13 = /* @__PURE__ */ jsx(Table.Simple, {
|
|
150
|
+
"aria-label": t4,
|
|
151
|
+
caption,
|
|
152
|
+
columns: t12,
|
|
153
|
+
rows,
|
|
154
|
+
rowToKey: _temp4,
|
|
155
|
+
viewportRef: setBox
|
|
156
|
+
});
|
|
157
|
+
$[31] = caption;
|
|
158
|
+
$[32] = rows;
|
|
159
|
+
$[33] = t12;
|
|
160
|
+
$[34] = t4;
|
|
161
|
+
$[35] = t13;
|
|
162
|
+
} else t13 = $[35];
|
|
163
|
+
return t13;
|
|
164
|
+
}
|
|
165
|
+
function _temp4(t0) {
|
|
166
|
+
const { variable: variable_2 } = t0;
|
|
167
|
+
return variable_2;
|
|
168
|
+
}
|
|
169
|
+
function _temp3(t0) {
|
|
170
|
+
const { sample: sample_0 } = t0;
|
|
171
|
+
return sample_0;
|
|
172
|
+
}
|
|
173
|
+
function _temp2(t0) {
|
|
174
|
+
const { sample } = t0;
|
|
175
|
+
return sample !== void 0;
|
|
176
|
+
}
|
|
177
|
+
function _temp(t0) {
|
|
178
|
+
const { variable } = t0;
|
|
179
|
+
return variable;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { TokenTable as t };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { n as variableOf } from "./variables-ymFs3Bzn.js";
|
|
2
|
+
import { n as useWords, t as DocPage } from "./doc-page-BQXdbP_h.js";
|
|
3
|
+
import { t as TokenTable } from "./token-table-yrZh5kLy.js";
|
|
4
|
+
import { PALETTES } from "@stealthscale/theme/contract";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { Stack } from "@stealthscale/component-layout";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Button } from "@stealthscale/component-actions";
|
|
9
|
+
//#region src/blocks/palette-buttons.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Lists the looks the buttons are shown in.
|
|
12
|
+
*/
|
|
13
|
+
const LOOKS = ["solid", "subtle"];
|
|
14
|
+
/**
|
|
15
|
+
* Renders a row per look, each with a button per palette named by the palette.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* One recipe renders every button, and the palette points `colorPalette` at another palette, so
|
|
19
|
+
* each button reads the same roles of another palette.
|
|
20
|
+
*/
|
|
21
|
+
function PaletteButtons() {
|
|
22
|
+
const $ = c(1);
|
|
23
|
+
let t0;
|
|
24
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
25
|
+
t0 = /* @__PURE__ */ jsx(Stack, {
|
|
26
|
+
gap: "sm",
|
|
27
|
+
children: LOOKS.map(_temp$1)
|
|
28
|
+
});
|
|
29
|
+
$[0] = t0;
|
|
30
|
+
} else t0 = $[0];
|
|
31
|
+
return t0;
|
|
32
|
+
}
|
|
33
|
+
function _temp$1(look) {
|
|
34
|
+
return /* @__PURE__ */ jsx(Stack, {
|
|
35
|
+
direction: "row",
|
|
36
|
+
gap: "sm",
|
|
37
|
+
wrap: true,
|
|
38
|
+
children: PALETTES.map((palette) => /* @__PURE__ */ jsx(Button, {
|
|
39
|
+
palette,
|
|
40
|
+
size: "sm",
|
|
41
|
+
variant: look,
|
|
42
|
+
children: palette
|
|
43
|
+
}, palette))
|
|
44
|
+
}, look);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/pages/tokens.tsx
|
|
48
|
+
/**
|
|
49
|
+
* Lists the tokens whose custom properties the page reads, by category and path.
|
|
50
|
+
*/
|
|
51
|
+
const READ = [
|
|
52
|
+
["colors", "bg.panel"],
|
|
53
|
+
["spacing", "gap.md"],
|
|
54
|
+
["sizes", "control.md"],
|
|
55
|
+
["radii", "l2"],
|
|
56
|
+
["durations", "press"]
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* Renders the tokens page.
|
|
60
|
+
*/
|
|
61
|
+
function TokensPage() {
|
|
62
|
+
const $ = c(11);
|
|
63
|
+
const { t } = useWords();
|
|
64
|
+
let t0;
|
|
65
|
+
let t1;
|
|
66
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
67
|
+
t0 = { id: "kinds" };
|
|
68
|
+
t1 = { id: "naming" };
|
|
69
|
+
$[0] = t0;
|
|
70
|
+
$[1] = t1;
|
|
71
|
+
} else {
|
|
72
|
+
t0 = $[0];
|
|
73
|
+
t1 = $[1];
|
|
74
|
+
}
|
|
75
|
+
let t2;
|
|
76
|
+
if ($[2] !== t) {
|
|
77
|
+
t2 = t("tokens.sections.variables.title");
|
|
78
|
+
$[2] = t;
|
|
79
|
+
$[3] = t2;
|
|
80
|
+
} else t2 = $[3];
|
|
81
|
+
let t3;
|
|
82
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
83
|
+
t3 = READ.map(_temp);
|
|
84
|
+
$[4] = t3;
|
|
85
|
+
} else t3 = $[4];
|
|
86
|
+
let t4;
|
|
87
|
+
if ($[5] !== t2) {
|
|
88
|
+
t4 = {
|
|
89
|
+
block: /* @__PURE__ */ jsx(TokenTable, {
|
|
90
|
+
caption: t2,
|
|
91
|
+
rows: t3
|
|
92
|
+
}),
|
|
93
|
+
id: "variables"
|
|
94
|
+
};
|
|
95
|
+
$[5] = t2;
|
|
96
|
+
$[6] = t4;
|
|
97
|
+
} else t4 = $[6];
|
|
98
|
+
let t5;
|
|
99
|
+
let t6;
|
|
100
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t5 = {
|
|
102
|
+
block: /* @__PURE__ */ jsx(PaletteButtons, {}),
|
|
103
|
+
id: "palette"
|
|
104
|
+
};
|
|
105
|
+
t6 = { id: "runtime" };
|
|
106
|
+
$[7] = t5;
|
|
107
|
+
$[8] = t6;
|
|
108
|
+
} else {
|
|
109
|
+
t5 = $[7];
|
|
110
|
+
t6 = $[8];
|
|
111
|
+
}
|
|
112
|
+
let t7;
|
|
113
|
+
if ($[9] !== t4) {
|
|
114
|
+
t7 = /* @__PURE__ */ jsx(DocPage, {
|
|
115
|
+
page: "tokens",
|
|
116
|
+
sections: [
|
|
117
|
+
t0,
|
|
118
|
+
t1,
|
|
119
|
+
t4,
|
|
120
|
+
t5,
|
|
121
|
+
t6
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
$[9] = t4;
|
|
125
|
+
$[10] = t7;
|
|
126
|
+
} else t7 = $[10];
|
|
127
|
+
return t7;
|
|
128
|
+
}
|
|
129
|
+
function _temp(t0) {
|
|
130
|
+
const [category, path] = t0;
|
|
131
|
+
const variable = variableOf(category, path);
|
|
132
|
+
return {
|
|
133
|
+
name: variable,
|
|
134
|
+
variable
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { TokensPage };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { t as measured } from "./measure-uwF7Fmpy.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { COLOR_MODE_ATTRIBUTE, THEME_ATTRIBUTE } from "@stealthscale/theme";
|
|
5
|
+
//#region src/reading/use-readings.ts
|
|
6
|
+
/**
|
|
7
|
+
* Reads what a list of tokens resolves to inside an element, once the element is in the document.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The readings before the element is in the document.
|
|
11
|
+
*/
|
|
12
|
+
const NONE = /* @__PURE__ */ new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Reads every token inside an element now and again whenever the document's theme or color mode
|
|
15
|
+
* changes.
|
|
16
|
+
*
|
|
17
|
+
* @param element - The element the tokens resolve in.
|
|
18
|
+
* @param asked - The custom properties to read, encoded as JSON.
|
|
19
|
+
* @param store - Receives each set of readings.
|
|
20
|
+
* @returns The function that stops reading.
|
|
21
|
+
*/
|
|
22
|
+
function watched(element, asked, store) {
|
|
23
|
+
const list = JSON.parse(asked);
|
|
24
|
+
const observer = new MutationObserver(read);
|
|
25
|
+
function read() {
|
|
26
|
+
store(measured(element, list));
|
|
27
|
+
}
|
|
28
|
+
read();
|
|
29
|
+
observer.observe(document.documentElement, {
|
|
30
|
+
attributeFilter: [THEME_ATTRIBUTE, COLOR_MODE_ATTRIBUTE],
|
|
31
|
+
attributes: true
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
observer.disconnect();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads every token inside an element after it renders, again when the element or the list
|
|
39
|
+
* changes, and again whenever the document's theme or color mode changes.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* The effect depends on the list encoded rather than on the array, because a caller that writes
|
|
43
|
+
* the array inline passes a new one every render. The theme provider writes the document's theme
|
|
44
|
+
* and color mode in an effect, which runs after the effects of the page under it, so the readings
|
|
45
|
+
* follow the document's attributes and not the theme a person picked.
|
|
46
|
+
* @param box - The element the tokens resolve in, or null before it renders.
|
|
47
|
+
* @param variables - The custom properties to read.
|
|
48
|
+
* @returns Each custom property's reading, or none before the element renders.
|
|
49
|
+
*/
|
|
50
|
+
function useReadings(box, variables) {
|
|
51
|
+
const $ = c(6);
|
|
52
|
+
const [readings, setReadings] = useState(NONE);
|
|
53
|
+
let t0;
|
|
54
|
+
if ($[0] !== variables) {
|
|
55
|
+
t0 = JSON.stringify(variables);
|
|
56
|
+
$[0] = variables;
|
|
57
|
+
$[1] = t0;
|
|
58
|
+
} else t0 = $[1];
|
|
59
|
+
const asked = t0;
|
|
60
|
+
let t1;
|
|
61
|
+
let t2;
|
|
62
|
+
if ($[2] !== asked || $[3] !== box) {
|
|
63
|
+
t1 = () => box === null ? void 0 : watched(box, asked, setReadings);
|
|
64
|
+
t2 = [asked, box];
|
|
65
|
+
$[2] = asked;
|
|
66
|
+
$[3] = box;
|
|
67
|
+
$[4] = t1;
|
|
68
|
+
$[5] = t2;
|
|
69
|
+
} else {
|
|
70
|
+
t1 = $[4];
|
|
71
|
+
t2 = $[5];
|
|
72
|
+
}
|
|
73
|
+
useEffect(t1, t2);
|
|
74
|
+
return readings;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { useReadings as t };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/reading/variables.ts
|
|
2
|
+
/**
|
|
3
|
+
* Writes the custom property a token is declared under, the way the stylesheet compiler names it.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The compiler joins the category and the path with dashes, writes a capital as a dash and the
|
|
7
|
+
* lower-case letter, and escapes every other character a custom property's name cannot contain:
|
|
8
|
+
* `colors.primary.focusRing` is `--colors-primary-focus-ring` and the grid step `spacing.0.5` is
|
|
9
|
+
* `--spacing-0\.5`. A dot between two digits is part of a step's name and every other dot
|
|
10
|
+
* separates two segments, because no key of the foundation has a dot between letters.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Matches a dot that separates two segments of a path: one that is not between two digits.
|
|
14
|
+
*/
|
|
15
|
+
const SEPARATOR = /\.(?!\d)|(?<!\d)\./u;
|
|
16
|
+
/**
|
|
17
|
+
* Writes one segment of a name: each capital as a dash and its lower-case letter, and each other
|
|
18
|
+
* character a custom property cannot contain escaped.
|
|
19
|
+
*/
|
|
20
|
+
function segmentOf(segment) {
|
|
21
|
+
return segment.replaceAll(/[A-Z]/gu, (capital) => `-${capital.toLowerCase()}`).replaceAll(/[^\w-]/gu, (other) => `\\${other}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the custom property a token is declared under.
|
|
25
|
+
*
|
|
26
|
+
* @param category - The token's category, such as `colors` or `zIndex`.
|
|
27
|
+
* @param path - The token's path inside the category, such as `primary.solid`. A `DEFAULT` segment
|
|
28
|
+
* is the category's own value and adds no segment.
|
|
29
|
+
*/
|
|
30
|
+
function variableOf(category, path) {
|
|
31
|
+
return `--${[category, ...path.split(SEPARATOR).filter((one) => one !== "DEFAULT")].map((segment) => segmentOf(segment)).join("-")}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a reference to the custom property a token is declared under, as a style reads it.
|
|
35
|
+
*
|
|
36
|
+
* @param category - The token's category.
|
|
37
|
+
* @param path - The token's path inside the category.
|
|
38
|
+
*/
|
|
39
|
+
function referenceOf(category, path) {
|
|
40
|
+
return `var(${variableOf(category, path)})`;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { variableOf as n, referenceOf as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useThemeChoice } from "@stealthscale/provider-shell";
|
|
2
|
+
//#region src/reading/worn.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reads the theme the page wears.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns the theme the page wears: the one a person chose, else the first the product offers, or
|
|
8
|
+
* undefined for a product that offers none.
|
|
9
|
+
*/
|
|
10
|
+
function useWornTheme() {
|
|
11
|
+
const { theme, themes } = useThemeChoice();
|
|
12
|
+
return theme ?? themes[0];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useWornTheme as t };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as DocPage } from "./doc-page-BQXdbP_h.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/pages/writing.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The page's sections, in reading order. Each is prose with its code.
|
|
7
|
+
*/
|
|
8
|
+
const SECTIONS = [
|
|
9
|
+
{ id: "statement" },
|
|
10
|
+
{ id: "axes" },
|
|
11
|
+
{ id: "colors" },
|
|
12
|
+
{ id: "derived" },
|
|
13
|
+
{ id: "installing" }
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Renders the page on writing a theme.
|
|
17
|
+
*/
|
|
18
|
+
function WritingPage() {
|
|
19
|
+
const $ = c(1);
|
|
20
|
+
let t0;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t0 = /* @__PURE__ */ jsx(DocPage, {
|
|
23
|
+
page: "writing",
|
|
24
|
+
sections: SECTIONS
|
|
25
|
+
});
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
} else t0 = $[0];
|
|
28
|
+
return t0;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { WritingPage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,127 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stealthscale/plugin-theming",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Renders the theming pages: what a theme is, every token, style and condition it fills with the values read from the stylesheet in both color modes, the gate's pairs measured live, and how a theme is written.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"plugins",
|
|
8
|
+
"react",
|
|
9
|
+
"theme",
|
|
10
|
+
"theming"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/stealth-scale/scale/tree/main/plugins/theming/web#readme",
|
|
13
|
+
"bugs": "https://github.com/stealth-scale/scale/issues",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/stealth-scale/scale.git",
|
|
18
|
+
"directory": "plugins/theming/web"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"imports": {
|
|
28
|
+
"#*": "./src/*"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./dist/index.js",
|
|
32
|
+
"./theme": "./dist/theme.js",
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@stealthscale/plugin-theming-contract": "^0.1.0",
|
|
40
|
+
"@stealthscale/sdk-core": "^0.2.0",
|
|
41
|
+
"lucide-react": "^1.52"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@arethetypeswrong/core": "^0.18",
|
|
45
|
+
"@openfeature/web-sdk": "^1.10",
|
|
46
|
+
"@stealthscale/component-actions": "^0.2.0",
|
|
47
|
+
"@stealthscale/component-collections": "^0.1.0",
|
|
48
|
+
"@stealthscale/component-content": "^0.1.0",
|
|
49
|
+
"@stealthscale/component-data": "^0.2.0",
|
|
50
|
+
"@stealthscale/component-disclosure": "^0.2.0",
|
|
51
|
+
"@stealthscale/component-forms": "^0.2.0",
|
|
52
|
+
"@stealthscale/component-layout": "^0.2.0",
|
|
53
|
+
"@stealthscale/component-navigation": "^0.2.0",
|
|
54
|
+
"@stealthscale/component-screen": "^0.1.0",
|
|
55
|
+
"@stealthscale/component-surfaces": "^0.1.0",
|
|
56
|
+
"@stealthscale/component-typography": "^0.2.0",
|
|
57
|
+
"@stealthscale/hooks": "^0.2.0",
|
|
58
|
+
"@stealthscale/provider-color-mode": "^0.2.0",
|
|
59
|
+
"@stealthscale/provider-data": "^0.2.0",
|
|
60
|
+
"@stealthscale/provider-form": "^0.2.0",
|
|
61
|
+
"@stealthscale/provider-hotkeys": "^0.2.0",
|
|
62
|
+
"@stealthscale/provider-i18n": "^0.1.0",
|
|
63
|
+
"@stealthscale/provider-router": "^0.2.0",
|
|
64
|
+
"@stealthscale/provider-shell": "^0.2.0",
|
|
65
|
+
"@stealthscale/provider-viewport": "^0.2.0",
|
|
66
|
+
"@stealthscale/sdk-host": "^0.2.0",
|
|
67
|
+
"@stealthscale/sdk-plugin": "^0.2.0",
|
|
68
|
+
"@stealthscale/settings": "^0.1.0",
|
|
69
|
+
"@stealthscale/testing-config": "^0.6.0",
|
|
70
|
+
"@stealthscale/testing-plugin": "^0.2.0",
|
|
71
|
+
"@stealthscale/testing-react": "^0.9.0",
|
|
72
|
+
"@stealthscale/testing-theme": "^0.3.0",
|
|
73
|
+
"@stealthscale/theme": "^0.4.0",
|
|
74
|
+
"@stealthscale/vite-config": "^0.7.0",
|
|
75
|
+
"@stealthscale/vite-config-core": "^0.4.0",
|
|
76
|
+
"@stealthscale/vite-config-i18n": "^0.2.0",
|
|
77
|
+
"@stealthscale/vite-config-product": "^0.2.0",
|
|
78
|
+
"@stealthscale/vite-config-react": "^0.9.0",
|
|
79
|
+
"@stealthscale/vite-config-typescript": "^0.3.0",
|
|
80
|
+
"@tanstack/react-form": "^1.33",
|
|
81
|
+
"@tanstack/react-hotkeys": "^0.13",
|
|
82
|
+
"@tanstack/react-query": "^5.104",
|
|
83
|
+
"@tanstack/react-router": "1.170.41",
|
|
84
|
+
"@tanstack/react-router-ssr-query": "^1.167",
|
|
85
|
+
"@testing-library/react": "^16.3",
|
|
86
|
+
"@types/react": "^19.3",
|
|
87
|
+
"@types/react-dom": "^19.3",
|
|
88
|
+
"@vitest/coverage-v8": "5.0.3",
|
|
89
|
+
"happy-dom": "^20.14",
|
|
90
|
+
"i18next": "^26.4",
|
|
91
|
+
"oxc-transform-react": "^0.153",
|
|
92
|
+
"publint": "^0.3",
|
|
93
|
+
"react": "^19.3",
|
|
94
|
+
"react-dom": "^19.3",
|
|
95
|
+
"react-i18next": "^17.0",
|
|
96
|
+
"typescript": "^7.0",
|
|
97
|
+
"vitest": "5.0.3"
|
|
98
|
+
},
|
|
99
|
+
"peerDependencies": {
|
|
100
|
+
"@stealthscale/component-actions": "^0.2.0",
|
|
101
|
+
"@stealthscale/component-collections": "^0.1.0",
|
|
102
|
+
"@stealthscale/component-content": "^0.1.0",
|
|
103
|
+
"@stealthscale/component-data": "^0.2.0",
|
|
104
|
+
"@stealthscale/component-disclosure": "^0.2.0",
|
|
105
|
+
"@stealthscale/component-forms": "^0.2.0",
|
|
106
|
+
"@stealthscale/component-layout": "^0.2.0",
|
|
107
|
+
"@stealthscale/component-navigation": "^0.2.0",
|
|
108
|
+
"@stealthscale/component-screen": "^0.1.0",
|
|
109
|
+
"@stealthscale/component-surfaces": "^0.1.0",
|
|
110
|
+
"@stealthscale/component-typography": "^0.2.0",
|
|
111
|
+
"@stealthscale/hooks": "^0.2.0",
|
|
112
|
+
"@stealthscale/provider-i18n": "^0.1.0",
|
|
113
|
+
"@stealthscale/provider-router": "^0.2.0",
|
|
114
|
+
"@stealthscale/provider-shell": "^0.2.0",
|
|
115
|
+
"@stealthscale/sdk-plugin": "^0.2.0",
|
|
116
|
+
"@stealthscale/theme": "^0.4.0",
|
|
117
|
+
"react": "^19.3"
|
|
118
|
+
},
|
|
119
|
+
"engines": {
|
|
120
|
+
"node": ">=26.0.0"
|
|
121
|
+
},
|
|
122
|
+
"scripts": {
|
|
123
|
+
"build": "vp pack",
|
|
124
|
+
"check": "vp check",
|
|
125
|
+
"test": "vp test"
|
|
126
|
+
}
|
|
6
127
|
}
|