wispcss 0.0.1 → 1.0.4
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/CHANGELOG.md +74 -0
- package/LICENSE +49 -0
- package/README.md +386 -0
- package/README.zh-CN.md +385 -0
- package/dist/wispcss.css +45823 -0
- package/dist/wispcss.min.css +2 -0
- package/examples/add-h2-ids.cjs +284 -0
- package/examples/demo-actions.html +188 -0
- package/examples/demo-alarm.html +219 -0
- package/examples/demo-animation.html +399 -0
- package/examples/demo-aura.html +195 -0
- package/examples/demo-avatar.html +279 -0
- package/examples/demo-background.html +284 -0
- package/examples/demo-badge.html +398 -0
- package/examples/demo-blob.html +307 -0
- package/examples/demo-blockquote.html +190 -0
- package/examples/demo-bookmark.html +243 -0
- package/examples/demo-breadcrumb.html +179 -0
- package/examples/demo-btns.html +349 -0
- package/examples/demo-bubble.html +215 -0
- package/examples/demo-buoy.html +187 -0
- package/examples/demo-button-icon.html +231 -0
- package/examples/demo-button-link.html +177 -0
- package/examples/demo-button.html +361 -0
- package/examples/demo-callout.html +601 -0
- package/examples/demo-check.html +323 -0
- package/examples/demo-code.html +212 -0
- package/examples/demo-color.html +545 -0
- package/examples/demo-comment.html +510 -0
- package/examples/demo-deform.html +229 -0
- package/examples/demo-dialog.html +932 -0
- package/examples/demo-divider.html +208 -0
- package/examples/demo-drawer.html +623 -0
- package/examples/demo-dropmenu.html +382 -0
- package/examples/demo-droppanel.html +354 -0
- package/examples/demo-ellipsis.html +145 -0
- package/examples/demo-emphasis.html +146 -0
- package/examples/demo-empty.html +112 -0
- package/examples/demo-entry.html +219 -0
- package/examples/demo-field.html +359 -0
- package/examples/demo-file.html +206 -0
- package/examples/demo-flag.html +225 -0
- package/examples/demo-form.html +201 -0
- package/examples/demo-gilt.html +170 -0
- package/examples/demo-heading.html +93 -0
- package/examples/demo-icon.html +164 -0
- package/examples/demo-input.html +300 -0
- package/examples/demo-kbd.html +202 -0
- package/examples/demo-lamp.html +248 -0
- package/examples/demo-link.html +142 -0
- package/examples/demo-normalize.html +366 -0
- package/examples/demo-otp.html +277 -0
- package/examples/demo-pagination.html +562 -0
- package/examples/demo-position.html +205 -0
- package/examples/demo-poster.html +384 -0
- package/examples/demo-pre - /345/211/257/346/234/254.html" +169 -0
- package/examples/demo-pre.html +205 -0
- package/examples/demo-preset.html +344 -0
- package/examples/demo-progress.html +303 -0
- package/examples/demo-range.html +211 -0
- package/examples/demo-rank.html +270 -0
- package/examples/demo-rating.html +251 -0
- package/examples/demo-reset.html +105 -0
- package/examples/demo-segment.html +436 -0
- package/examples/demo-select.html +332 -0
- package/examples/demo-shadow.html +152 -0
- package/examples/demo-shell.html +377 -0
- package/examples/demo-shimmer.html +217 -0
- package/examples/demo-size.html +149 -0
- package/examples/demo-skeleton.html +143 -0
- package/examples/demo-sketch.html +213 -0
- package/examples/demo-spacer.html +150 -0
- package/examples/demo-spinner.html +220 -0
- package/examples/demo-stats.html +165 -0
- package/examples/demo-status.html +212 -0
- package/examples/demo-step.html +240 -0
- package/examples/demo-styles.css +14 -0
- package/examples/demo-summary.html +128 -0
- package/examples/demo-swatch.html +253 -0
- package/examples/demo-switch.html +223 -0
- package/examples/demo-table.html +339 -0
- package/examples/demo-tag.html +318 -0
- package/examples/demo-text.html +91 -0
- package/examples/demo-theme.html +167 -0
- package/examples/demo-tools.html +152 -0
- package/examples/demo-transition.html +169 -0
- package/examples/demo-tree.html +929 -0
- package/examples/demo-underline.html +76 -0
- package/examples/demo-utils.js +131 -0
- package/examples/demo-validate.html +120 -0
- package/examples/index.html +149 -0
- package/package.json +72 -8
- package/script-gen-color.js +148 -0
- package/script-mini.js +78 -0
- package/script-prefix.js +398 -0
- package/skill.md +575 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link id="wispcss-css" rel="stylesheet" href="../dist/wispcss.css">
|
|
8
|
+
<link rel="stylesheet" href="./demo-styles.css">
|
|
9
|
+
<title>Color System - WispCSS Demo</title>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
/* Control panel */
|
|
13
|
+
.controls {
|
|
14
|
+
display: grid;
|
|
15
|
+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
16
|
+
gap: 16px;
|
|
17
|
+
margin-bottom: 2rem;
|
|
18
|
+
padding: 24px;
|
|
19
|
+
background: var(--color-title-bg-hover);
|
|
20
|
+
border-radius: 12px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.control-group {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: 6px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.control-group label {
|
|
30
|
+
font-size: 0.85rem;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
color: var(--color-title-body);
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.control-group label .value {
|
|
39
|
+
font-weight: 400;
|
|
40
|
+
color: var(--color-caption);
|
|
41
|
+
font-size: 0.8rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/* Color display cards */
|
|
46
|
+
.color-grid {
|
|
47
|
+
display: grid;
|
|
48
|
+
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
|
49
|
+
gap: 24px;
|
|
50
|
+
margin-bottom: 24px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.color-card {
|
|
54
|
+
border-radius: 12px;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.color-card-header {
|
|
59
|
+
padding: 12px 16px;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
font-size: 1rem;
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: space-between;
|
|
64
|
+
align-items: center;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.color-card-header .base-color {
|
|
68
|
+
font-weight: 400;
|
|
69
|
+
font-size: 0.8rem;
|
|
70
|
+
color: var(--color-caption);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.color-swatches {
|
|
74
|
+
padding: 12px 16px;
|
|
75
|
+
display: grid;
|
|
76
|
+
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
77
|
+
gap: 8px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.swatch-item {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
gap: 4px;
|
|
84
|
+
padding: 8px;
|
|
85
|
+
border-radius: 8px;
|
|
86
|
+
background: var(--color-title-bg-hover);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.swatch-label {
|
|
90
|
+
font-size: 0.72rem;
|
|
91
|
+
color: var(--color-caption);
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
text-overflow: ellipsis;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.swatch-box {
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 40px;
|
|
100
|
+
border-radius: 6px;
|
|
101
|
+
border: 1px solid rgba(0, 0, 0, .08);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.swatch-value {
|
|
105
|
+
font-size: 0.65rem;
|
|
106
|
+
color: var(--color-caption);
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
text-overflow: ellipsis;
|
|
109
|
+
white-space: nowrap;
|
|
110
|
+
line-height: 1.3;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (max-width: 768px) {
|
|
114
|
+
.controls {
|
|
115
|
+
grid-template-columns: 1fr;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.color-grid {
|
|
119
|
+
grid-template-columns: 1fr;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
123
|
+
</head>
|
|
124
|
+
|
|
125
|
+
<body>
|
|
126
|
+
<h1>Color System</h1>
|
|
127
|
+
<p>WispCSS color system built on OKLCH color space. Adjust controls to preview real-time color changes.</p>
|
|
128
|
+
|
|
129
|
+
<h2>Notes</h2>
|
|
130
|
+
<div class="section">
|
|
131
|
+
<ul>
|
|
132
|
+
<li>Color system uses OKLCH color space for perceptual uniformity.</li>
|
|
133
|
+
<li><code>--color-c-factor</code> controls saturation; <code>--light-threshold-*</code> controls contrast text
|
|
134
|
+
brightness.</li>
|
|
135
|
+
<li>Each theme color has 13 derived variants (hover, active, contrast, body, surface, fg, bg, bg-hover, bg-active,
|
|
136
|
+
bd, bd-hover, bd-active).</li>
|
|
137
|
+
<li>Typically you only need to modify <code>--color-primary-base</code>, <code>--color-secondary-base</code> and
|
|
138
|
+
<code>--color-tertiary-base</code> to change the theme style with just three colors.
|
|
139
|
+
</li>
|
|
140
|
+
<li>Adjust color base values and light parameters below to see real-time updates on cards and buttons.</li>
|
|
141
|
+
</ul>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<h2 id="configuration">Configuration</h2>
|
|
145
|
+
<pre id="config-output"></pre>
|
|
146
|
+
|
|
147
|
+
<!-- Controls panel -->
|
|
148
|
+
<div class="section">
|
|
149
|
+
<h2 id="controls">Controls</h2>
|
|
150
|
+
<div class="controls" id="controls">
|
|
151
|
+
<div class="control-group">
|
|
152
|
+
<label>--color-c-light <span class="value" id="val-c-light"></span></label>
|
|
153
|
+
<input type=range id="ctrl-c-light" min="0" max="2" step="0.01">
|
|
154
|
+
</div>
|
|
155
|
+
<div class="control-group">
|
|
156
|
+
<label>--color-c-dark <span class="value" id="val-c-dark"></span></label>
|
|
157
|
+
<input type=range id="ctrl-c-dark" min="0" max="2" step="0.01">
|
|
158
|
+
</div>
|
|
159
|
+
<div class="control-group">
|
|
160
|
+
<label>--light-threshold-contrast <span class="value" id="val-l-threshold"></span></label>
|
|
161
|
+
<input type=range id="ctrl-l-threshold" min="0" max="1" step="0.01">
|
|
162
|
+
</div>
|
|
163
|
+
<div class="control-group">
|
|
164
|
+
<label>--light-min <span class="value" id="val-l-min"></span></label>
|
|
165
|
+
<input type=range id="ctrl-l-min" min="0" max="1" step="0.01">
|
|
166
|
+
</div>
|
|
167
|
+
<div class="control-group">
|
|
168
|
+
<label>--light-max <span class="value" id="val-l-max"></span></label>
|
|
169
|
+
<input type=range id="ctrl-l-max" min="0" max="1" step="0.01">
|
|
170
|
+
</div>
|
|
171
|
+
<div class="control-group">
|
|
172
|
+
<label>--color-primary-base</label>
|
|
173
|
+
<input type="color" id="ctrl-primary-base">
|
|
174
|
+
</div>
|
|
175
|
+
<div class="control-group">
|
|
176
|
+
<label>--color-secondary-base</label>
|
|
177
|
+
<input type="color" id="ctrl-secondary-base">
|
|
178
|
+
</div>
|
|
179
|
+
<div class="control-group">
|
|
180
|
+
<label>--color-tertiary-base</label>
|
|
181
|
+
<input type="color" id="ctrl-tertiary-base">
|
|
182
|
+
</div>
|
|
183
|
+
<div class="control-group">
|
|
184
|
+
<label>--color-success-base</label>
|
|
185
|
+
<input type="color" id="ctrl-success-base">
|
|
186
|
+
</div>
|
|
187
|
+
<div class="control-group">
|
|
188
|
+
<label>--color-error-base</label>
|
|
189
|
+
<input type="color" id="ctrl-error-base">
|
|
190
|
+
</div>
|
|
191
|
+
<div class="control-group">
|
|
192
|
+
<label>--color-info-base</label>
|
|
193
|
+
<input type="color" id="ctrl-info-base">
|
|
194
|
+
</div>
|
|
195
|
+
<div class="control-group">
|
|
196
|
+
<label>--color-warning-base</label>
|
|
197
|
+
<input type="color" id="ctrl-warning-base">
|
|
198
|
+
</div>
|
|
199
|
+
<div class="control-group">
|
|
200
|
+
<label>--color-caution-base</label>
|
|
201
|
+
<input type="color" id="ctrl-caution-base">
|
|
202
|
+
</div>
|
|
203
|
+
<div class="control-group">
|
|
204
|
+
<label>--color-highlight-base</label>
|
|
205
|
+
<input type="color" id="ctrl-highlight-base">
|
|
206
|
+
</div>
|
|
207
|
+
<div class="control-group">
|
|
208
|
+
<label>--color-title-base</label>
|
|
209
|
+
<input type="color" id="ctrl-title-base">
|
|
210
|
+
</div>
|
|
211
|
+
<div class="control-group">
|
|
212
|
+
<label>--color-ink-base</label>
|
|
213
|
+
<input type="color" id="ctrl-ink-base">
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<!-- Color swatches -->
|
|
219
|
+
<div class="section">
|
|
220
|
+
<h2 id="color-swatches">Color swatches</h2>
|
|
221
|
+
<div id="color-display"></div>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<!-- Button preview -->
|
|
225
|
+
<div class="section">
|
|
226
|
+
<h2 id="button-color-preview">Button color preview</h2>
|
|
227
|
+
<p>Buttons rendered with current color variables. Adjust controls above to see real-time changes.</p>
|
|
228
|
+
|
|
229
|
+
<div>
|
|
230
|
+
<div class="button-group-label">Primary</div>
|
|
231
|
+
<div class="button-row">
|
|
232
|
+
<button class="btn-primary">Solid</button>
|
|
233
|
+
<button class="btn-outline-primary">Outline</button>
|
|
234
|
+
<button class="btn-muted-primary">Muted</button>
|
|
235
|
+
<button class="btn-subtle-primary">Subtle</button>
|
|
236
|
+
<button class="btn-vivid-primary">Vivid</button>
|
|
237
|
+
<button class="btn-ghost-primary">Ghost</button>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
<div>
|
|
241
|
+
<div class="button-group-label">Secondary</div>
|
|
242
|
+
<div class="button-row">
|
|
243
|
+
<button class="btn-secondary">Solid</button>
|
|
244
|
+
<button class="btn-outline-secondary">Outline</button>
|
|
245
|
+
<button class="btn-muted-secondary">Muted</button>
|
|
246
|
+
<button class="btn-subtle-secondary">Subtle</button>
|
|
247
|
+
<button class="btn-vivid-secondary">Vivid</button>
|
|
248
|
+
<button class="btn-ghost-secondary">Ghost</button>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
<div>
|
|
252
|
+
<div class="button-group-label">Tertiary</div>
|
|
253
|
+
<div class="button-row">
|
|
254
|
+
<button class="btn-tertiary">Solid</button>
|
|
255
|
+
<button class="btn-outline-tertiary">Outline</button>
|
|
256
|
+
<button class="btn-muted-tertiary">Muted</button>
|
|
257
|
+
<button class="btn-subtle-tertiary">Subtle</button>
|
|
258
|
+
<button class="btn-vivid-tertiary">Vivid</button>
|
|
259
|
+
<button class="btn-ghost-tertiary">Ghost</button>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
<div>
|
|
263
|
+
<div class="button-group-label">Success</div>
|
|
264
|
+
<div class="button-row">
|
|
265
|
+
<button class="btn-success">Solid</button>
|
|
266
|
+
<button class="btn-outline-success">Outline</button>
|
|
267
|
+
<button class="btn-muted-success">Muted</button>
|
|
268
|
+
<button class="btn-subtle-success">Subtle</button>
|
|
269
|
+
<button class="btn-vivid-success">Vivid</button>
|
|
270
|
+
<button class="btn-ghost-success">Ghost</button>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
<div>
|
|
274
|
+
<div class="button-group-label">Error</div>
|
|
275
|
+
<div class="button-row">
|
|
276
|
+
<button class="btn-error">Solid</button>
|
|
277
|
+
<button class="btn-outline-error">Outline</button>
|
|
278
|
+
<button class="btn-muted-error">Muted</button>
|
|
279
|
+
<button class="btn-subtle-error">Subtle</button>
|
|
280
|
+
<button class="btn-vivid-error">Vivid</button>
|
|
281
|
+
<button class="btn-ghost-error">Ghost</button>
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
<div>
|
|
285
|
+
<div class="button-group-label">Info</div>
|
|
286
|
+
<div class="button-row">
|
|
287
|
+
<button class="btn-info">Solid</button>
|
|
288
|
+
<button class="btn-outline-info">Outline</button>
|
|
289
|
+
<button class="btn-muted-info">Muted</button>
|
|
290
|
+
<button class="btn-subtle-info">Subtle</button>
|
|
291
|
+
<button class="btn-vivid-info">Vivid</button>
|
|
292
|
+
<button class="btn-ghost-info">Ghost</button>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
<div>
|
|
296
|
+
<div class="button-group-label">Warning</div>
|
|
297
|
+
<div class="button-row">
|
|
298
|
+
<button class="btn-warning">Solid</button>
|
|
299
|
+
<button class="btn-outline-warning">Outline</button>
|
|
300
|
+
<button class="btn-muted-warning">Muted</button>
|
|
301
|
+
<button class="btn-subtle-warning">Subtle</button>
|
|
302
|
+
<button class="btn-vivid-warning">Vivid</button>
|
|
303
|
+
<button class="btn-ghost-warning">Ghost</button>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
<div>
|
|
307
|
+
<div class="button-group-label">Caution</div>
|
|
308
|
+
<div class="button-row">
|
|
309
|
+
<button class="btn-caution">Solid</button>
|
|
310
|
+
<button class="btn-outline-caution">Outline</button>
|
|
311
|
+
<button class="btn-muted-caution">Muted</button>
|
|
312
|
+
<button class="btn-subtle-caution">Subtle</button>
|
|
313
|
+
<button class="btn-vivid-caution">Vivid</button>
|
|
314
|
+
<button class="btn-ghost-caution">Ghost</button>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
<div>
|
|
318
|
+
<div class="button-group-label">Highlight</div>
|
|
319
|
+
<div class="button-row">
|
|
320
|
+
<button class="btn-highlight">Solid</button>
|
|
321
|
+
<button class="btn-outline-highlight">Outline</button>
|
|
322
|
+
<button class="btn-muted-highlight">Muted</button>
|
|
323
|
+
<button class="btn-subtle-highlight">Subtle</button>
|
|
324
|
+
<button class="btn-vivid-highlight">Vivid</button>
|
|
325
|
+
<button class="btn-ghost-highlight">Ghost</button>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
<div>
|
|
329
|
+
<div class="button-group-label">Title</div>
|
|
330
|
+
<div class="button-row">
|
|
331
|
+
<button class="btn-title">Solid</button>
|
|
332
|
+
<button class="btn-outline-title">Outline</button>
|
|
333
|
+
<button class="btn-muted-title">Muted</button>
|
|
334
|
+
<button class="btn-subtle-title">Subtle</button>
|
|
335
|
+
<button class="btn-vivid-title">Vivid</button>
|
|
336
|
+
<button class="btn-ghost-title">Ghost</button>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
<div>
|
|
340
|
+
<div class="button-group-label">Ink</div>
|
|
341
|
+
<div class="button-row">
|
|
342
|
+
<button class="btn-ink">Solid</button>
|
|
343
|
+
<button class="btn-outline-ink">Outline</button>
|
|
344
|
+
<button class="btn-muted-ink">Muted</button>
|
|
345
|
+
<button class="btn-subtle-ink">Subtle</button>
|
|
346
|
+
<button class="btn-vivid-ink">Vivid</button>
|
|
347
|
+
<button class="btn-ghost-ink">Ghost</button>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<p>For preset theme colors, visit <a class="link" href="./demo-theme.html">demo-theme.html</a>.</p>
|
|
353
|
+
|
|
354
|
+
<script>
|
|
355
|
+
// Color configs
|
|
356
|
+
const colorConfigs = [
|
|
357
|
+
{ name: 'primary', label: 'Primary', base: '#0f67ff' },
|
|
358
|
+
{ name: 'secondary', label: 'Secondary', base: '#6f58dc' },
|
|
359
|
+
{ name: 'tertiary', label: 'Tertiary', base: '#00b8cc' },
|
|
360
|
+
{ name: 'success', label: 'Success', base: '#439e3b' },
|
|
361
|
+
{ name: 'error', label: 'Error', base: '#e04e40' },
|
|
362
|
+
{ name: 'info', label: 'Info', base: '#0097f5' },
|
|
363
|
+
{ name: 'warning', label: 'Warning', base: '#fa8c1c' },
|
|
364
|
+
{ name: 'caution', label: 'Caution', base: '#f4b000' },
|
|
365
|
+
{ name: 'highlight', label: 'Highlight', base: '#f1f100' },
|
|
366
|
+
{ name: 'title', label: 'Title', base: '#0d0d0d' },
|
|
367
|
+
{ name: 'ink', label: 'Ink', base: '#0d0d0d' },
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
// Variants
|
|
371
|
+
const variants = [
|
|
372
|
+
{ key: '', label: 'Base' },
|
|
373
|
+
{ key: '-hover', label: 'Hover' },
|
|
374
|
+
{ key: '-active', label: 'Active' },
|
|
375
|
+
{ key: '-contrast', label: 'Contrast' },
|
|
376
|
+
{ key: '-body', label: 'Body' },
|
|
377
|
+
{ key: '-surface', label: 'Surface' },
|
|
378
|
+
{ key: '-fg', label: 'Foreground' },
|
|
379
|
+
{ key: '-bg', label: 'Background' },
|
|
380
|
+
{ key: '-bg-hover', label: 'Bg Hover' },
|
|
381
|
+
{ key: '-bg-active', label: 'Bg Active' },
|
|
382
|
+
{ key: '-bd', label: 'Border' },
|
|
383
|
+
{ key: '-bd-hover', label: 'Border Hover' },
|
|
384
|
+
{ key: '-bd-active', label: 'Border Active' },
|
|
385
|
+
];
|
|
386
|
+
|
|
387
|
+
const rangeDefaults = [
|
|
388
|
+
{ id: 'ctrl-c-light', valId: 'val-c-light', value: 1 },
|
|
389
|
+
{ id: 'ctrl-c-dark', valId: 'val-c-dark', value: 0.8 },
|
|
390
|
+
{ id: 'ctrl-l-threshold', valId: 'val-l-threshold', value: 0.82 },
|
|
391
|
+
{ id: 'ctrl-l-min', valId: 'val-l-min', value: 0.17 },
|
|
392
|
+
{ id: 'ctrl-l-max', valId: 'val-l-max', value: 1 },
|
|
393
|
+
];
|
|
394
|
+
|
|
395
|
+
const rangeVars = [
|
|
396
|
+
{ key: '--color-c-light', id: 'ctrl-c-light' },
|
|
397
|
+
{ key: '--color-c-dark', id: 'ctrl-c-dark' },
|
|
398
|
+
{ key: '--light-threshold-contrast', id: 'ctrl-l-threshold' },
|
|
399
|
+
{ key: '--light-min', id: 'ctrl-l-min' },
|
|
400
|
+
{ key: '--light-max', id: 'ctrl-l-max' },
|
|
401
|
+
];
|
|
402
|
+
|
|
403
|
+
const rangeControls = [
|
|
404
|
+
{ id: 'ctrl-c-light', varName: '--color-c-light', valId: 'val-c-light' },
|
|
405
|
+
{ id: 'ctrl-c-dark', varName: '--color-c-dark', valId: 'val-c-dark' },
|
|
406
|
+
{ id: 'ctrl-l-threshold', varName: '--light-threshold-contrast', valId: 'val-l-threshold' },
|
|
407
|
+
{ id: 'ctrl-l-min', varName: '--light-min', valId: 'val-l-min' },
|
|
408
|
+
{ id: 'ctrl-l-max', varName: '--light-max', valId: 'val-l-max' },
|
|
409
|
+
];
|
|
410
|
+
|
|
411
|
+
const colorControls = [
|
|
412
|
+
{ id: 'ctrl-primary-base', varName: '--color-primary-base' },
|
|
413
|
+
{ id: 'ctrl-secondary-base', varName: '--color-secondary-base' },
|
|
414
|
+
{ id: 'ctrl-tertiary-base', varName: '--color-tertiary-base' },
|
|
415
|
+
{ id: 'ctrl-success-base', varName: '--color-success-base' },
|
|
416
|
+
{ id: 'ctrl-error-base', varName: '--color-error-base' },
|
|
417
|
+
{ id: 'ctrl-info-base', varName: '--color-info-base' },
|
|
418
|
+
{ id: 'ctrl-warning-base', varName: '--color-warning-base' },
|
|
419
|
+
{ id: 'ctrl-caution-base', varName: '--color-caution-base' },
|
|
420
|
+
{ id: 'ctrl-highlight-base', varName: '--color-highlight-base' },
|
|
421
|
+
{ id: 'ctrl-title-base', varName: '--color-title-base' },
|
|
422
|
+
{ id: 'ctrl-ink-base', varName: '--color-ink-base' },
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
const colorDisplay = document.getElementById('color-display');
|
|
426
|
+
|
|
427
|
+
function buildColorCards() {
|
|
428
|
+
colorDisplay.innerHTML = '';
|
|
429
|
+
colorConfigs.forEach(config => {
|
|
430
|
+
const card = document.createElement('div');
|
|
431
|
+
card.className = 'color-card';
|
|
432
|
+
card.id = `card-${config.name}`;
|
|
433
|
+
const header = document.createElement('div');
|
|
434
|
+
header.className = 'color-card-header';
|
|
435
|
+
header.innerHTML = `${config.label} <span class="base-color" id="base-${config.name}">${config.base}</span>`;
|
|
436
|
+
card.appendChild(header);
|
|
437
|
+
const swatches = document.createElement('div');
|
|
438
|
+
swatches.className = 'color-swatches';
|
|
439
|
+
swatches.id = `swatches-${config.name}`;
|
|
440
|
+
variants.forEach(v => {
|
|
441
|
+
const item = document.createElement('div');
|
|
442
|
+
item.className = 'swatch-item';
|
|
443
|
+
const box = document.createElement('div');
|
|
444
|
+
box.className = 'swatch-box';
|
|
445
|
+
box.id = `box-${config.name}${v.key}`;
|
|
446
|
+
box.style.background = `var(--color-${config.name}${v.key})`;
|
|
447
|
+
item.appendChild(box);
|
|
448
|
+
const label = document.createElement('div');
|
|
449
|
+
label.className = 'swatch-label';
|
|
450
|
+
label.textContent = `--color-${config.name}${v.key}`;
|
|
451
|
+
item.appendChild(label);
|
|
452
|
+
const val = document.createElement('div');
|
|
453
|
+
val.className = 'swatch-value';
|
|
454
|
+
val.id = `val-${config.name}${v.key}`;
|
|
455
|
+
val.textContent = getComputedStyle(document.documentElement).getPropertyValue(`--color-${config.name}${v.key}`).trim();
|
|
456
|
+
item.appendChild(val);
|
|
457
|
+
swatches.appendChild(item);
|
|
458
|
+
});
|
|
459
|
+
card.appendChild(swatches);
|
|
460
|
+
colorDisplay.appendChild(card);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function updateColorValues() {
|
|
465
|
+
colorConfigs.forEach(config => {
|
|
466
|
+
variants.forEach(v => {
|
|
467
|
+
const varName = `--color-${config.name}${v.key}`;
|
|
468
|
+
const val = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
469
|
+
const valEl = document.getElementById(`val-${config.name}${v.key}`);
|
|
470
|
+
const boxEl = document.getElementById(`box-${config.name}${v.key}`);
|
|
471
|
+
if (valEl) valEl.textContent = val;
|
|
472
|
+
if (boxEl) boxEl.style.background = `var(${varName})`;
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function setCSSVariable(name, value) {
|
|
478
|
+
document.documentElement.style.setProperty(name, value);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function updateConfigOutput() {
|
|
482
|
+
const lines = [];
|
|
483
|
+
|
|
484
|
+
rangeVars.forEach(v => {
|
|
485
|
+
const el = document.getElementById(v.id);
|
|
486
|
+
lines.push(`${v.key}: ${el.value};`);
|
|
487
|
+
});
|
|
488
|
+
colorConfigs.forEach(c => {
|
|
489
|
+
lines.push(`--color-${c.name}-base: ${c.base};`);
|
|
490
|
+
});
|
|
491
|
+
document.getElementById('config-output').textContent = lines.join('\n');
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function initControlValues() {
|
|
495
|
+
|
|
496
|
+
rangeDefaults.forEach(d => {
|
|
497
|
+
const el = document.getElementById(d.id);
|
|
498
|
+
const valEl = document.getElementById(d.valId);
|
|
499
|
+
if (el) el.value = d.value;
|
|
500
|
+
if (valEl) valEl.textContent = d.value;
|
|
501
|
+
});
|
|
502
|
+
colorConfigs.forEach(c => {
|
|
503
|
+
const el = document.getElementById(`ctrl-${c.name}-base`);
|
|
504
|
+
if (el) el.value = c.base;
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function initControls() {
|
|
509
|
+
|
|
510
|
+
rangeControls.forEach(cfg => {
|
|
511
|
+
const el = document.getElementById(cfg.id);
|
|
512
|
+
const valEl = document.getElementById(cfg.valId);
|
|
513
|
+
el.addEventListener('input', () => {
|
|
514
|
+
const v = el.value;
|
|
515
|
+
valEl.textContent = v;
|
|
516
|
+
setCSSVariable(cfg.varName, v);
|
|
517
|
+
updateColorValues();
|
|
518
|
+
updateConfigOutput();
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
colorControls.forEach(cfg => {
|
|
523
|
+
const el = document.getElementById(cfg.id);
|
|
524
|
+
el.addEventListener('input', () => {
|
|
525
|
+
const v = el.value;
|
|
526
|
+
setCSSVariable(cfg.varName, v);
|
|
527
|
+
const name = cfg.varName.replace('--color-', '').replace('-base', '');
|
|
528
|
+
const baseEl = document.getElementById(`base-${name}`);
|
|
529
|
+
if (baseEl) baseEl.textContent = v;
|
|
530
|
+
updateColorValues();
|
|
531
|
+
updateConfigOutput();
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
initControlValues();
|
|
537
|
+
buildColorCards();
|
|
538
|
+
initControls();
|
|
539
|
+
updateConfigOutput();
|
|
540
|
+
setTimeout(updateColorValues, 100);
|
|
541
|
+
</script>
|
|
542
|
+
<script src="./demo-utils.js"></script>
|
|
543
|
+
</body>
|
|
544
|
+
|
|
545
|
+
</html>
|