@stealthscale/plugin-theming 0.0.0-stage → 0.2.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -2
  3. package/dist/accessibility-Dg5Dh35o.js +409 -0
  4. package/dist/attributes-vx1W0PiK.js +26 -0
  5. package/dist/breakpoints-CJjhy79u.js +83 -0
  6. package/dist/code-DcoH6hCX.js +69 -0
  7. package/dist/conditions-CjjQwqro.js +338 -0
  8. package/dist/corners-CH5jyCks.js +92 -0
  9. package/dist/cursors-hl00ix41.js +54 -0
  10. package/dist/cyclonedx/bom.json +1 -0
  11. package/dist/density-DEW_j0I5.js +207 -0
  12. package/dist/depth-DCn3mAAJ.js +143 -0
  13. package/dist/doc-page-BQXdbP_h.js +439 -0
  14. package/dist/extending-CY7ry7Y4.js +31 -0
  15. package/dist/faces-D76c_Ryh.js +65 -0
  16. package/dist/gate-CoX2Yr9x.js +199 -0
  17. package/dist/index.d.ts +48 -0
  18. package/dist/index.js +39 -0
  19. package/dist/layers-BxdWdfPg.js +53 -0
  20. package/dist/looks-BrROho5Y.js +107 -0
  21. package/dist/measure-uwF7Fmpy.js +137 -0
  22. package/dist/mode-colors-Cf_ZPo3g.js +260 -0
  23. package/dist/mode-panels-Bmh0ec0U.js +54 -0
  24. package/dist/motion-DRbsuZZo.js +202 -0
  25. package/dist/overview-BbE82N2c.js +192 -0
  26. package/dist/palettes-CZo2HrNT.js +49 -0
  27. package/dist/parts-BVmqVMgo.js +25 -0
  28. package/dist/recipes-C88xVIGB.js +32 -0
  29. package/dist/rows-Dv8c7jye.js +18 -0
  30. package/dist/sampler-Ue67PX2n.js +27 -0
  31. package/dist/series-AvSZjk2b.js +63 -0
  32. package/dist/setting-BsgJKTlh.js +12 -0
  33. package/dist/sizes-B7LgvyBS.js +98 -0
  34. package/dist/spacing-DMyyV6vX.js +75 -0
  35. package/dist/surfaces-Db0HjMwB.js +76 -0
  36. package/dist/text-styles-BZnXaigP.js +233 -0
  37. package/dist/theme.d.ts +12 -0
  38. package/dist/theme.js +23 -0
  39. package/dist/themes-yClyRA9e.js +305 -0
  40. package/dist/theming-text.recipe-Dvcza4j1.js +308 -0
  41. package/dist/token-table-yrZh5kLy.js +182 -0
  42. package/dist/tokens-7Pm-eLiZ.js +138 -0
  43. package/dist/use-readings-D56mNtEc.js +77 -0
  44. package/dist/variables-ymFs3Bzn.js +43 -0
  45. package/dist/worn-D4HEJsJ2.js +15 -0
  46. package/dist/writing-b05oSPB2.js +31 -0
  47. package/package.json +124 -3
