@texturehq/edges 1.34.0 → 1.34.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/dist/styles.css +1226 -0
- package/package.json +5 -4
- package/scripts/generate-color-utilities.mjs +163 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@texturehq/edges",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"author": "Nicholas Brown <nick@texturehq.com>",
|
|
5
5
|
"description": "A shared component library for Texture",
|
|
6
6
|
"type": "module",
|
|
@@ -44,10 +44,11 @@
|
|
|
44
44
|
"./prose.css": "./dist/prose.css"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"dev": "yarn watch",
|
|
47
|
+
"dev": "yarn build:pre && yarn watch",
|
|
48
48
|
"watch": "tsup --watch",
|
|
49
|
-
"build": "tsup && yarn build:post",
|
|
50
|
-
"build:
|
|
49
|
+
"build": "yarn build:pre && tsup && yarn build:post",
|
|
50
|
+
"build:pre": "node scripts/generate-color-utilities.mjs",
|
|
51
|
+
"build:post": "node scripts/copy-assets.js",
|
|
51
52
|
"build:yalc": "yarn build && npx yalc publish && npx yalc push",
|
|
52
53
|
"dev:yalc": "yarn build && npx yalc publish && npx yalc push && echo 'Package updated! Run in target project: yarn install && yarn dev'",
|
|
53
54
|
"dev:yalc:force": "yarn build && npx yalc publish && npx yalc push && echo 'Package updated! Run in target project: rm -rf .vite && yarn cache clean && yarn dev --force'",
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generates `src/styles/generated-color-utilities.css` — a single
|
|
5
|
+
* `@source inline(...)` block that guarantees every color token in
|
|
6
|
+
* `@texturehq/edges-tokens` has its appropriate Tailwind utility class
|
|
7
|
+
* shipped in the compiled `dist/styles.css`.
|
|
8
|
+
*
|
|
9
|
+
* Without this, Tailwind v4's content-scan would only emit utilities
|
|
10
|
+
* for the subset of color tokens actually referenced in `packages/edges/src`,
|
|
11
|
+
* leaving consumers of the prebuilt CSS (apps that don't run Tailwind
|
|
12
|
+
* themselves) unable to use the rest of the token set — even though the
|
|
13
|
+
* underlying CSS variables are present in the shipped theme.
|
|
14
|
+
*
|
|
15
|
+
* Token name → utility mapping (by prefix):
|
|
16
|
+
* text-* → text-{token}
|
|
17
|
+
* border-* → border-{token}
|
|
18
|
+
* background-* → bg-{token}
|
|
19
|
+
* input-background-* → bg-{token}
|
|
20
|
+
* scrim-*, skeleton-* → bg-{token}
|
|
21
|
+
* feedback-*-background → bg-{token}
|
|
22
|
+
* feedback-*-border → border-{token}
|
|
23
|
+
* feedback-*-text → text-{token}
|
|
24
|
+
* state-*-border → border-{token}
|
|
25
|
+
* state-*-text → text-{token}
|
|
26
|
+
* state-*-data → (skipped — consumed via CSS var directly)
|
|
27
|
+
* state-* (other) → bg-{token} + text-{token}
|
|
28
|
+
* action-*-text → text-{token}
|
|
29
|
+
* action-*-hover → bg-{token}
|
|
30
|
+
* action-* (other) → bg-{token} + text-{token}
|
|
31
|
+
* map-*-border → border-{token}
|
|
32
|
+
* map-* → bg-{token}
|
|
33
|
+
* viz-* → bg-{token} + text-{token}
|
|
34
|
+
* color primitives (gray-/iris-/ocean-/etc., black/white/graphite/ink/linen/paper)
|
|
35
|
+
* → bg-, text-, border- (all three)
|
|
36
|
+
*
|
|
37
|
+
* Token names that don't match any rule above are skipped with a warning so
|
|
38
|
+
* a maintainer can decide whether to extend the mapping.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
import fs from "node:fs";
|
|
42
|
+
import path from "node:path";
|
|
43
|
+
import { fileURLToPath } from "node:url";
|
|
44
|
+
|
|
45
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
46
|
+
const PKG_ROOT = path.resolve(__dirname, "..");
|
|
47
|
+
|
|
48
|
+
const TOKENS_PATH = path.resolve(PKG_ROOT, "../edges-tokens/dist/tokens.json");
|
|
49
|
+
const OUTPUT_PATH = path.resolve(PKG_ROOT, "src/generated/color-utilities.css");
|
|
50
|
+
|
|
51
|
+
const PRIMITIVES = new Set(["black", "white", "graphite", "ink", "linen", "paper"]);
|
|
52
|
+
const PALETTE_PREFIXES = ["gray-", "iris-", "moss-", "ocean-", "rose-", "honey-", "canary-", "plum-"];
|
|
53
|
+
const SEMANTIC_BASE_NAMES = new Set([
|
|
54
|
+
"error-light",
|
|
55
|
+
"error-base",
|
|
56
|
+
"error-dark",
|
|
57
|
+
"warning-light",
|
|
58
|
+
"warning-base",
|
|
59
|
+
"warning-dark",
|
|
60
|
+
"success-light",
|
|
61
|
+
"success-base",
|
|
62
|
+
"success-dark",
|
|
63
|
+
"info-light",
|
|
64
|
+
"info-base",
|
|
65
|
+
"info-dark",
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
function classify(token) {
|
|
69
|
+
if (token === "paper-border") return ["border"];
|
|
70
|
+
if (token.startsWith("text-")) return ["text"];
|
|
71
|
+
if (token.startsWith("border-")) return ["border"];
|
|
72
|
+
if (token.startsWith("background-")) return ["bg"];
|
|
73
|
+
if (token.startsWith("input-background-")) return ["bg"];
|
|
74
|
+
if (token.startsWith("scrim-") || token.startsWith("skeleton-")) return ["bg"];
|
|
75
|
+
|
|
76
|
+
if (token.startsWith("feedback-")) {
|
|
77
|
+
if (token.endsWith("-background")) return ["bg"];
|
|
78
|
+
if (token.endsWith("-border")) return ["border"];
|
|
79
|
+
if (token.endsWith("-text")) return ["text"];
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (token.startsWith("state-")) {
|
|
84
|
+
if (token.endsWith("-border")) return ["border"];
|
|
85
|
+
if (token.endsWith("-text")) return ["text"];
|
|
86
|
+
if (token.endsWith("-data")) return [];
|
|
87
|
+
return ["bg", "text"];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (token.startsWith("action-")) {
|
|
91
|
+
if (token.endsWith("-text")) return ["text"];
|
|
92
|
+
if (token.endsWith("-hover")) return ["bg"];
|
|
93
|
+
return ["bg", "text"];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (token.startsWith("map-")) {
|
|
97
|
+
if (token.endsWith("-border")) return ["border"];
|
|
98
|
+
return ["bg"];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (token.startsWith("viz-")) return ["bg", "text"];
|
|
102
|
+
|
|
103
|
+
if (PRIMITIVES.has(token)) return ["bg", "text", "border"];
|
|
104
|
+
if (PALETTE_PREFIXES.some((p) => token.startsWith(p))) return ["bg", "text", "border"];
|
|
105
|
+
if (SEMANTIC_BASE_NAMES.has(token)) return ["bg", "text", "border"];
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const tokensRaw = JSON.parse(fs.readFileSync(TOKENS_PATH, "utf8"));
|
|
111
|
+
const colorTokens = Object.keys(tokensRaw)
|
|
112
|
+
.filter((k) => k.startsWith("color-"))
|
|
113
|
+
.map((k) => k.slice("color-".length))
|
|
114
|
+
.sort();
|
|
115
|
+
|
|
116
|
+
const classes = new Set();
|
|
117
|
+
const unmatched = [];
|
|
118
|
+
|
|
119
|
+
for (const token of colorTokens) {
|
|
120
|
+
const prefixes = classify(token);
|
|
121
|
+
if (prefixes === null) {
|
|
122
|
+
unmatched.push(token);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
for (const prefix of prefixes) {
|
|
126
|
+
classes.add(`${prefix}-${token}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const sorted = Array.from(classes).sort();
|
|
131
|
+
|
|
132
|
+
const banner = `/**
|
|
133
|
+
* GENERATED FILE — DO NOT EDIT BY HAND.
|
|
134
|
+
*
|
|
135
|
+
* Source: scripts/generate-color-utilities.mjs
|
|
136
|
+
* Inputs: ../edges-tokens/dist/tokens.json
|
|
137
|
+
* Tokens: ${colorTokens.length} color tokens → ${sorted.length} utility classes
|
|
138
|
+
*
|
|
139
|
+
* Forces Tailwind to ship a utility for every color token in the design
|
|
140
|
+
* system, regardless of whether it's referenced in this package's source.
|
|
141
|
+
* Apps that consume the prebuilt dist/styles.css get the full token set.
|
|
142
|
+
*
|
|
143
|
+
* To regenerate: \`yarn build\` (runs this script as build:pre, before tsup).
|
|
144
|
+
*/
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
const sourceBlock = `@source inline("${sorted.join(" ")}");\n`;
|
|
148
|
+
|
|
149
|
+
fs.mkdirSync(path.dirname(OUTPUT_PATH), { recursive: true });
|
|
150
|
+
fs.writeFileSync(OUTPUT_PATH, `${banner}\n${sourceBlock}`);
|
|
151
|
+
|
|
152
|
+
console.log(`✅ Wrote ${sorted.length} color utilities to ${path.relative(PKG_ROOT, OUTPUT_PATH)}`);
|
|
153
|
+
|
|
154
|
+
if (unmatched.length > 0) {
|
|
155
|
+
console.error("");
|
|
156
|
+
console.error(`❌ ${unmatched.length} color tokens did not match any classification rule:`);
|
|
157
|
+
for (const t of unmatched) console.error(` - color-${t}`);
|
|
158
|
+
console.error("");
|
|
159
|
+
console.error(" Every color token must map to at least one utility (or be explicitly");
|
|
160
|
+
console.error(" skipped by returning []). Extend the rules in classify() in");
|
|
161
|
+
console.error(" scripts/generate-color-utilities.mjs so this PR's contract holds.");
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|