@skriv/ads 0.1.0 → 0.2.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/README.md +5 -3
- package/bin/ads.mjs +1 -1
- package/dist/manifest.json +22 -5
- package/dist/skills/ads-init/SKILL.md +2 -0
- package/dist/skills/ads-init/profile.md +1 -1
- package/dist/skills/heroui-theming/LICENSE.txt +199 -0
- package/dist/skills/heroui-theming/SKILL.md +268 -0
- package/dist/skills/heroui-theming/references/any-framework.md +219 -0
- package/dist/skills/heroui-theming/references/components.md +237 -0
- package/dist/skills/heroui-theming/references/theme-recipe.md +701 -0
- package/dist/skills/heroui-theming/references/tokens.md +258 -0
- package/dist/skills/heroui-theming/scripts/_styles_dir.mjs +112 -0
- package/dist/skills/heroui-theming/scripts/list_component_classes.mjs +319 -0
- package/dist/skills/heroui-theming/scripts/list_tokens.mjs +157 -0
- package/dist/templates/routing.md +2 -0
- package/dist/templates/theming.md +26 -0
- package/package.json +21 -6
- package/src/install.mjs +3 -2
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Inspect the BEM surface of HeroUI components from the INSTALLED `@heroui/styles`
|
|
4
|
+
* (no network), so overrides target selectors that exist in the project's version.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node list_component_classes.mjs # list every component stylesheet
|
|
8
|
+
* node list_component_classes.mjs button # summary for one component
|
|
9
|
+
* node list_component_classes.mjs button switch # several components
|
|
10
|
+
* node list_component_classes.mjs button --css # also print the raw CSS
|
|
11
|
+
* node list_component_classes.mjs button --json # machine-readable output
|
|
12
|
+
* node list_component_classes.mjs --dir <path> # explicit @heroui/styles location
|
|
13
|
+
*
|
|
14
|
+
* The summary lists: blocks, elements, modifiers, state selectors, `data-slot`
|
|
15
|
+
* hooks, component custom properties (with their defaults), and the theme
|
|
16
|
+
* tokens the component reads.
|
|
17
|
+
*/
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
|
|
21
|
+
import {findStylesDir, stripComments, takeDirArg} from "./_styles_dir.mjs";
|
|
22
|
+
|
|
23
|
+
const COLOR_UTILITY_PREFIXES = [
|
|
24
|
+
"bg",
|
|
25
|
+
"text",
|
|
26
|
+
"border",
|
|
27
|
+
"ring",
|
|
28
|
+
"ring-offset",
|
|
29
|
+
"outline",
|
|
30
|
+
"fill",
|
|
31
|
+
"stroke",
|
|
32
|
+
"from",
|
|
33
|
+
"via",
|
|
34
|
+
"to",
|
|
35
|
+
"placeholder",
|
|
36
|
+
"divide",
|
|
37
|
+
"caret",
|
|
38
|
+
"decoration",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const STATE_PSEUDO_CLASSES = new Set([
|
|
42
|
+
"active",
|
|
43
|
+
"autofill",
|
|
44
|
+
"checked",
|
|
45
|
+
"disabled",
|
|
46
|
+
"focus",
|
|
47
|
+
"focus-visible",
|
|
48
|
+
"focus-within",
|
|
49
|
+
"hover",
|
|
50
|
+
"indeterminate",
|
|
51
|
+
"invalid",
|
|
52
|
+
"placeholder-shown",
|
|
53
|
+
"read-only",
|
|
54
|
+
"required",
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
/** `.block`, `.block__element` (elements can nest: `.a__b__c`), and an optional `--modifier`. */
|
|
58
|
+
const NAME = "[a-z0-9]+(?:-[a-z0-9]+)*";
|
|
59
|
+
const CLASS_PATTERN = new RegExp(
|
|
60
|
+
`\\.([a-z][a-z0-9]*(?:-[a-z0-9]+)*)((?:__${NAME})+)?(--${NAME})?(?![\\w-])`,
|
|
61
|
+
"g",
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const toKebab = (name) =>
|
|
65
|
+
name
|
|
66
|
+
.replace(/\.css$/, "")
|
|
67
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
68
|
+
.replace(/[\s_]+/g, "-")
|
|
69
|
+
.toLowerCase();
|
|
70
|
+
|
|
71
|
+
/** Returns every selector prelude (the text right before a `{`), skipping at-rules. */
|
|
72
|
+
const readSelectors = (css) => {
|
|
73
|
+
const selectors = [];
|
|
74
|
+
let start = 0;
|
|
75
|
+
|
|
76
|
+
for (let i = 0; i < css.length; i++) {
|
|
77
|
+
const char = css[i];
|
|
78
|
+
|
|
79
|
+
if (char === ";" || char === "}") {
|
|
80
|
+
start = i + 1;
|
|
81
|
+
} else if (char === "{") {
|
|
82
|
+
const prelude = css.slice(start, i).trim();
|
|
83
|
+
|
|
84
|
+
if (prelude && !prelude.startsWith("@")) selectors.push(prelude.replace(/\s+/g, " "));
|
|
85
|
+
start = i + 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return selectors;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Reads themes/shared/theme.css: which Tailwind theme variable points at which HeroUI token,
|
|
94
|
+
* e.g. `--color-field` -> `--field-background`, `--radius-3xl` -> `--radius`.
|
|
95
|
+
*/
|
|
96
|
+
const readThemeMap = (cssRoot) => {
|
|
97
|
+
const themeCss = stripComments(
|
|
98
|
+
fs.readFileSync(path.join(cssRoot, "themes", "shared", "theme.css"), "utf8"),
|
|
99
|
+
);
|
|
100
|
+
const themeMap = new Map();
|
|
101
|
+
|
|
102
|
+
for (const match of themeCss.matchAll(/(--[\w-]+)\s*:\s*[^;]*?var\(\s*(--[\w-]+)/g)) {
|
|
103
|
+
themeMap.set(match[1], match[2]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const colorNames = [...themeMap.keys()]
|
|
107
|
+
.filter((name) => name.startsWith("--color-"))
|
|
108
|
+
.map((name) => name.slice("--color-".length))
|
|
109
|
+
.sort((a, b) => b.length - a.length);
|
|
110
|
+
|
|
111
|
+
return {colorNames, themeMap};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** HeroUI state utilities (utilities/index.css) and the tokens behind them. */
|
|
115
|
+
const STATUS_UTILITY_TOKENS = {
|
|
116
|
+
"focus-field-ring": ["--focus"],
|
|
117
|
+
"focus-ring": ["--focus", "--ring-offset-width"],
|
|
118
|
+
"invalid-field-ring": ["--danger"],
|
|
119
|
+
scrollbar: ["--scrollbar-width", "--scrollbar-color", "--scrollbar-gutter"],
|
|
120
|
+
"scrollbar-thin": ["--scrollbar-thumb", "--scrollbar-track"],
|
|
121
|
+
"status-disabled": ["--disabled-opacity", "--cursor-disabled"],
|
|
122
|
+
"status-focused": ["--focus", "--ring-offset-width"],
|
|
123
|
+
"status-focused-field": ["--focus"],
|
|
124
|
+
"status-invalid-field": ["--danger"],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const analyze = (css, {colorNames, themeMap}) => {
|
|
128
|
+
const clean = stripComments(css);
|
|
129
|
+
const selectors = readSelectors(clean);
|
|
130
|
+
const blocks = new Map();
|
|
131
|
+
const states = new Set();
|
|
132
|
+
const slots = new Set();
|
|
133
|
+
|
|
134
|
+
const blockEntry = (block) => {
|
|
135
|
+
if (!blocks.has(block)) blocks.set(block, {elements: new Set(), modifiers: new Set()});
|
|
136
|
+
|
|
137
|
+
return blocks.get(block);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
for (const selector of selectors) {
|
|
141
|
+
for (const match of selector.matchAll(CLASS_PATTERN)) {
|
|
142
|
+
const [, block, element, modifier] = match;
|
|
143
|
+
const entry = blockEntry(block);
|
|
144
|
+
|
|
145
|
+
if (element && modifier) entry.modifiers.add(`.${block}${element}${modifier}`);
|
|
146
|
+
else if (element) entry.elements.add(`.${block}${element}`);
|
|
147
|
+
else if (modifier) entry.modifiers.add(`.${block}${modifier}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
for (const match of selector.matchAll(
|
|
151
|
+
/\[((?:data|aria)-[\w-]+)(?:[~|^$*]?=("[^"]*"|[^\]]*))?\]/g,
|
|
152
|
+
)) {
|
|
153
|
+
const [whole, attribute] = match;
|
|
154
|
+
|
|
155
|
+
if (attribute === "data-slot") slots.add(whole);
|
|
156
|
+
else states.add(whole);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
for (const match of selector.matchAll(/:([a-z-]+)/g)) {
|
|
160
|
+
if (STATE_PSEUDO_CLASSES.has(match[1])) states.add(`:${match[1]}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const properties = new Map();
|
|
165
|
+
|
|
166
|
+
for (const match of clean.matchAll(/(?:^|[;{}])\s*(--[\w-]+)\s*:\s*([^;{}]+)/g)) {
|
|
167
|
+
const [, name, value] = match;
|
|
168
|
+
|
|
169
|
+
if (name.startsWith("--tw-")) continue;
|
|
170
|
+
if (!properties.has(name)) properties.set(name, value.replace(/\s+/g, " ").trim());
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const tokens = new Set();
|
|
174
|
+
/** Records the HeroUI token behind a Tailwind theme variable (`--color-field` -> `--field-background`). */
|
|
175
|
+
const addToken = (name) => tokens.add(themeMap.get(name) ?? name);
|
|
176
|
+
|
|
177
|
+
for (const match of clean.matchAll(/var\(\s*(--[\w-]+)/g)) {
|
|
178
|
+
if (!properties.has(match[1]) && !match[1].startsWith("--tw-")) addToken(match[1]);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (const match of clean.matchAll(/@apply\s+([^;]+);/g)) {
|
|
182
|
+
for (const rawUtility of match[1].split(/\s+/)) {
|
|
183
|
+
const utility = rawUtility
|
|
184
|
+
.split(":")
|
|
185
|
+
.pop()
|
|
186
|
+
.replace(/^!|!$/g, "")
|
|
187
|
+
.replace(/\/[\w.[\]%-]+$/, "");
|
|
188
|
+
|
|
189
|
+
if (STATUS_UTILITY_TOKENS[utility]) {
|
|
190
|
+
for (const token of STATUS_UTILITY_TOKENS[utility]) tokens.add(token);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (/^shadow-(surface|overlay|field)$/.test(utility)) {
|
|
194
|
+
addToken(`--${utility}`);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (/^rounded(-[a-z]{1,2})?-(xs|sm|md|lg|xl|2xl|3xl|4xl)$/.test(utility)) {
|
|
198
|
+
tokens.add("--radius");
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (/^rounded(-[a-z]{1,2})?-field$/.test(utility)) {
|
|
202
|
+
addToken("--radius-field");
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
for (const prefix of COLOR_UTILITY_PREFIXES) {
|
|
206
|
+
if (!utility.startsWith(`${prefix}-`)) continue;
|
|
207
|
+
const color = colorNames.find((name) => utility === `${prefix}-${name}`);
|
|
208
|
+
|
|
209
|
+
if (color) addToken(`--color-${color}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
blocks: [...blocks].map(([name, entry]) => ({
|
|
216
|
+
elements: [...entry.elements].sort(),
|
|
217
|
+
modifiers: [...entry.modifiers].sort(),
|
|
218
|
+
name: `.${name}`,
|
|
219
|
+
})),
|
|
220
|
+
customProperties: [...properties].map(([name, value]) => ({name, value})),
|
|
221
|
+
slots: [...slots].sort(),
|
|
222
|
+
states: [...states].sort(),
|
|
223
|
+
tokens: [...tokens].sort(),
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const printList = (title, items) => {
|
|
228
|
+
if (items.length === 0) return;
|
|
229
|
+
console.log(`\n${title}`);
|
|
230
|
+
for (const item of items) console.log(` ${item}`);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const main = () => {
|
|
234
|
+
const {dir, rest} = takeDirArg(process.argv.slice(2));
|
|
235
|
+
const flags = new Set(rest.filter((arg) => arg.startsWith("--")));
|
|
236
|
+
const names = rest.filter((arg) => !arg.startsWith("--")).map(toKebab);
|
|
237
|
+
|
|
238
|
+
const {cssRoot, version} = findStylesDir(dir);
|
|
239
|
+
const componentsDir = path.join(cssRoot, "components");
|
|
240
|
+
const available = fs
|
|
241
|
+
.readdirSync(componentsDir)
|
|
242
|
+
.filter((file) => file.endsWith(".css") && file !== "index.css")
|
|
243
|
+
.map((file) => file.replace(/\.css$/, ""))
|
|
244
|
+
.sort();
|
|
245
|
+
|
|
246
|
+
if (names.length === 0) {
|
|
247
|
+
console.log(`# @heroui/styles ${version}`);
|
|
248
|
+
console.log(`# ${componentsDir}`);
|
|
249
|
+
console.log(`# ${available.length} component stylesheets\n`);
|
|
250
|
+
console.log(available.join("\n"));
|
|
251
|
+
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const theme = readThemeMap(cssRoot);
|
|
256
|
+
const results = [];
|
|
257
|
+
|
|
258
|
+
for (const name of names) {
|
|
259
|
+
if (!available.includes(name)) {
|
|
260
|
+
const hints = available.filter((item) => item.includes(name) || name.includes(item));
|
|
261
|
+
|
|
262
|
+
console.error(
|
|
263
|
+
`# No stylesheet for "${name}".` +
|
|
264
|
+
(hints.length
|
|
265
|
+
? ` Did you mean: ${hints.join(", ")}?`
|
|
266
|
+
: " Run without arguments to list all."),
|
|
267
|
+
);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const file = path.join(componentsDir, `${name}.css`);
|
|
272
|
+
const css = fs.readFileSync(file, "utf8");
|
|
273
|
+
|
|
274
|
+
results.push({component: name, file, ...analyze(css, theme), css});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (flags.has("--json")) {
|
|
278
|
+
const payload = results.map(({css, ...result}) =>
|
|
279
|
+
flags.has("--css") ? {...result, css} : result,
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
console.log(JSON.stringify({components: payload, version}, null, 2));
|
|
283
|
+
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
for (const result of results) {
|
|
288
|
+
console.log(`\n# ${result.component} (@heroui/styles ${version})`);
|
|
289
|
+
console.log(`# ${result.file}`);
|
|
290
|
+
|
|
291
|
+
for (const block of result.blocks) {
|
|
292
|
+
console.log(`\nBlock ${block.name}`);
|
|
293
|
+
if (block.elements.length) console.log(` elements: ${block.elements.join(" ")}`);
|
|
294
|
+
if (block.modifiers.length) console.log(` modifiers: ${block.modifiers.join(" ")}`);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
printList("State selectors (style the pseudo-class AND the data attribute)", result.states);
|
|
298
|
+
printList("data-slot hooks", result.slots);
|
|
299
|
+
printList(
|
|
300
|
+
"Component custom properties (set them on the component class, not on :root)",
|
|
301
|
+
result.customProperties.map((property) => `${property.name}: ${property.value}`),
|
|
302
|
+
);
|
|
303
|
+
printList("Theme tokens read by this component", result.tokens);
|
|
304
|
+
|
|
305
|
+
if (flags.has("--css")) {
|
|
306
|
+
console.log("\n/* ---- source ---- */");
|
|
307
|
+
console.log(result.css);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (results.length === 0) process.exit(1);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
main();
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.error(`Error: ${error.message}`);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* List the theme tokens of the INSTALLED `@heroui/styles` (no network).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node list_tokens.mjs # every block: shared, light, dark + Tailwind mapping
|
|
7
|
+
* node list_tokens.mjs --mode dark # only the dark block
|
|
8
|
+
* node list_tokens.mjs --names # token names only, one per line (deduplicated)
|
|
9
|
+
* node list_tokens.mjs --json # machine-readable output
|
|
10
|
+
* node list_tokens.mjs --dir <path> # explicit @heroui/styles location
|
|
11
|
+
*
|
|
12
|
+
* Reads `themes/default/variables.css` (token values per mode) and
|
|
13
|
+
* `themes/shared/theme.css` (token -> Tailwind theme variable mapping).
|
|
14
|
+
*/
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
|
|
18
|
+
import {findStylesDir, stripComments, takeDirArg} from "./_styles_dir.mjs";
|
|
19
|
+
|
|
20
|
+
/** Splits `css` into top-level `{selector, body}` rules, descending into at-rules. */
|
|
21
|
+
const readRules = (css) => {
|
|
22
|
+
const rules = [];
|
|
23
|
+
let depth = 0;
|
|
24
|
+
let start = 0;
|
|
25
|
+
let prelude = "";
|
|
26
|
+
let bodyStart = 0;
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < css.length; i++) {
|
|
29
|
+
const char = css[i];
|
|
30
|
+
|
|
31
|
+
if (char === "{") {
|
|
32
|
+
if (depth === 0) {
|
|
33
|
+
prelude = css.slice(start, i).trim();
|
|
34
|
+
bodyStart = i + 1;
|
|
35
|
+
}
|
|
36
|
+
depth++;
|
|
37
|
+
} else if (char === "}") {
|
|
38
|
+
depth--;
|
|
39
|
+
if (depth === 0) {
|
|
40
|
+
const body = css.slice(bodyStart, i);
|
|
41
|
+
|
|
42
|
+
if (prelude.startsWith("@layer") || prelude.startsWith("@media")) {
|
|
43
|
+
rules.push(...readRules(body));
|
|
44
|
+
} else {
|
|
45
|
+
rules.push({body, selector: prelude.replace(/\s+/g, " ")});
|
|
46
|
+
}
|
|
47
|
+
start = i + 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return rules;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Reads `--name: value;` declarations at the top level of a rule body. */
|
|
56
|
+
const readDeclarations = (body) => {
|
|
57
|
+
const declarations = [];
|
|
58
|
+
let depth = 0;
|
|
59
|
+
let current = "";
|
|
60
|
+
|
|
61
|
+
for (const char of body) {
|
|
62
|
+
if (char === "{") depth++;
|
|
63
|
+
if (char === "}") {
|
|
64
|
+
depth--;
|
|
65
|
+
current = "";
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (depth > 0) continue;
|
|
69
|
+
if (char === ";") {
|
|
70
|
+
const match = current.match(/^\s*(--[\w-]+)\s*:\s*([\s\S]+)$/);
|
|
71
|
+
|
|
72
|
+
if (match) declarations.push({name: match[1], value: match[2].replace(/\s+/g, " ").trim()});
|
|
73
|
+
current = "";
|
|
74
|
+
} else {
|
|
75
|
+
current += char;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return declarations;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const modeOf = (selector) => {
|
|
83
|
+
if (selector.startsWith("@theme")) return "tailwind";
|
|
84
|
+
if (selector.includes("data-vibrant-palette")) return "vibrant";
|
|
85
|
+
if (/\.dark|data-theme="dark"/.test(selector)) return "dark";
|
|
86
|
+
if (/\.light|data-theme="light"/.test(selector)) return "light";
|
|
87
|
+
|
|
88
|
+
return "shared";
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const main = () => {
|
|
92
|
+
const {dir, rest} = takeDirArg(process.argv.slice(2));
|
|
93
|
+
const asJson = rest.includes("--json");
|
|
94
|
+
const namesOnly = rest.includes("--names");
|
|
95
|
+
const modeIndex = rest.indexOf("--mode");
|
|
96
|
+
const onlyMode = modeIndex === -1 ? null : rest[modeIndex + 1];
|
|
97
|
+
|
|
98
|
+
const {cssRoot, version} = findStylesDir(dir);
|
|
99
|
+
const variablesPath = path.join(cssRoot, "themes", "default", "variables.css");
|
|
100
|
+
const themePath = path.join(cssRoot, "themes", "shared", "theme.css");
|
|
101
|
+
|
|
102
|
+
const blocks = [];
|
|
103
|
+
|
|
104
|
+
for (const file of [variablesPath, themePath]) {
|
|
105
|
+
for (const rule of readRules(stripComments(fs.readFileSync(file, "utf8")))) {
|
|
106
|
+
const mode = modeOf(rule.selector);
|
|
107
|
+
|
|
108
|
+
if (mode === "vibrant") continue;
|
|
109
|
+
const existing = blocks.find((block) => block.mode === mode);
|
|
110
|
+
const tokens = readDeclarations(rule.body);
|
|
111
|
+
|
|
112
|
+
if (existing) existing.tokens.push(...tokens);
|
|
113
|
+
else blocks.push({mode, selector: rule.selector, tokens});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const selected = onlyMode ? blocks.filter((block) => block.mode === onlyMode) : blocks;
|
|
118
|
+
|
|
119
|
+
if (asJson) {
|
|
120
|
+
console.log(JSON.stringify({blocks: selected, cssRoot, version}, null, 2));
|
|
121
|
+
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (namesOnly) {
|
|
126
|
+
const names = new Set(selected.flatMap((block) => block.tokens.map((token) => token.name)));
|
|
127
|
+
|
|
128
|
+
console.log([...names].join("\n"));
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`/* @heroui/styles ${version} */`);
|
|
134
|
+
console.log(`/* ${variablesPath} */`);
|
|
135
|
+
console.log(`/* ${themePath} */`);
|
|
136
|
+
|
|
137
|
+
const titles = {
|
|
138
|
+
dark: "Dark mode tokens",
|
|
139
|
+
light: "Light mode tokens",
|
|
140
|
+
shared: "Shared tokens (same in every mode)",
|
|
141
|
+
tailwind: "Tailwind mapping (@theme inline): theme variable -> HeroUI token",
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
for (const block of selected) {
|
|
145
|
+
console.log(`\n/* ${titles[block.mode]} */`);
|
|
146
|
+
console.log(`${block.selector} {`);
|
|
147
|
+
for (const token of block.tokens) console.log(` ${token.name}: ${token.value};`);
|
|
148
|
+
console.log("}");
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
main();
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error(`Error: ${error.message}`);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
@@ -6,4 +6,6 @@ Maintain the affected flow's English behavior contract and stable scenario IDs w
|
|
|
6
6
|
|
|
7
7
|
Use ads-record for a separately requested walkthrough; use ads-code-review to verify integrated behavior. Use ads-figma-to-code for supplied Figma designs and ads-code-to-figma for editable Figma components or flows. Run local tools for the user. Recordings use synthetic input. Post results externally only when requested.
|
|
8
8
|
|
|
9
|
+
For HeroUI projects, use heroui-react to build interfaces and heroui-theming for explicitly requested global restyling or themes. Read tokens and component selectors from the installed @heroui/styles. Keep new token approval with the designer; allow literal definitions only in explicitly approved files and selectors recorded in the project profile. Component overrides, slots and states must use approved tokens. When installed, docs/ads/templates/theming.md explains the ADS integration and checks. Verify both modes, keyboard focus and reduced motion after a theme change.
|
|
10
|
+
|
|
9
11
|
The installed package version and file hashes are in .ads/install.json. To upgrade the bundle use `npx @skriv/ads@latest update`; reconcile reported local changes before retrying. Use `npx @skriv/ads@latest doctor` to check setup. Templates are in docs/ads/templates/.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# HeroUI theming in ADS
|
|
2
|
+
|
|
3
|
+
Use heroui-theming for an explicitly requested global visual change or named theme; use heroui-react to build interfaces. Preserve the target project's UI library and installed version. Custom styling and new tokens follow its designer-approval rules. The skill's examples illustrate HeroUI mechanics; raw visual values in example component overrides still need approved tokens under ADS.
|
|
4
|
+
|
|
5
|
+
## Inspect the installed library
|
|
6
|
+
|
|
7
|
+
From the app root, run the installed skill's scripts by their actual paths:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
node .agents/skills/heroui-theming/scripts/list_tokens.mjs --json
|
|
11
|
+
node .agents/skills/heroui-theming/scripts/list_component_classes.mjs button --json
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
In monorepos use the app working directory with an absolute skill-script path, or pass --dir pointing to that app's @heroui/styles package. These tools read local CSS and do not change node_modules. Install dependencies through the project's existing workflow if needed.
|
|
15
|
+
|
|
16
|
+
## Definition sites and component overrides
|
|
17
|
+
|
|
18
|
+
Record the approved theme-definition files, exact theme selectors, entry import and token-check command in docs/ads/project.md. A named theme can use src/themes/<name>/variables.css plus component override files as described in the upstream recipe. Approve the definition site and any new tokens before adding them. Import the theme after HeroUI, use the prescribed cascade layers and activate it on html, including portaled overlays.
|
|
19
|
+
|
|
20
|
+
The reference ADS lab's checker reads docs/ads/token-sources.json. Each source names an exact repository-relative CSS file and the individual theme selectors where token values may be defined. @theme definitions are allowed in listed files too. For example, after approving a theme, append its variables.css with .brand-light, [data-theme="brand-light"], .brand-dark and [data-theme="brand-dark"] as its selectors. This is a configuration format for the reference checker, not an instruction to replace another project's existing token tooling.
|
|
21
|
+
|
|
22
|
+
Imports and a themes/ folder name grant no exemption. In an approved file only custom-property definitions in the approved theme scopes can contain raw visual values. Other declarations and component rules remain checked; component overrides reference the approved tokens. Unknown var() references still fail, including aliases inside definitions. Existing project profiles and theme decisions survive npm updates.
|
|
23
|
+
|
|
24
|
+
## Verification
|
|
25
|
+
|
|
26
|
+
Run the project's token gate and production CSS build. Then exercise changed components and consuming flows in light and dark modes: rest, hover, pressed, invalid, disabled, keyboard focus, overlays and reduced motion as applicable. Keep foreground pairs readable. Update DESIGN.md and the profile to reflect approved visual changes. Maintain behavior contracts when an agreed behavior requirement changes; a visual theme alone does not authorize business behavior changes.
|
package/package.json
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skriv/ads",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Project-local Agentic Design System skills, onboarding and diagnostics",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
|
-
"engines": {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"ads": "bin/ads.mjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/",
|
|
15
|
+
"src/",
|
|
16
|
+
"dist/",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/skriv/ADS.git",
|
|
25
|
+
"directory": "packages/ads"
|
|
26
|
+
},
|
|
12
27
|
"scripts": {
|
|
13
28
|
"build": "node scripts/build.mjs",
|
|
14
29
|
"test": "node --test test/install.test.mjs",
|
package/src/install.mjs
CHANGED
|
@@ -91,12 +91,13 @@ export function install({ target, command = 'init', withHeroUI = false, dryRun =
|
|
|
91
91
|
if (compare(state.version, manifest.version) > 0) throw new Error(`Installed ${state.version} is newer than this bundle (${manifest.version}). Use @latest.`);
|
|
92
92
|
}
|
|
93
93
|
const skills = [...manifest.skills];
|
|
94
|
-
|
|
94
|
+
const heroUISkills = manifest.skillGroups?.heroui ?? ['heroui-react'];
|
|
95
|
+
if (withHeroUI || state?.skills.some(skill => heroUISkills.includes(skill)) || detectHeroUI(root)) skills.push(...heroUISkills);
|
|
95
96
|
const desired = new Map();
|
|
96
97
|
for (const relative of Object.keys(manifest.files)) {
|
|
97
98
|
if (relative.startsWith('skills/') && skills.includes(relative.split('/')[1])) {
|
|
98
99
|
desired.set(`.agents/${relative}`, fs.readFileSync(safePath(source, relative)));
|
|
99
|
-
} else if (['templates/flow.md', 'templates/review.md'].includes(relative)) {
|
|
100
|
+
} else if (['templates/flow.md', 'templates/review.md'].includes(relative) || relative === 'templates/theming.md' && skills.includes('heroui-theming')) {
|
|
100
101
|
desired.set(`docs/ads/${relative}`, fs.readFileSync(safePath(source, relative)));
|
|
101
102
|
}
|
|
102
103
|
}
|