@@ -0,0 +1,98 @@
1
+ import { n as useWords, t as DocPage } from "./doc-page-BQXdbP_h.js";
2
+ import { t as tokenRows } from "./rows-Dv8c7jye.js";
3
+ import { t as TokenTable } from "./token-table-yrZh5kLy.js";
4
+ import { t as sampler } from "./sampler-Ue67PX2n.js";
5
+ import { ASPECT_RATIOS, INTRINSIC, LAYOUT, SCALE, WIDTHS } from "@stealthscale/theme/contract";
6
+ import { c } from "react/compiler-runtime";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/pages/sizes.tsx
9
+ /**
10
+ * Renders a square as large as a size.
11
+ */
12
+ const SQUARE = sampler("square", "size");
13
+ /**
14
+ * Lists the page's tables, in reading order.
15
+ */
16
+ const TABLES = [
17
+ {
18
+ category: "sizes",
19
+ id: "controls",
20
+ lengths: true,
21
+ names: SCALE.map((step) => `control.${step}`),
22
+ sample: SQUARE
23
+ },
24
+ {
25
+ category: "sizes",
26
+ id: "icons",
27
+ lengths: true,
28
+ names: SCALE.map((step) => `icon.${step}`),
29
+ sample: SQUARE
30
+ },
31
+ {
32
+ category: "sizes",
33
+ id: "tags",
34
+ lengths: true,
35
+ names: SCALE.map((step) => `tag.${step}`),
36
+ sample: SQUARE
37
+ },
38
+ {
39
+ category: "sizes",
40
+ id: "layout",
41
+ lengths: true,
42
+ names: LAYOUT
43
+ },
44
+ {
45
+ category: "sizes",
46
+ id: "measures",
47
+ lengths: true,
48
+ names: WIDTHS
49
+ },
50
+ {
51
+ category: "sizes",
52
+ id: "intrinsic",
53
+ lengths: false,
54
+ names: INTRINSIC
55
+ },
56
+ {
57
+ category: "aspectRatios",
58
+ id: "ratios",
59
+ lengths: false,
60
+ names: ASPECT_RATIOS,
61
+ sample: sampler("ratio", "ratio")
62
+ }
63
+ ];
64
+ /**
65
+ * Renders the sizes page.
66
+ */
67
+ function SizesPage() {
68
+ const $ = c(4);
69
+ const { t } = useWords();
70
+ let t0;
71
+ if ($[0] !== t) {
72
+ t0 = TABLES.map((t1) => {
73
+ const { category, id, lengths, names, sample } = t1;
74
+ return {
75
+ block: /* @__PURE__ */ jsx(TokenTable, {
76
+ caption: t(`sizes.sections.${id}.title`, { defaultValue: id }),
77
+ lengths,
78
+ rows: tokenRows(category, names, sample)
79
+ }),
80
+ id
81
+ };
82
+ });
83
+ $[0] = t;
84
+ $[1] = t0;
85
+ } else t0 = $[1];
86
+ let t1;
87
+ if ($[2] !== t0) {
88
+ t1 = /* @__PURE__ */ jsx(DocPage, {
89
+ page: "sizes",
90
+ sections: t0
91
+ });
92
+ $[2] = t0;
93
+ $[3] = t1;
94
+ } else t1 = $[3];
95
+ return t1;
96
+ }
97
+ //#endregion
98
+ export { SizesPage };
@@ -0,0 +1,75 @@
1
+ import { n as useWords, t as DocPage } from "./doc-page-BQXdbP_h.js";
2
+ import { t as tokenRows } from "./rows-Dv8c7jye.js";
3
+ import { t as TokenTable } from "./token-table-yrZh5kLy.js";
4
+ import { t as sampler } from "./sampler-Ue67PX2n.js";
5
+ import { GRID, SCALE } from "@stealthscale/theme/contract";
6
+ import { c } from "react/compiler-runtime";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/pages/spacing.tsx
9
+ /**
10
+ * Lists the page's tables, in reading order.
11
+ */
12
+ const TABLES = [
13
+ {
14
+ barred: true,
15
+ id: "gaps",
16
+ names: SCALE.map((step) => `gap.${step}`)
17
+ },
18
+ {
19
+ barred: true,
20
+ id: "insets",
21
+ names: SCALE.map((step) => `inset.${step}`)
22
+ },
23
+ {
24
+ barred: true,
25
+ id: "grid",
26
+ names: GRID
27
+ },
28
+ {
29
+ barred: false,
30
+ id: "other",
31
+ names: [
32
+ "marker",
33
+ "ring",
34
+ "safe.top",
35
+ "safe.right",
36
+ "safe.bottom",
37
+ "safe.left"
38
+ ]
39
+ }
40
+ ];
41
+ /**
42
+ * Renders the spacing page.
43
+ */
44
+ function SpacingPage() {
45
+ const $ = c(4);
46
+ const { t } = useWords();
47
+ let t0;
48
+ if ($[0] !== t) {
49
+ t0 = TABLES.map((t1) => {
50
+ const { barred, id, names } = t1;
51
+ return {
52
+ block: /* @__PURE__ */ jsx(TokenTable, {
53
+ caption: t(`spacing.sections.${id}.title`, { defaultValue: id }),
54
+ lengths: true,
55
+ rows: tokenRows("spacing", names, barred ? sampler("bar", "size") : void 0)
56
+ }),
57
+ id
58
+ };
59
+ });
60
+ $[0] = t;
61
+ $[1] = t0;
62
+ } else t0 = $[1];
63
+ let t1;
64
+ if ($[2] !== t0) {
65
+ t1 = /* @__PURE__ */ jsx(DocPage, {
66
+ page: "spacing",
67
+ sections: t0
68
+ });
69
+ $[2] = t0;
70
+ $[3] = t1;
71
+ } else t1 = $[3];
72
+ return t1;
73
+ }
74
+ //#endregion
75
+ export { SpacingPage };
@@ -0,0 +1,76 @@
1
+ import { n as variableOf } from "./variables-ymFs3Bzn.js";
2
+ import { t as DocPage } from "./doc-page-BQXdbP_h.js";
3
+ import { t as ModeColors } from "./mode-colors-Cf_ZPo3g.js";
4
+ import { BACKGROUNDS, BORDERS, FOREGROUNDS, STATUSES } from "@stealthscale/theme/contract";
5
+ import { c } from "react/compiler-runtime";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/pages/surfaces.tsx
8
+ /**
9
+ * Returns a token of a family by its member, the family's own value for `DEFAULT`.
10
+ */
11
+ function tokenOf(family, member) {
12
+ const name = member === "DEFAULT" ? family : `${family}.${member}`;
13
+ return {
14
+ name,
15
+ variable: variableOf("colors", name)
16
+ };
17
+ }
18
+ /**
19
+ * Returns a family's members and its status members as rows, each measured against the token its
20
+ * function names: the ink on a background, a background behind an ink or a line, and the inverted
21
+ * member against its inverted partner.
22
+ */
23
+ function rowsOf(family, members, partner) {
24
+ return [...members, ...STATUSES].map((member) => {
25
+ const { name, variable } = tokenOf(family, member);
26
+ return {
27
+ against: tokenOf(partner, member === "inverted" ? "inverted" : "DEFAULT"),
28
+ name,
29
+ variable
30
+ };
31
+ });
32
+ }
33
+ /**
34
+ * The page's sections: a family each, then the wells.
35
+ */
36
+ const SECTIONS = [
37
+ {
38
+ block: /* @__PURE__ */ jsx(ModeColors, {
39
+ name: "bg",
40
+ rows: rowsOf("bg", BACKGROUNDS, "fg")
41
+ }),
42
+ id: "backgrounds"
43
+ },
44
+ {
45
+ block: /* @__PURE__ */ jsx(ModeColors, {
46
+ name: "fg",
47
+ rows: rowsOf("fg", FOREGROUNDS, "bg")
48
+ }),
49
+ id: "inks"
50
+ },
51
+ {
52
+ block: /* @__PURE__ */ jsx(ModeColors, {
53
+ name: "border",
54
+ rows: rowsOf("border", BORDERS, "bg")
55
+ }),
56
+ id: "lines"
57
+ },
58
+ { id: "wells" }
59
+ ];
60
+ /**
61
+ * Renders the surfaces page.
62
+ */
63
+ function SurfacesPage() {
64
+ const $ = c(1);
65
+ let t0;
66
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
67
+ t0 = /* @__PURE__ */ jsx(DocPage, {
68
+ page: "surfaces",
69
+ sections: SECTIONS
70
+ });
71
+ $[0] = t0;
72
+ } else t0 = $[0];
73
+ return t0;
74
+ }
75
+ //#endregion
76
+ export { SurfacesPage };
@@ -0,0 +1,233 @@
1
+ import { s as keyOf } from "./theming-text.recipe-Dvcza4j1.js";
2
+ import { s as roundedPixels } from "./measure-uwF7Fmpy.js";
3
+ import { n as useWords, t as DocPage } from "./doc-page-BQXdbP_h.js";
4
+ import { t as tokenRows } from "./rows-Dv8c7jye.js";
5
+ import { t as TokenTable } from "./token-table-yrZh5kLy.js";
6
+ import { a as ThemingText } from "./parts-BVmqVMgo.js";
7
+ import { t as sampler } from "./sampler-Ue67PX2n.js";
8
+ import { FONT_SIZES, LETTER_SPACINGS, LINE_HEIGHTS, ROLE_STYLES } from "@stealthscale/theme/contract";
9
+ import { c } from "react/compiler-runtime";
10
+ import { useEffect, useState } from "react";
11
+ import { Grid, Stack } from "@stealthscale/component-layout";
12
+ import { Code, Text } from "@stealthscale/component-typography";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ //#region src/blocks/text-style-item.tsx
15
+ /**
16
+ * Renders one text style: its name, a line set in it, and the size, leading, weight and tracking
17
+ * the line comes to.
18
+ */
19
+ /**
20
+ * Renders the style's name, the sample line, and what the browser computed for the line.
21
+ *
22
+ * @remarks
23
+ * The computed values are read from the line once it renders, so they are the theme's values in
24
+ * the page's mode, whatever the style refers to.
25
+ */
26
+ function TextStyleItem(t0) {
27
+ const $ = c(19);
28
+ const { name } = t0;
29
+ const { t } = useWords();
30
+ const [line, setLine] = useState(null);
31
+ const [computed, setComputed] = useState("");
32
+ let t1;
33
+ let t2;
34
+ if ($[0] !== line || $[1] !== t) {
35
+ t1 = () => {
36
+ if (line === null) return;
37
+ const element = line;
38
+ (function read() {
39
+ const style = getComputedStyle(element);
40
+ setComputed(t("blocks.computed", {
41
+ leading: roundedPixels(style.lineHeight),
42
+ size: roundedPixels(style.fontSize),
43
+ tracking: roundedPixels(style.letterSpacing),
44
+ weight: style.fontWeight
45
+ }));
46
+ })();
47
+ };
48
+ t2 = [line, t];
49
+ $[0] = line;
50
+ $[1] = t;
51
+ $[2] = t1;
52
+ $[3] = t2;
53
+ } else {
54
+ t1 = $[2];
55
+ t2 = $[3];
56
+ }
57
+ useEffect(t1, t2);
58
+ let t3;
59
+ if ($[4] !== name) {
60
+ t3 = /* @__PURE__ */ jsx(Code, { children: name });
61
+ $[4] = name;
62
+ $[5] = t3;
63
+ } else t3 = $[5];
64
+ let t4;
65
+ if ($[6] !== name) {
66
+ t4 = keyOf(name);
67
+ $[6] = name;
68
+ $[7] = t4;
69
+ } else t4 = $[7];
70
+ let t5;
71
+ if ($[8] !== t) {
72
+ t5 = t("blocks.specimen");
73
+ $[8] = t;
74
+ $[9] = t5;
75
+ } else t5 = $[9];
76
+ let t6;
77
+ if ($[10] !== t4 || $[11] !== t5) {
78
+ t6 = /* @__PURE__ */ jsx(ThemingText, {
79
+ ref: setLine,
80
+ text: t4,
81
+ children: t5
82
+ });
83
+ $[10] = t4;
84
+ $[11] = t5;
85
+ $[12] = t6;
86
+ } else t6 = $[12];
87
+ let t7;
88
+ if ($[13] !== computed) {
89
+ t7 = /* @__PURE__ */ jsx(Text, {
90
+ size: "sm",
91
+ children: computed
92
+ });
93
+ $[13] = computed;
94
+ $[14] = t7;
95
+ } else t7 = $[14];
96
+ let t8;
97
+ if ($[15] !== t3 || $[16] !== t6 || $[17] !== t7) {
98
+ t8 = /* @__PURE__ */ jsxs(Stack, {
99
+ gap: "xs",
100
+ children: [
101
+ t3,
102
+ t6,
103
+ t7
104
+ ]
105
+ });
106
+ $[15] = t3;
107
+ $[16] = t6;
108
+ $[17] = t7;
109
+ $[18] = t8;
110
+ } else t8 = $[18];
111
+ return t8;
112
+ }
113
+ //#endregion
114
+ //#region src/blocks/text-style-list.tsx
115
+ /**
116
+ * Renders an item per text style, in columns as wide as the room allows.
117
+ */
118
+ function TextStyleList(t0) {
119
+ const $ = c(4);
120
+ const { names } = t0;
121
+ let t1;
122
+ if ($[0] !== names) {
123
+ t1 = names.map(_temp);
124
+ $[0] = names;
125
+ $[1] = t1;
126
+ } else t1 = $[1];
127
+ let t2;
128
+ if ($[2] !== t1) {
129
+ t2 = /* @__PURE__ */ jsx(Grid.Root, {
130
+ columns: "fill-xs",
131
+ gap: "xl",
132
+ children: t1
133
+ });
134
+ $[2] = t1;
135
+ $[3] = t2;
136
+ } else t2 = $[3];
137
+ return t2;
138
+ }
139
+ function _temp(name) {
140
+ return /* @__PURE__ */ jsx(TextStyleItem, { name }, name);
141
+ }
142
+ //#endregion
143
+ //#region src/pages/text-styles.tsx
144
+ /**
145
+ * Renders the text styles page.
146
+ */
147
+ function TextStylesPage() {
148
+ const $ = c(17);
149
+ const { t } = useWords();
150
+ let t0;
151
+ let t1;
152
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
153
+ t0 = {
154
+ block: /* @__PURE__ */ jsx(TextStyleList, { names: FONT_SIZES }),
155
+ id: "sizes"
156
+ };
157
+ t1 = {
158
+ block: /* @__PURE__ */ jsx(TextStyleList, { names: ROLE_STYLES }),
159
+ id: "roles"
160
+ };
161
+ $[0] = t0;
162
+ $[1] = t1;
163
+ } else {
164
+ t0 = $[0];
165
+ t1 = $[1];
166
+ }
167
+ let t2;
168
+ if ($[2] !== t) {
169
+ t2 = t("text-styles.sections.leading.title");
170
+ $[2] = t;
171
+ $[3] = t2;
172
+ } else t2 = $[3];
173
+ let t3;
174
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
175
+ t3 = tokenRows("lineHeights", LINE_HEIGHTS);
176
+ $[4] = t3;
177
+ } else t3 = $[4];
178
+ let t4;
179
+ if ($[5] !== t2) {
180
+ t4 = {
181
+ block: /* @__PURE__ */ jsx(TokenTable, {
182
+ caption: t2,
183
+ rows: t3
184
+ }),
185
+ id: "leading"
186
+ };
187
+ $[5] = t2;
188
+ $[6] = t4;
189
+ } else t4 = $[6];
190
+ let t5;
191
+ if ($[7] !== t) {
192
+ t5 = t("text-styles.sections.tracking.title");
193
+ $[7] = t;
194
+ $[8] = t5;
195
+ } else t5 = $[8];
196
+ let t6;
197
+ if ($[9] !== t) {
198
+ t6 = tokenRows("letterSpacings", LETTER_SPACINGS, sampler("text", "tracking", t("blocks.specimen")));
199
+ $[9] = t;
200
+ $[10] = t6;
201
+ } else t6 = $[10];
202
+ let t7;
203
+ if ($[11] !== t5 || $[12] !== t6) {
204
+ t7 = {
205
+ block: /* @__PURE__ */ jsx(TokenTable, {
206
+ caption: t5,
207
+ rows: t6
208
+ }),
209
+ id: "tracking"
210
+ };
211
+ $[11] = t5;
212
+ $[12] = t6;
213
+ $[13] = t7;
214
+ } else t7 = $[13];
215
+ let t8;
216
+ if ($[14] !== t4 || $[15] !== t7) {
217
+ t8 = /* @__PURE__ */ jsx(DocPage, {
218
+ page: "text-styles",
219
+ sections: [
220
+ t0,
221
+ t1,
222
+ t4,
223
+ t7
224
+ ]
225
+ });
226
+ $[14] = t4;
227
+ $[15] = t7;
228
+ $[16] = t8;
229
+ } else t8 = $[16];
230
+ return t8;
231
+ }
232
+ //#endregion
233
+ export { TextStylesPage };
@@ -0,0 +1,12 @@
1
+ //#region src/theme.d.ts
2
+ /**
3
+ * Publishes the theming plugin's recipes as a preset, for the stylesheet compiler of an application
4
+ * that renders the theme pages.
5
+ *
6
+ * @remarks
7
+ * Each recipe's class name starts with the plugin's id, and each states every value it offers
8
+ * under `staticCss`, so a product compiles every sample the pages show.
9
+ */
10
+ declare const _default: import("@stealthscale/theme/authoring").Preset;
11
+ //#endregion
12
+ export { _default as default };
package/dist/theme.js ADDED
@@ -0,0 +1,23 @@
1
+ import { a as recipe$1, i as recipe$2, n as recipe$3, o as recipe, t as recipe$4 } from "./theming-text.recipe-Dvcza4j1.js";
2
+ import { definePreset } from "@stealthscale/theme/authoring";
3
+ //#region src/theme.ts
4
+ /**
5
+ * Publishes the theming plugin's recipes as a preset, for the stylesheet compiler of an application
6
+ * that renders the theme pages.
7
+ *
8
+ * @remarks
9
+ * Each recipe's class name starts with the plugin's id, and each states every value it offers
10
+ * under `staticCss`, so a product compiles every sample the pages show.
11
+ */
12
+ var theme_default = definePreset({
13
+ name: "@stealthscale/plugin-theming",
14
+ theme: { extend: { recipes: {
15
+ themingLook: recipe,
16
+ themingMotion: recipe$1,
17
+ themingPanel: recipe$2,
18
+ themingSample: recipe$3,
19
+ themingText: recipe$4
20
+ } } }
21
+ });
22
+ //#endregion
23
+ export { theme_default as default };