clampography 2.0.0-beta.8 → 2.0.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 +20 -20
- package/README.md +76 -47
- package/css/base.css +501 -0
- package/css/base.min.css +1 -0
- package/css/clampography.css +1050 -0
- package/css/clampography.min.css +1 -0
- package/css/extra.css +189 -0
- package/css/extra.min.css +1 -0
- package/css/figma-tokens.json +110 -0
- package/css/forms.css +244 -0
- package/css/forms.min.css +1 -0
- package/css/kbd.css +28 -0
- package/css/kbd.min.css +1 -0
- package/css/theme.css +73 -0
- package/css/theme.min.css +1 -0
- package/package.json +42 -22
- package/src/base.js +626 -460
- package/src/convert.js +285 -0
- package/src/export-figma.js +89 -0
- package/src/export-types.js +39 -0
- package/src/extra.js +256 -137
- package/src/forms.js +298 -0
- package/src/index.js +249 -90
- package/src/kbd.js +88 -0
- package/src/print.js +92 -0
- package/src/theme-plugin.js +68 -14
- package/src/theme.js +34 -0
- package/src/themes.js +43 -48
- package/src/types/index.d.ts +24 -0
- package/src/types/theme-plugin.d.ts +32 -0
- package/src/types/themes.d.ts +28 -0
- package/src/types/vars.d.ts +68 -0
- package/src/base.css +0 -535
package/src/extra.js
CHANGED
|
@@ -1,138 +1,257 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
|
|
1
|
+
export default (options = {}) => {
|
|
2
|
+
const root = options.root || ":root";
|
|
3
|
+
|
|
4
|
+
// Helper to scope selectors safely
|
|
5
|
+
const scope = (selector) => {
|
|
6
|
+
const parts = [];
|
|
7
|
+
let current = "";
|
|
8
|
+
let depth = 0;
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < selector.length; i++) {
|
|
11
|
+
const char = selector[i];
|
|
12
|
+
if (char === "(") depth++;
|
|
13
|
+
if (char === ")") depth--;
|
|
14
|
+
|
|
15
|
+
if (char === "," && depth === 0) {
|
|
16
|
+
parts.push(current.trim());
|
|
17
|
+
current = "";
|
|
18
|
+
} else {
|
|
19
|
+
current += char;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
parts.push(current.trim());
|
|
23
|
+
|
|
24
|
+
const typographyPrefix = options.typography && options.typography !== "global" ? ` ${options.typography}` : "";
|
|
25
|
+
|
|
26
|
+
return parts
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.map((part) => {
|
|
29
|
+
if (part === ":root" || part === "body") return root;
|
|
30
|
+
if (typographyPrefix) {
|
|
31
|
+
return `${root}${typographyPrefix} ${part}`;
|
|
32
|
+
}
|
|
33
|
+
return `${root} ${part}`;
|
|
34
|
+
})
|
|
35
|
+
.join(", ");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
// Transition duration token — drives smooth color changes when the theme changes.
|
|
40
|
+
// Scoped here (not in base.js) because transitions are an extra.js concern.
|
|
41
|
+
// Users can override: :root { --clampography-transition-duration: 0ms; } to disable.
|
|
42
|
+
[`:where(${root})`]: {
|
|
43
|
+
"--clampography-transition-duration": "200ms",
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// --- Basic Coloring & Font (with user-font priority) ---
|
|
47
|
+
[(() => {
|
|
48
|
+
const typographyPrefix = options.typography && options.typography !== "global" ? ` ${options.typography}` : "";
|
|
49
|
+
const bodyBase = root === ":root" ? "body" : root;
|
|
50
|
+
return typographyPrefix ? `${bodyBase}${typographyPrefix}` : bodyBase;
|
|
51
|
+
})()]: {
|
|
52
|
+
"background-color": "var(--clampography-background)",
|
|
53
|
+
"color": "var(--clampography-text)",
|
|
54
|
+
// --font-sans is Tailwind v4's way to expose the user's font choice.
|
|
55
|
+
// If the user sets a font in their project, it wins. If not, fallback to clampography's system stack.
|
|
56
|
+
"font-family": "var(--font-sans, var(--clampography-font-base))",
|
|
57
|
+
// Smooth theme transitions: all color CSS variables animate when data-theme changes.
|
|
58
|
+
// Duration is driven by the token set in base.js (default 200ms).
|
|
59
|
+
// Automatically disabled by the prefers-reduced-motion media query in base.js.
|
|
60
|
+
"transition-property": "color, background-color, border-color, text-decoration-color, fill, stroke",
|
|
61
|
+
"transition-duration": "var(--clampography-transition-duration, 200ms)",
|
|
62
|
+
"transition-timing-function": "ease",
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
[scope(":where(h1, h2, h3, h4, h5, h6)")]: {
|
|
66
|
+
"color": "var(--clampography-heading)",
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Styled Links
|
|
70
|
+
[scope("a")]: {
|
|
71
|
+
"color": "var(--clampography-link)",
|
|
72
|
+
"font-weight": "600",
|
|
73
|
+
"letter-spacing": "0.025em",
|
|
74
|
+
"text-decoration-line": "underline",
|
|
75
|
+
"text-decoration-thickness": "2px",
|
|
76
|
+
"text-underline-offset": "4px",
|
|
77
|
+
"text-decoration-color":
|
|
78
|
+
"color-mix(in oklab, var(--clampography-link) 30%, transparent)",
|
|
79
|
+
"transition-property": "color, text-decoration-color",
|
|
80
|
+
"transition-duration": "150ms",
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
[scope("a:hover")]: {
|
|
84
|
+
"text-decoration-color": "var(--clampography-link)",
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
// Lists
|
|
88
|
+
[scope("ul > li::before")]: {
|
|
89
|
+
"background-color": "var(--clampography-primary)",
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
[scope("ol > li::before")]: {
|
|
93
|
+
"color": "var(--clampography-primary)",
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// Inline Code
|
|
97
|
+
[scope(":where(code:not(pre code), kbd, samp)")]: {
|
|
98
|
+
"background-color": "var(--clampography-surface)",
|
|
99
|
+
"color": "var(--clampography-heading)",
|
|
100
|
+
"border": "1px solid var(--clampography-border)",
|
|
101
|
+
"border-radius": "0.25rem",
|
|
102
|
+
"padding": "0.125rem var(--clampography-spacing-xs)",
|
|
103
|
+
"white-space": "nowrap",
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
[scope("kbd")]: {
|
|
107
|
+
transform: "translateY(-0.15em)",
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// Preformatted Code Blocks
|
|
111
|
+
[scope("pre")]: {
|
|
112
|
+
"background-color": "var(--clampography-surface)",
|
|
113
|
+
"border": "1px solid var(--clampography-border)",
|
|
114
|
+
"border-radius": "0.375rem",
|
|
115
|
+
"padding": "var(--clampography-spacing-md)",
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// Tables
|
|
119
|
+
[scope("table")]: {
|
|
120
|
+
"padding": "var(--clampography-spacing-sm)",
|
|
121
|
+
"border": "1px solid var(--clampography-border)",
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
[scope("th")]: {
|
|
125
|
+
"color": "var(--clampography-heading)",
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
[scope("th, td")]: {
|
|
129
|
+
"border": "1px solid var(--clampography-border)",
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
[scope("thead th")]: {
|
|
133
|
+
"border-bottom-width": "2px",
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
[scope("tbody tr:nth-child(even)")]: {
|
|
137
|
+
"background-color": "var(--clampography-surface)",
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
// Captions & Muted
|
|
141
|
+
[scope("caption, figcaption, .muted")]: {
|
|
142
|
+
"color": "var(--clampography-muted)",
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Horizontal Rule
|
|
146
|
+
[scope("hr")]: {
|
|
147
|
+
"height": "1px",
|
|
148
|
+
"border-width": "0",
|
|
149
|
+
"margin-top": "var(--clampography-spacing-xl)",
|
|
150
|
+
"margin-bottom": "var(--clampography-spacing-xl)",
|
|
151
|
+
"background-color": "var(--clampography-border)",
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
// Blockquote
|
|
155
|
+
[scope("blockquote")]: {
|
|
156
|
+
"border-inline-start-width": "4px",
|
|
157
|
+
"border-inline-start-color": "var(--clampography-primary)",
|
|
158
|
+
"background-color": "var(--clampography-surface)",
|
|
159
|
+
"padding": "var(--clampography-spacing-md)",
|
|
160
|
+
"border-radius": "0.25rem",
|
|
161
|
+
"font-style": "italic",
|
|
162
|
+
"color": "var(--clampography-heading)",
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// Mark
|
|
166
|
+
[scope("mark")]: {
|
|
167
|
+
"background-color": "var(--clampography-primary)",
|
|
168
|
+
"color": "var(--clampography-background)",
|
|
169
|
+
"padding": "0.125rem var(--clampography-spacing-xs)",
|
|
170
|
+
"border-radius": "0.25rem",
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// Deleted Text
|
|
174
|
+
[scope("del")]: {
|
|
175
|
+
"text-decoration-color": "var(--clampography-error)",
|
|
176
|
+
"text-decoration-thickness": "2px",
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
// Details
|
|
180
|
+
[scope("details")]: {
|
|
181
|
+
"border": "1px solid var(--clampography-border)",
|
|
182
|
+
"border-radius": "0.375rem",
|
|
183
|
+
"padding": "var(--clampography-spacing-sm)",
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
[scope("summary")]: {
|
|
187
|
+
"color": "var(--clampography-heading)",
|
|
188
|
+
"border-bottom": "0px solid var(--clampography-border)",
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
[scope("details[open] > summary")]: {
|
|
192
|
+
"border-bottom-width": "1px",
|
|
193
|
+
"padding-bottom": "var(--clampography-spacing-sm)",
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// ACCESSIBILITY: Disable all transitions for users who prefer reduced motion.
|
|
197
|
+
// Respects the OS-level "Reduce Motion" setting on macOS, Windows, iOS, and Android.
|
|
198
|
+
// Placed here (not in base.js) because it targets the transitions added above.
|
|
199
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
200
|
+
[(() => {
|
|
201
|
+
const typographyPrefix = options.typography && options.typography !== "global" ? ` ${options.typography}` : "";
|
|
202
|
+
const bodyBase = root === ":root" ? "body" : root;
|
|
203
|
+
return typographyPrefix ? `${bodyBase}${typographyPrefix}` : bodyBase;
|
|
204
|
+
})()]: {
|
|
205
|
+
"transition": "none",
|
|
206
|
+
"--clampography-transition-duration": "0ms",
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// ACCESSIBILITY: High-contrast mode for users who need maximum legibility.
|
|
211
|
+
// Triggered automatically by the OS "Increase Contrast" setting on macOS,
|
|
212
|
+
// Windows High Contrast Mode, or Android's Accessibility settings.
|
|
213
|
+
"@media (prefers-contrast: more)": {
|
|
214
|
+
[(() => {
|
|
215
|
+
const typographyPrefix = options.typography && options.typography !== "global" ? ` ${options.typography}` : "";
|
|
216
|
+
const bodyBase = root === ":root" ? "body" : root;
|
|
217
|
+
return typographyPrefix ? `${bodyBase}${typographyPrefix}` : bodyBase;
|
|
218
|
+
})()]: {
|
|
219
|
+
// Override theme colors with absolute black/white for maximum legibility
|
|
220
|
+
"background-color": "white",
|
|
221
|
+
"color": "black",
|
|
222
|
+
},
|
|
223
|
+
[scope(":where(h1, h2, h3, h4, h5, h6)")]: {
|
|
224
|
+
"color": "black",
|
|
225
|
+
},
|
|
226
|
+
[scope("a")]: {
|
|
227
|
+
"color": "black",
|
|
228
|
+
"text-decoration": "underline",
|
|
229
|
+
"text-decoration-thickness": "2px",
|
|
230
|
+
"font-weight": "700",
|
|
231
|
+
},
|
|
232
|
+
[scope(":where(code:not(pre code), kbd, samp)")]: {
|
|
233
|
+
"background-color": "#f0f0f0",
|
|
234
|
+
"color": "black",
|
|
235
|
+
"border": "2px solid black",
|
|
236
|
+
},
|
|
237
|
+
[scope("pre")]: {
|
|
238
|
+
"background-color": "#f0f0f0",
|
|
239
|
+
"color": "black",
|
|
240
|
+
"border": "2px solid black",
|
|
241
|
+
},
|
|
242
|
+
[scope("blockquote")]: {
|
|
243
|
+
"background-color": "#f0f0f0",
|
|
244
|
+
"border-inline-start-color": "black",
|
|
245
|
+
"border-inline-start-width": "6px",
|
|
246
|
+
"color": "black",
|
|
247
|
+
},
|
|
248
|
+
[scope("th, td")]: {
|
|
249
|
+
"border": "2px solid black",
|
|
250
|
+
},
|
|
251
|
+
[scope("hr")]: {
|
|
252
|
+
"background-color": "black",
|
|
253
|
+
"height": "2px",
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
};
|
|
138
257
|
};
|