@pairdraw/dom-css 0.16.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/behaviours/states/layers.js +27 -1
- package/dist/chunks/behaviours/states/layers.js.map +1 -1
- package/dist/chunks/behaviours/states/tailwind.js +16 -3
- package/dist/chunks/behaviours/states/tailwind.js.map +1 -1
- package/dist/chunks/browser.js +31 -4
- package/dist/chunks/browser.js.map +1 -1
- package/dist/chunks/export/bundle.js +21 -15
- package/dist/chunks/export/bundle.js.map +1 -1
- package/dist/chunks/export/storybook/export.js +1 -1
- package/dist/chunks/export/storybook/export.js.map +1 -1
- package/dist/chunks/import/html.js +103 -44
- package/dist/chunks/import/html.js.map +1 -1
- package/dist/export.d.ts +0 -7
- package/package.json +3 -3
- package/src/export/bundle.ts +24 -22
- package/src/export/html.ts +19 -2
- package/src/export/storybook/export.ts +1 -1
- package/src/import/jsx/core.ts +30 -5
- package/src/import/scene-graph.ts +5 -3
- package/src/runtime/headless/styles.ts +142 -64
- package/src/tokens/stylesheet.ts +42 -2
|
@@ -476,8 +476,15 @@ function modeValue(variable, value, modeId, names, variables) {
|
|
|
476
476
|
function block(selector, declarations, indent = "") {
|
|
477
477
|
return `${indent}${selector} {\n${declarations.map(({ name, value }) => `${indent} --${name}: ${value};`).join("\n")}\n${indent}}`;
|
|
478
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* A comment naming `text`. Collection and mode names are the person's own text, so a `*` before
|
|
481
|
+
* a `/` in them is spaced apart, which keeps a name from ending the comment and writing rules.
|
|
482
|
+
*/
|
|
483
|
+
function cssComment(text) {
|
|
484
|
+
return `/* ${text.replaceAll("*/", "* /")} */`;
|
|
485
|
+
}
|
|
479
486
|
function modeBlock(scope) {
|
|
480
|
-
const comment =
|
|
487
|
+
const comment = cssComment(`${scope.collection.name}: ${scope.mode.name}`);
|
|
481
488
|
if (!isAtRuleCondition(scope.condition)) return `${comment}\n${block(scope.condition, scope.declarations)}`;
|
|
482
489
|
return `${comment}\n${scope.condition} {\n${block(":root", scope.declarations, " ")}\n}`;
|
|
483
490
|
}
|
|
@@ -501,6 +508,24 @@ function variantNames(scopes) {
|
|
|
501
508
|
* references, and number formulas `calc()` over them; both are declared again in each mode that
|
|
502
509
|
* changes what they point to.
|
|
503
510
|
*/
|
|
511
|
+
/**
|
|
512
|
+
* A name that took a numeric suffix is an alias nobody can read back from the stylesheet, so it
|
|
513
|
+
* is reported rather than left as a silent second spelling of another token.
|
|
514
|
+
*/
|
|
515
|
+
function numberedNameIssues(variables, names, modeOf) {
|
|
516
|
+
const issues = [];
|
|
517
|
+
for (const variable of variables) {
|
|
518
|
+
const name = names.get(variable.id);
|
|
519
|
+
const base = deriveCSSName(variable);
|
|
520
|
+
if (!name || explicitCSSName(variable) || name === base) continue;
|
|
521
|
+
issues.push({
|
|
522
|
+
message: `"${variable.name}" is written --${name}: --${base} is taken`,
|
|
523
|
+
variableId: variable.id,
|
|
524
|
+
modeId: modeOf(variable)
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
return issues;
|
|
528
|
+
}
|
|
504
529
|
function buildTokenStylesheet(source, { format, include = () => true }, validate) {
|
|
505
530
|
const issues = [];
|
|
506
531
|
const collections = [...source.variableCollections.values()];
|
|
@@ -532,6 +557,7 @@ function buildTokenStylesheet(source, { format, include = () => true }, validate
|
|
|
532
557
|
value: css
|
|
533
558
|
};
|
|
534
559
|
}
|
|
560
|
+
issues.push(...numberedNameIssues(variables, names, defaultModeOf));
|
|
535
561
|
const defaults = /* @__PURE__ */ new Map();
|
|
536
562
|
const theme = [];
|
|
537
563
|
const root = [];
|