svelte-multistyle-ui 0.0.4-alpha → 0.0.6-alpha
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 +1 -1
- package/cli/bin.js +90 -0
- package/cli/emit.js +228 -0
- package/cli/fixtures/sample.expected.svelte +69 -0
- package/cli/fixtures/sample.yaml +128 -0
- package/cli/generate.js +68 -0
- package/cli/registry.js +95 -0
- package/cli/schema.js +145 -0
- package/dist/components/Button.svelte +3 -1
- package/dist/components/Button.svelte.d.ts +2 -0
- package/dist/components/DatePicker.svelte +47 -12
- package/dist/components/FAB.svelte +3 -1
- package/dist/components/FAB.svelte.d.ts +2 -0
- package/dist/components/IconButton.svelte +3 -1
- package/dist/components/IconButton.svelte.d.ts +2 -0
- package/dist/components/Input.svelte +0 -1
- package/dist/components/MultiSelect.svelte +0 -1
- package/dist/components/Select.svelte +0 -1
- package/dist/components/Stepper.svelte +91 -33
- package/dist/components/Textarea.svelte +0 -1
- package/dist/components/accordion-styles.css +1 -9
- package/dist/components/alert-styles.css +1 -4
- package/dist/components/avatar-styles.css +1 -4
- package/dist/components/breadcrumb-styles.css +1 -7
- package/dist/components/button-styles.css +44 -52
- package/dist/components/buttongroup-styles.css +1 -5
- package/dist/components/card-styles.css +1 -9
- package/dist/components/carousel-styles.css +1 -5
- package/dist/components/charts/Chart.svelte +63 -3
- package/dist/components/charts/chart-config.d.ts +27 -2
- package/dist/components/charts/chart-config.js +180 -67
- package/dist/components/charts/chart-styles.css +32 -17
- package/dist/components/checkbox-styles.css +2 -10
- package/dist/components/chip-styles.css +1 -4
- package/dist/components/commandpalette-styles.css +0 -4
- package/dist/components/datepicker-styles.css +967 -1027
- package/dist/components/divider-styles.css +1 -4
- package/dist/components/drawer-styles.css +0 -4
- package/dist/components/dropdown-styles.css +0 -5
- package/dist/components/fab-styles.css +18 -12
- package/dist/components/fileupload-styles.css +2 -10
- package/dist/components/iconbutton-styles.css +33 -34
- package/dist/components/input-styles.css +5 -37
- package/dist/components/modal-styles.css +0 -8
- package/dist/components/multiselect-styles.css +5 -32
- package/dist/components/pagination-styles.css +2 -5
- package/dist/components/popover-styles.css +0 -4
- package/dist/components/progressbar-styles.css +1 -5
- package/dist/components/radio-styles.css +1 -8
- package/dist/components/rating-styles.css +1 -4
- package/dist/components/select-styles.css +5 -18
- package/dist/components/skeleton-styles.css +1 -4
- package/dist/components/slider-styles.css +1 -5
- package/dist/components/sortablelist-styles.css +0 -13
- package/dist/components/spinner-styles.css +1 -4
- package/dist/components/stepper-styles.css +59 -8
- package/dist/components/table-styles.css +1 -5
- package/dist/components/tabs-styles.css +3 -7
- package/dist/components/textarea-styles.css +5 -18
- package/dist/components/theme-base.css +19 -2
- package/dist/components/theme.css +329 -333
- package/dist/components/toast-styles.css +1 -4
- package/dist/components/toggle-styles.css +1 -11
- package/dist/components/tooltip-styles.css +1 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/themes/color.d.ts +52 -0
- package/dist/themes/color.js +91 -0
- package/dist/themes/generator.d.ts +41 -0
- package/dist/themes/generator.js +174 -0
- package/dist/themes/index.d.ts +3 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/presets.d.ts +445 -0
- package/dist/themes/presets.js +144 -0
- package/dist/themes/schema.d.ts +47 -0
- package/dist/themes/schema.js +34 -0
- package/package.json +18 -4
|
@@ -64,10 +64,4 @@
|
|
|
64
64
|
.s-breadcrumb-carbon { font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; }
|
|
65
65
|
|
|
66
66
|
/* Liquid Glass */
|
|
67
|
-
.s-breadcrumb-liquid-glass .s-breadcrumb-item a:hover { color: var(--t-primary); }
|
|
68
|
-
|
|
69
|
-
/* Legacy iOS */
|
|
70
|
-
.s-breadcrumb-legacy-ios .s-breadcrumb-item a,
|
|
71
|
-
.s-breadcrumb-legacy-ios .s-breadcrumb-item span { color: var(--t-primary); }
|
|
72
|
-
.s-breadcrumb-legacy-ios .s-breadcrumb-item.current a,
|
|
73
|
-
.s-breadcrumb-legacy-ios .s-breadcrumb-item.current span { color: var(--t-text); }
|
|
67
|
+
.s-breadcrumb-liquid-glass .s-breadcrumb-item a:hover { color: var(--t-primary); }
|
|
@@ -12,12 +12,21 @@
|
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
white-space: nowrap;
|
|
14
14
|
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
--btn-color: var(--btn-color);
|
|
16
|
+
background: var(--btn-color);
|
|
17
|
+
color: var(--t-text-on-primary);
|
|
17
18
|
border: var(--t-border-width) solid transparent;
|
|
18
19
|
border-radius: var(--t-btn-radius);
|
|
19
20
|
box-shadow: var(--t-shadow-sm);
|
|
20
21
|
}
|
|
22
|
+
|
|
23
|
+
/* ===== PRESETS (semantic color, theme-aware via --t-* tokens) ===== */
|
|
24
|
+
.s-button.btn-primary { --btn-color: var(--t-primary); }
|
|
25
|
+
.s-button.btn-secondary { --btn-color: var(--t-secondary); }
|
|
26
|
+
.s-button.btn-info { --btn-color: var(--t-info); }
|
|
27
|
+
.s-button.btn-success { --btn-color: var(--t-success); }
|
|
28
|
+
.s-button.btn-warning { --btn-color: var(--t-warning); }
|
|
29
|
+
.s-button.btn-error { --btn-color: var(--t-error); }
|
|
21
30
|
.s-button:disabled {
|
|
22
31
|
opacity: 0.45;
|
|
23
32
|
pointer-events: none;
|
|
@@ -31,12 +40,12 @@
|
|
|
31
40
|
|
|
32
41
|
/* ===== VARIANTS ===== */
|
|
33
42
|
.s-button.btn-filled {
|
|
34
|
-
background: var(--
|
|
35
|
-
color:
|
|
43
|
+
background: var(--btn-color);
|
|
44
|
+
color: var(--t-text-on-primary);
|
|
36
45
|
border-color: transparent;
|
|
37
46
|
}
|
|
38
47
|
.s-button.btn-filled:hover {
|
|
39
|
-
background: color-mix(in srgb, var(--
|
|
48
|
+
background: color-mix(in srgb, var(--btn-color) 85%, #000);
|
|
40
49
|
box-shadow: var(--t-shadow-colored-md);
|
|
41
50
|
}
|
|
42
51
|
.s-button.btn-filled:active {
|
|
@@ -46,42 +55,42 @@
|
|
|
46
55
|
|
|
47
56
|
.s-button.btn-outlined {
|
|
48
57
|
background: transparent;
|
|
49
|
-
color: var(--
|
|
50
|
-
border-color: var(--
|
|
58
|
+
color: var(--btn-color);
|
|
59
|
+
border-color: var(--btn-color);
|
|
51
60
|
box-shadow: none;
|
|
52
61
|
}
|
|
53
62
|
.s-button.btn-outlined:hover {
|
|
54
|
-
background: color-mix(in srgb, var(--
|
|
63
|
+
background: color-mix(in srgb, var(--btn-color) 8%, transparent);
|
|
55
64
|
}
|
|
56
65
|
.s-button.btn-outlined:active {
|
|
57
|
-
background: color-mix(in srgb, var(--
|
|
66
|
+
background: color-mix(in srgb, var(--btn-color) 14%, transparent);
|
|
58
67
|
transform: scale(0.97);
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
.s-button.btn-text {
|
|
62
71
|
background: transparent;
|
|
63
|
-
color: var(--
|
|
72
|
+
color: var(--btn-color);
|
|
64
73
|
border-color: transparent;
|
|
65
74
|
box-shadow: none;
|
|
66
75
|
}
|
|
67
76
|
.s-button.btn-text:hover {
|
|
68
|
-
background: color-mix(in srgb, var(--
|
|
77
|
+
background: color-mix(in srgb, var(--btn-color) 8%, transparent);
|
|
69
78
|
}
|
|
70
79
|
.s-button.btn-text:active {
|
|
71
|
-
background: color-mix(in srgb, var(--
|
|
80
|
+
background: color-mix(in srgb, var(--btn-color) 14%, transparent);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
.s-button.btn-tonal {
|
|
75
|
-
background: color-mix(in srgb, var(--
|
|
76
|
-
color: var(--
|
|
84
|
+
background: color-mix(in srgb, var(--btn-color) 15%, var(--t-surface));
|
|
85
|
+
color: var(--btn-color);
|
|
77
86
|
border-color: transparent;
|
|
78
87
|
box-shadow: none;
|
|
79
88
|
}
|
|
80
89
|
.s-button.btn-tonal:hover {
|
|
81
|
-
background: color-mix(in srgb, var(--
|
|
90
|
+
background: color-mix(in srgb, var(--btn-color) 22%, var(--t-surface));
|
|
82
91
|
}
|
|
83
92
|
.s-button.btn-tonal:active {
|
|
84
|
-
background: color-mix(in srgb, var(--
|
|
93
|
+
background: color-mix(in srgb, var(--btn-color) 28%, var(--t-surface));
|
|
85
94
|
transform: scale(0.97);
|
|
86
95
|
}
|
|
87
96
|
|
|
@@ -141,31 +150,31 @@
|
|
|
141
150
|
|
|
142
151
|
/* Neon */
|
|
143
152
|
.s-button-neon {
|
|
144
|
-
box-shadow: 0 0 5px var(--
|
|
153
|
+
box-shadow: 0 0 5px var(--btn-color), 0 0 15px var(--t-shadow);
|
|
145
154
|
}
|
|
146
155
|
.s-button-neon:hover {
|
|
147
|
-
box-shadow: 0 0 10px var(--
|
|
156
|
+
box-shadow: 0 0 10px var(--btn-color), 0 0 30px var(--t-shadow);
|
|
148
157
|
}
|
|
149
158
|
.s-button-neon.btn-filled {
|
|
150
159
|
background: var(--t-surface);
|
|
151
|
-
color: var(--
|
|
152
|
-
border-color: var(--
|
|
160
|
+
color: var(--btn-color);
|
|
161
|
+
border-color: var(--btn-color);
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
/* Metro */
|
|
156
165
|
.s-button-metro {
|
|
157
166
|
border-radius: 0;
|
|
158
|
-
border: var(--t-border-width) solid var(--
|
|
167
|
+
border: var(--t-border-width) solid var(--btn-color);
|
|
159
168
|
font-weight: 600;
|
|
160
169
|
box-shadow: none;
|
|
161
170
|
}
|
|
162
171
|
.s-button-metro.btn-filled {
|
|
163
|
-
background: var(--
|
|
164
|
-
color:
|
|
172
|
+
background: var(--btn-color);
|
|
173
|
+
color: var(--t-text-on-primary);
|
|
165
174
|
}
|
|
166
175
|
.s-button-metro.btn-outlined {
|
|
167
176
|
background: var(--t-surface);
|
|
168
|
-
color: var(--
|
|
177
|
+
color: var(--btn-color);
|
|
169
178
|
}
|
|
170
179
|
.s-button-metro:hover {
|
|
171
180
|
opacity: 0.85;
|
|
@@ -178,30 +187,30 @@
|
|
|
178
187
|
box-shadow: var(--t-shadow-xs);
|
|
179
188
|
}
|
|
180
189
|
.s-button-bootstrap.btn-filled {
|
|
181
|
-
border-color: var(--
|
|
190
|
+
border-color: var(--btn-color);
|
|
182
191
|
}
|
|
183
192
|
.s-button-bootstrap:hover {
|
|
184
193
|
box-shadow: 0 0 0 3px var(--t-shadow);
|
|
185
194
|
}
|
|
186
195
|
.s-button-bootstrap:focus-visible {
|
|
187
196
|
box-shadow: 0 0 0 3px var(--t-shadow);
|
|
188
|
-
border-color: var(--
|
|
197
|
+
border-color: var(--btn-color);
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
/* Cartoon */
|
|
192
201
|
.s-button-cartoon {
|
|
193
202
|
border-radius: 16px;
|
|
194
203
|
border: var(--t-border-width) solid var(--t-text);
|
|
195
|
-
box-shadow: 4px 4px 0 var(--
|
|
204
|
+
box-shadow: 4px 4px 0 var(--btn-color);
|
|
196
205
|
font-weight: 700;
|
|
197
206
|
}
|
|
198
207
|
.s-button-cartoon:hover {
|
|
199
208
|
transform: translate(-1px, -1px);
|
|
200
|
-
box-shadow: 5px 5px 0 var(--
|
|
209
|
+
box-shadow: 5px 5px 0 var(--btn-color);
|
|
201
210
|
}
|
|
202
211
|
.s-button-cartoon:active {
|
|
203
212
|
transform: translate(2px, 2px);
|
|
204
|
-
box-shadow: 1px 1px 0 var(--
|
|
213
|
+
box-shadow: 1px 1px 0 var(--btn-color);
|
|
205
214
|
}
|
|
206
215
|
|
|
207
216
|
/* Illustration */
|
|
@@ -225,10 +234,10 @@
|
|
|
225
234
|
box-shadow: none;
|
|
226
235
|
}
|
|
227
236
|
.s-button-carbon:hover {
|
|
228
|
-
border-bottom-color: var(--
|
|
237
|
+
border-bottom-color: var(--btn-color);
|
|
229
238
|
}
|
|
230
239
|
.s-button-carbon:focus-visible {
|
|
231
|
-
border-bottom-color: var(--
|
|
240
|
+
border-bottom-color: var(--btn-color);
|
|
232
241
|
}
|
|
233
242
|
|
|
234
243
|
/* Liquid Glass */
|
|
@@ -241,32 +250,15 @@
|
|
|
241
250
|
box-shadow: var(--t-shadow-md), inset 0 1px 0 rgba(255,255,255,0.3);
|
|
242
251
|
}
|
|
243
252
|
.s-button-liquid-glass.btn-filled {
|
|
244
|
-
background: color-mix(in srgb, var(--
|
|
253
|
+
background: color-mix(in srgb, var(--btn-color) 60%, transparent);
|
|
245
254
|
border-color: rgba(255,255,255,0.2);
|
|
246
255
|
}
|
|
247
256
|
.s-button-liquid-glass.btn-outlined {
|
|
248
257
|
background: rgba(255,255,255,0.06);
|
|
249
|
-
border-color: color-mix(in srgb, var(--
|
|
250
|
-
color: var(--
|
|
258
|
+
border-color: color-mix(in srgb, var(--btn-color) 50%, transparent);
|
|
259
|
+
color: var(--btn-color);
|
|
251
260
|
}
|
|
252
261
|
.s-button-liquid-glass:hover {
|
|
253
262
|
background: rgba(255,255,255,0.18);
|
|
254
263
|
box-shadow: var(--t-shadow-lg), inset 0 1px 0 rgba(255,255,255,0.4);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/* Legacy iOS */
|
|
258
|
-
.s-button-legacy-ios {
|
|
259
|
-
border-radius: 10px;
|
|
260
|
-
border: var(--t-border-width) solid var(--t-border);
|
|
261
|
-
background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%);
|
|
262
|
-
box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--t-shadow-xs);
|
|
263
|
-
font-weight: 600;
|
|
264
|
-
}
|
|
265
|
-
.s-button-legacy-ios.btn-filled {
|
|
266
|
-
background: linear-gradient(180deg, color-mix(in srgb, var(--t-primary) 80%, #fff) 0%, var(--t-primary) 100%);
|
|
267
|
-
color: #fff;
|
|
268
|
-
border-color: color-mix(in srgb, var(--t-primary) 80%, #000);
|
|
269
|
-
}
|
|
270
|
-
.s-button-legacy-ios:active {
|
|
271
|
-
transform: scale(0.95);
|
|
272
|
-
}
|
|
264
|
+
}
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
/* Variant - filled */
|
|
49
49
|
.btn-group-filled .s-btn-group-item.active {
|
|
50
50
|
background: var(--t-primary);
|
|
51
|
-
color:
|
|
51
|
+
color: var(--t-text-on-primary);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/* Variant - tonal */
|
|
@@ -107,10 +107,6 @@
|
|
|
107
107
|
.s-btn-group-liquid-glass { border-radius: 12px; backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); }
|
|
108
108
|
.s-btn-group-liquid-glass .s-btn-group-item { background: transparent; }
|
|
109
109
|
.s-btn-group-liquid-glass .s-btn-group-item:hover { background: rgba(255,255,255,0.1); }
|
|
110
|
-
|
|
111
|
-
/* Legacy iOS */
|
|
112
|
-
.s-btn-group-legacy-ios { border-radius: 8px; border: 1px solid var(--t-border); background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8); }
|
|
113
|
-
|
|
114
110
|
/* Material3 */
|
|
115
111
|
.s-btn-group-material3 { border-radius: 24px; }
|
|
116
112
|
|
|
@@ -90,12 +90,4 @@
|
|
|
90
90
|
}
|
|
91
91
|
.s-card-liquid-glass .demo-label,
|
|
92
92
|
.s-card-liquid-glass .text-muted,
|
|
93
|
-
.s-card-liquid-glass .text-hint { color: rgba(255,255,255,0.55); }
|
|
94
|
-
|
|
95
|
-
/* Legacy iOS */
|
|
96
|
-
.s-card-legacy-ios {
|
|
97
|
-
border-radius: 10px;
|
|
98
|
-
border: var(--t-border-width) solid var(--t-border);
|
|
99
|
-
background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%);
|
|
100
|
-
box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--t-shadow-sm);
|
|
101
|
-
}
|
|
93
|
+
.s-card-liquid-glass .text-hint { color: rgba(255,255,255,0.55); }
|
|
@@ -138,8 +138,4 @@
|
|
|
138
138
|
|
|
139
139
|
/* Liquid Glass */
|
|
140
140
|
.s-carousel-liquid-glass { backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); }
|
|
141
|
-
.s-carousel-liquid-glass .s-carousel-arrow { background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.2); }
|
|
142
|
-
|
|
143
|
-
/* Legacy iOS */
|
|
144
|
-
.s-carousel-legacy-ios { border: 1px solid var(--t-border); }
|
|
145
|
-
.s-carousel-legacy-ios .s-carousel-arrow { background: rgba(0,0,0,0.3); }
|
|
141
|
+
.s-carousel-liquid-glass .s-carousel-arrow { background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.2); }
|
|
@@ -113,7 +113,12 @@
|
|
|
113
113
|
chartInstance = null;
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
// Single effect: recreate on shape change, update in-place otherwise
|
|
116
|
+
// Single effect: recreate on shape change, update in-place otherwise.
|
|
117
|
+
// Creation is deferred until the canvas has a non-zero layout size — Chart.js
|
|
118
|
+
// initialized at 0×0 (e.g. chart mounted inside a hidden tab/accordion) reads
|
|
119
|
+
// a bogus size, then a ResizeObserver fires mid-entry-animation and breaks it
|
|
120
|
+
// (labels vanish, animation stalls). Waiting one frame + guarding on size
|
|
121
|
+
// lets layout settle before the first render.
|
|
117
122
|
$effect(() => {
|
|
118
123
|
if (!canvasEl) return;
|
|
119
124
|
|
|
@@ -138,13 +143,68 @@
|
|
|
138
143
|
// Shape changed (or first mount) — destroy old if any, then create new
|
|
139
144
|
if (existing) existing.destroy();
|
|
140
145
|
|
|
141
|
-
const ctx = canvas.getContext("2d");
|
|
142
146
|
const cfg = {
|
|
143
147
|
type,
|
|
144
148
|
data: buildData(type, { data: normalized.data, series: normalized.series, labels: normalized.labels }, tokens),
|
|
145
149
|
options: buildOptions(type, style, tokens, { title, legend, animated, userOptions: options, seriesCount, xAxisLabel, yAxisLabel }),
|
|
146
150
|
};
|
|
147
|
-
|
|
151
|
+
|
|
152
|
+
let rafId = 0;
|
|
153
|
+
let resizeId = 0;
|
|
154
|
+
let cancelled = false;
|
|
155
|
+
const container = canvas.parentElement;
|
|
156
|
+
const init = () => {
|
|
157
|
+
if (cancelled) return;
|
|
158
|
+
// Wait until the chart's container has a real layout size. Charts mount
|
|
159
|
+
// while their gallery section is display:none (parent 0×0); creating now
|
|
160
|
+
// yields a degenerate chartArea that hides axes/labels. The container
|
|
161
|
+
// (not the canvas — it has a 300×150 intrinsic default) is Chart.js's
|
|
162
|
+
// size source.
|
|
163
|
+
if (!container || container.clientWidth === 0 || container.clientHeight === 0) {
|
|
164
|
+
rafId = requestAnimationFrame(init);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
chartInstance = new ChartJS(canvas.getContext("2d"), cfg);
|
|
168
|
+
// Layout can still settle one frame after the container becomes visible;
|
|
169
|
+
// force a re-measure so the first render's chartArea is final and axes
|
|
170
|
+
// + labels draw.
|
|
171
|
+
resizeId = requestAnimationFrame(() => {
|
|
172
|
+
if (cancelled || !chartInstance) return;
|
|
173
|
+
chartInstance.resize();
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
rafId = requestAnimationFrame(init);
|
|
177
|
+
|
|
178
|
+
// Cancel any pending deferred init when deps change again or on unmount.
|
|
179
|
+
return () => {
|
|
180
|
+
cancelled = true;
|
|
181
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
182
|
+
if (resizeId) cancelAnimationFrame(resizeId);
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Color mode (dark/light) is toggled by adding/removing a class on <html>,
|
|
187
|
+
// which flips every --t-* token. That isn't a Svelte-reactive dep, so the
|
|
188
|
+
// main effect never re-runs and the chart keeps stale token colors — labels
|
|
189
|
+
// and axes render in the old mode's color and vanish against the new
|
|
190
|
+
// background. Watch <html>'s class and refresh colors in place.
|
|
191
|
+
$effect(() => {
|
|
192
|
+
if (!canvasEl) return;
|
|
193
|
+
const root = document.documentElement;
|
|
194
|
+
let isDark = root.classList.contains("dark");
|
|
195
|
+
const observer = new MutationObserver(() => {
|
|
196
|
+
const nowDark = root.classList.contains("dark");
|
|
197
|
+
if (nowDark === isDark) return;
|
|
198
|
+
isDark = nowDark;
|
|
199
|
+
const existing = ChartJS.getChart(canvasEl);
|
|
200
|
+
if (!existing) return;
|
|
201
|
+
const tokens = readTokens(canvasEl);
|
|
202
|
+
existing.data = buildData(type, { data: normalized.data, series: normalized.series, labels: normalized.labels }, tokens);
|
|
203
|
+
existing.options = buildOptions(type, style, tokens, { title, legend, animated, userOptions: options, seriesCount, xAxisLabel, yAxisLabel });
|
|
204
|
+
existing.update("none");
|
|
205
|
+
});
|
|
206
|
+
observer.observe(root, { attributes: true, attributeFilter: ["class"] });
|
|
207
|
+
return () => observer.disconnect();
|
|
148
208
|
});
|
|
149
209
|
|
|
150
210
|
function downloadChart() {
|
|
@@ -46,7 +46,7 @@ export function buildData(type: any, { data, series, labels }: {
|
|
|
46
46
|
* @param {object} tokens - resolved CSS theme tokens
|
|
47
47
|
* @param {{ title, legend, animated, userOptions, seriesCount, xAxisLabel, yAxisLabel }} params
|
|
48
48
|
*/
|
|
49
|
-
export function buildOptions(type: string, style: string, tokens: object, { title, legend, animated, userOptions, seriesCount, xAxisLabel, yAxisLabel }: {
|
|
49
|
+
export function buildOptions(type: string, style: string, tokens: object, { title, legend, animated, userOptions, seriesCount, xAxisLabel, yAxisLabel, }: {
|
|
50
50
|
title: any;
|
|
51
51
|
legend: any;
|
|
52
52
|
animated: any;
|
|
@@ -57,7 +57,32 @@ export function buildOptions(type: string, style: string, tokens: object, { titl
|
|
|
57
57
|
}): {
|
|
58
58
|
responsive: boolean;
|
|
59
59
|
maintainAspectRatio: boolean;
|
|
60
|
-
animation: boolean
|
|
60
|
+
animation: boolean | {
|
|
61
|
+
duration: number;
|
|
62
|
+
easing: string;
|
|
63
|
+
animateRotate: boolean;
|
|
64
|
+
animateScale: boolean;
|
|
65
|
+
animations?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
duration: number;
|
|
68
|
+
easing: string;
|
|
69
|
+
animateRotate?: undefined;
|
|
70
|
+
animateScale?: undefined;
|
|
71
|
+
animations?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
duration: number;
|
|
74
|
+
easing: string;
|
|
75
|
+
animations: {
|
|
76
|
+
x: {
|
|
77
|
+
type: string;
|
|
78
|
+
easing: string;
|
|
79
|
+
duration: number;
|
|
80
|
+
from: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
animateRotate?: undefined;
|
|
84
|
+
animateScale?: undefined;
|
|
85
|
+
};
|
|
61
86
|
color: any;
|
|
62
87
|
font: {
|
|
63
88
|
family: string;
|