@celar-ui/svelte 2.0.0 → 2.0.2
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/buttons/TextBaseButton.svelte +2 -1
- package/dist/buttons/styles/button_utils.css +1 -1
- package/dist/buttons/styles/expanded_text_button.css +1 -1
- package/dist/containment/Spacer.svelte +1 -1
- package/dist/containment/styles/avatar.css +1 -1
- package/dist/containment/styles/breadcrumb.css +1 -1
- package/dist/containment/styles/card.css +1 -1
- package/dist/containment/styles/container.css +3 -3
- package/dist/containment/styles/surface-container.css +1 -1
- package/dist/inputs/Checkbox.svelte +6 -4
- package/dist/inputs/ColorInput.svelte +2 -4
- package/dist/inputs/FileInput.svelte +1 -1
- package/dist/inputs/RadioItem.svelte +2 -4
- package/dist/inputs/Slider.svelte +2 -3
- package/dist/inputs/Switch.svelte +2 -4
- package/dist/inputs/TagInput.svelte +1 -6
- package/dist/inputs/TextInput.svelte +1 -12
- package/dist/inputs/styles/radio_group.css +1 -1
- package/dist/misc/Badge.svelte +1 -1
- package/dist/misc/DuckSpinner.svelte +34 -34
- package/dist/misc/Gap.svelte +1 -1
- package/dist/misc/LinearProgressIndicator.svelte +10 -10
- package/dist/navigation/AdaptiveSidebar.svelte +2 -2
- package/dist/navigation/AppBar.svelte +2 -2
- package/dist/navigation/NavigationBar.svelte +1 -2
- package/dist/navigation/NavigationBarButton.svelte +1 -1
- package/dist/navigation/styles/navigation_drawer.css +1 -1
- package/dist/overlay/styles/command.css +2 -3
- package/dist/overlay/styles/dialog.css +5 -4
- package/dist/overlay/styles/popover.css +1 -1
- package/dist/overlay/styles/surface-dialog.css +1 -1
- package/package.json +9 -8
- package/src/bin/gen-theme.ts +71 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
children,
|
|
14
14
|
loading,
|
|
15
15
|
icon,
|
|
16
|
+
style,
|
|
16
17
|
active = false,
|
|
17
18
|
gap = 'calc(var(--spacing) * 2)',
|
|
18
19
|
...rest
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
let visibility = $derived(loading ? 'hidden' : 'initial');
|
|
21
22
|
</script>
|
|
22
23
|
|
|
23
|
-
<BaseButton {...rest} {loading} {active} data-button-base-text style="--body-gap: {gap}">
|
|
24
|
+
<BaseButton {...rest} {loading} {active} data-button-base-text style="--body-gap: {gap}; {style}">
|
|
24
25
|
{#if icon}
|
|
25
26
|
<span class="button-icon" style:visibility>
|
|
26
27
|
{@render icon()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@reference '
|
|
1
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
2
2
|
|
|
3
3
|
@layer components {
|
|
4
4
|
[data-container] {
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
&[data-sm='true'] {
|
|
15
|
-
max-width: var(--breakpoint
|
|
15
|
+
max-width: var(--breakpoint-sm);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&[data-md='true'] {
|
|
19
|
-
max-width: var(--breakpoint
|
|
19
|
+
max-width: var(--breakpoint-md);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
&[data-fluid='true'] {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
</label>
|
|
56
56
|
|
|
57
57
|
<style>
|
|
58
|
-
@reference '
|
|
58
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
59
59
|
|
|
60
60
|
@layer components {
|
|
61
61
|
[data-checkbox] {
|
|
@@ -67,9 +67,7 @@
|
|
|
67
67
|
padding: --spacing(1) 0;
|
|
68
68
|
padding-right: --spacing(4);
|
|
69
69
|
width: 100%;
|
|
70
|
-
|
|
71
|
-
-moz-user-select: none;
|
|
72
|
-
user-select: none;
|
|
70
|
+
user-select: none;
|
|
73
71
|
|
|
74
72
|
[data-checkbox-icon] {
|
|
75
73
|
display: flex;
|
|
@@ -97,5 +95,9 @@
|
|
|
97
95
|
:global([data-checkbox-root]:not([data-state='unchecked'])) {
|
|
98
96
|
background-color: var(--color-primary);
|
|
99
97
|
}
|
|
98
|
+
|
|
99
|
+
:global([data-checkbox-root]:focus-visible) {
|
|
100
|
+
@apply outline-primary outline outline-solid;
|
|
101
|
+
}
|
|
100
102
|
}
|
|
101
103
|
</style>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</label>
|
|
20
20
|
|
|
21
21
|
<style>
|
|
22
|
-
@reference '
|
|
22
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
23
23
|
|
|
24
24
|
@layer components {
|
|
25
25
|
[data-color-input] {
|
|
@@ -36,9 +36,7 @@
|
|
|
36
36
|
position: absolute;
|
|
37
37
|
top: 0;
|
|
38
38
|
right: 0;
|
|
39
|
-
|
|
40
|
-
-moz-appearance: none;
|
|
41
|
-
appearance: none;
|
|
39
|
+
appearance: none;
|
|
42
40
|
outline: none;
|
|
43
41
|
border: none;
|
|
44
42
|
border-radius: var(--radius-2xl);
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</label>
|
|
17
17
|
|
|
18
18
|
<style>
|
|
19
|
-
@reference '
|
|
19
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
20
20
|
|
|
21
21
|
@layer components {
|
|
22
22
|
[data-radio-item] {
|
|
@@ -28,9 +28,7 @@
|
|
|
28
28
|
padding: --spacing(1) 0;
|
|
29
29
|
padding-right: --spacing(4);
|
|
30
30
|
width: 100%;
|
|
31
|
-
|
|
32
|
-
-moz-user-select: none;
|
|
33
|
-
user-select: none;
|
|
31
|
+
user-select: none;
|
|
34
32
|
|
|
35
33
|
[data-radio-item-icon] {
|
|
36
34
|
width: --spacing(14);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
21
|
<style>
|
|
22
|
-
@reference '
|
|
22
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
23
23
|
|
|
24
24
|
@utility track {
|
|
25
25
|
@apply box-border h-2 w-full rounded-2xl border-none;
|
|
@@ -56,8 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
&,
|
|
58
58
|
&::-webkit-slider-thumb {
|
|
59
|
-
|
|
60
|
-
appearance: none;
|
|
59
|
+
appearance: none;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
&::-webkit-slider-runnable-track {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</label>
|
|
19
19
|
|
|
20
20
|
<style>
|
|
21
|
-
@reference '
|
|
21
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
22
22
|
|
|
23
23
|
@layer components {
|
|
24
24
|
[data-switch] {
|
|
@@ -29,9 +29,7 @@
|
|
|
29
29
|
justify-content: flex-start;
|
|
30
30
|
align-items: center;
|
|
31
31
|
width: 100%;
|
|
32
|
-
|
|
33
|
-
-moz-user-select: none;
|
|
34
|
-
user-select: none;
|
|
32
|
+
user-select: none;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
:global([data-switch-root]) {
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
</div>
|
|
107
107
|
|
|
108
108
|
<style>
|
|
109
|
-
@reference '
|
|
109
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
110
110
|
|
|
111
111
|
@layer components {
|
|
112
112
|
[data-tag-input] {
|
|
@@ -137,11 +137,6 @@
|
|
|
137
137
|
font-family: inherit;
|
|
138
138
|
color: inherit;
|
|
139
139
|
|
|
140
|
-
&::-moz-placeholder {
|
|
141
|
-
@apply text-onBackground/70;
|
|
142
|
-
opacity: 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
140
|
&::placeholder {
|
|
146
141
|
@apply text-onBackground/70;
|
|
147
142
|
opacity: 1;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</label>
|
|
21
21
|
|
|
22
22
|
<style>
|
|
23
|
-
@reference '
|
|
23
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
24
24
|
|
|
25
25
|
@layer components {
|
|
26
26
|
[data-text-input] {
|
|
@@ -52,23 +52,12 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
&:is(:-moz-placeholder) ~ [data-text-input-placeholder] {
|
|
56
|
-
transform: translateY(50%);
|
|
57
|
-
visibility: hidden;
|
|
58
|
-
opacity: 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
55
|
&:is(:placeholder-shown) ~ [data-text-input-placeholder] {
|
|
62
56
|
transform: translateY(50%);
|
|
63
57
|
visibility: hidden;
|
|
64
58
|
opacity: 0;
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
&::-moz-placeholder {
|
|
68
|
-
@apply text-onBackground/70;
|
|
69
|
-
opacity: 1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
61
|
&::placeholder {
|
|
73
62
|
@apply text-onBackground/70;
|
|
74
63
|
opacity: 1;
|
package/dist/misc/Badge.svelte
CHANGED
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
</svg>
|
|
139
139
|
|
|
140
140
|
<style>
|
|
141
|
-
@reference '
|
|
141
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
142
142
|
|
|
143
143
|
@layer components {
|
|
144
144
|
[data-duck-spinner] {
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
stroke-linecap: round;
|
|
150
150
|
stroke-linejoin: round;
|
|
151
151
|
stroke-dasharray: none;
|
|
152
|
-
transition-duration: var(--
|
|
152
|
+
transition-duration: var(--default-transition-duration, 150ms);
|
|
153
153
|
transition-property: stroke;
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -171,15 +171,6 @@
|
|
|
171
171
|
opacity: 0.32;
|
|
172
172
|
animation-direction: reverse;
|
|
173
173
|
}
|
|
174
|
-
|
|
175
|
-
@keyframes spin {
|
|
176
|
-
from {
|
|
177
|
-
rotate: 0;
|
|
178
|
-
}
|
|
179
|
-
to {
|
|
180
|
-
rotate: 359deg;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
174
|
}
|
|
184
175
|
|
|
185
176
|
.duck {
|
|
@@ -190,18 +181,6 @@
|
|
|
190
181
|
animation-iteration-count: infinite;
|
|
191
182
|
animation-name: slay;
|
|
192
183
|
|
|
193
|
-
@keyframes slay {
|
|
194
|
-
0% {
|
|
195
|
-
rotate: -24deg;
|
|
196
|
-
}
|
|
197
|
-
50% {
|
|
198
|
-
rotate: 24deg;
|
|
199
|
-
}
|
|
200
|
-
100% {
|
|
201
|
-
rotate: -24deg;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
184
|
.body {
|
|
206
185
|
stroke-width: 1.5;
|
|
207
186
|
}
|
|
@@ -210,22 +189,43 @@
|
|
|
210
189
|
stroke-width: 1;
|
|
211
190
|
}
|
|
212
191
|
}
|
|
213
|
-
}
|
|
214
192
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.duck {
|
|
221
|
-
.body {
|
|
222
|
-
stroke-width: 1;
|
|
193
|
+
&[data-thin='true'] {
|
|
194
|
+
.line {
|
|
195
|
+
stroke-width: 0.5;
|
|
223
196
|
}
|
|
224
197
|
|
|
225
|
-
.
|
|
226
|
-
|
|
198
|
+
.duck {
|
|
199
|
+
.body {
|
|
200
|
+
stroke-width: 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.eye {
|
|
204
|
+
stroke-width: 0.8;
|
|
205
|
+
}
|
|
227
206
|
}
|
|
228
207
|
}
|
|
229
208
|
}
|
|
209
|
+
|
|
210
|
+
@keyframes slay {
|
|
211
|
+
0% {
|
|
212
|
+
rotate: -24deg;
|
|
213
|
+
}
|
|
214
|
+
50% {
|
|
215
|
+
rotate: 24deg;
|
|
216
|
+
}
|
|
217
|
+
100% {
|
|
218
|
+
rotate: -24deg;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@keyframes spin {
|
|
223
|
+
from {
|
|
224
|
+
rotate: 0;
|
|
225
|
+
}
|
|
226
|
+
to {
|
|
227
|
+
rotate: 359deg;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
230
|
}
|
|
231
231
|
</style>
|
package/dist/misc/Gap.svelte
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<style>
|
|
11
|
-
@reference '
|
|
11
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
12
12
|
|
|
13
13
|
@layer components {
|
|
14
14
|
[data-linear-progress-indicator] {
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
width: 0;
|
|
32
32
|
height: 100%;
|
|
33
33
|
}
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
36
|
+
@keyframes linear-progress-animation {
|
|
37
|
+
0% {
|
|
38
|
+
left: -8%;
|
|
39
|
+
width: 8%;
|
|
40
|
+
}
|
|
41
|
+
100% {
|
|
42
|
+
left: 100%;
|
|
43
|
+
width: 100%;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
49
|
<style>
|
|
50
|
-
@reference '
|
|
50
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
51
51
|
|
|
52
52
|
@layer components {
|
|
53
53
|
[data-adaptive-sidebar-backdrop] {
|
|
54
|
-
@apply bg-onBackground/20 blur
|
|
54
|
+
@apply bg-onBackground/20 backdrop-blur transition-all;
|
|
55
55
|
position: fixed;
|
|
56
56
|
top: 0;
|
|
57
57
|
left: 0;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
</section>
|
|
29
29
|
|
|
30
30
|
<style>
|
|
31
|
-
@reference '
|
|
31
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
32
32
|
|
|
33
33
|
@layer components {
|
|
34
34
|
[data-app-bar] {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
[data-app-bar-left] {
|
|
46
46
|
display: flex;
|
|
47
47
|
align-items: center;
|
|
48
|
-
gap:
|
|
48
|
+
gap: --spacing(2);
|
|
49
49
|
overflow: hidden;
|
|
50
50
|
|
|
51
51
|
[data-app-bar-title] {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</section>
|
|
10
10
|
|
|
11
11
|
<style>
|
|
12
|
-
@reference '
|
|
12
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
13
13
|
|
|
14
14
|
@layer components {
|
|
15
15
|
[data-navigation-bar] {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
border-top-left-radius: 0;
|
|
30
30
|
border-bottom-right-radius: var(--radius);
|
|
31
31
|
padding: 0 --spacing(2);
|
|
32
|
-
width: -moz-min-content;
|
|
33
32
|
width: min-content;
|
|
34
33
|
height: 100%;
|
|
35
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@reference '
|
|
1
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
2
2
|
|
|
3
3
|
@layer components {
|
|
4
4
|
[data-command-dialog] {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
max-height: calc(75dvh - --spacing(8));
|
|
9
9
|
|
|
10
10
|
[data-command-input] {
|
|
11
|
-
@apply border-onBackground/20 border border-solid;
|
|
11
|
+
@apply border-onBackground/20 border border-solid transition-colors;
|
|
12
12
|
background-color: var(--color-background);
|
|
13
13
|
border-radius: var(--radius-lg);
|
|
14
14
|
padding: --spacing(2);
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
line-height: 1.5;
|
|
18
18
|
color: var(--color-onSurface);
|
|
19
19
|
outline: none;
|
|
20
|
-
transition: border-color var(--tw-duration, 150ms) ease-in-out;
|
|
21
20
|
width: 100%;
|
|
22
21
|
box-sizing: border-box;
|
|
23
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@reference '
|
|
1
|
+
@reference '@celar-ui/svelte/styles/index.css';
|
|
2
2
|
|
|
3
3
|
@layer components {
|
|
4
4
|
[data-celar-dialog-overlay] {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
[data-celar-dialog-content] {
|
|
15
|
-
|
|
15
|
+
@apply shadow-xl;
|
|
16
|
+
box-sizing: border-box;
|
|
16
17
|
position: fixed;
|
|
17
18
|
top: calc(50dvh - --spacing(4));
|
|
18
19
|
left: calc(50lvw - --spacing(4));
|
|
@@ -29,10 +30,10 @@
|
|
|
29
30
|
max-width: min(calc(100% - --spacing(8)), var(--breakpoint-xs));
|
|
30
31
|
}
|
|
31
32
|
&[data-sm='true'] {
|
|
32
|
-
max-width: min(calc(100% - --spacing(8)), var(--breakpoint
|
|
33
|
+
max-width: min(calc(100% - --spacing(8)), var(--breakpoint-sm));
|
|
33
34
|
}
|
|
34
35
|
&[data-md='true'] {
|
|
35
|
-
max-width: min(calc(100% - --spacing(8)), var(--breakpoint
|
|
36
|
+
max-width: min(calc(100% - --spacing(8)), var(--breakpoint-md));
|
|
36
37
|
}
|
|
37
38
|
&[data-fluid='true'] {
|
|
38
39
|
width: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celar-ui/svelte",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "cuikho210",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "vite dev",
|
|
16
|
-
"build": "vite build &&
|
|
16
|
+
"build": "vite build && bun run prepack",
|
|
17
17
|
"preview": "vite preview",
|
|
18
18
|
"prepare": "svelte-kit sync || echo ''",
|
|
19
19
|
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
29
|
"src/styles",
|
|
30
|
+
"src/bin",
|
|
30
31
|
"!dist/**/*.test.*",
|
|
31
32
|
"!dist/**/*.spec.*"
|
|
32
33
|
],
|
|
@@ -41,10 +42,12 @@
|
|
|
41
42
|
"types": "./dist/index.d.ts",
|
|
42
43
|
"svelte": "./dist/index.js"
|
|
43
44
|
},
|
|
44
|
-
"./src/styles
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
"./styles/index.css": "./src/styles/index.css",
|
|
46
|
+
"./styles/theme.css": "./src/styles/theme.css",
|
|
47
|
+
"./styles/*.css": "./src/styles/*.css"
|
|
48
|
+
},
|
|
49
|
+
"bin": {
|
|
50
|
+
"gen-theme": "./src/bin/gen-theme.ts"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"bits-ui": "^2.8.0",
|
|
@@ -59,7 +62,6 @@
|
|
|
59
62
|
"@sveltejs/package": "^2.5.7",
|
|
60
63
|
"@sveltejs/vite-plugin-svelte": "^5.1.1",
|
|
61
64
|
"@tailwindcss/vite": "^4.2.2",
|
|
62
|
-
"autoprefixer": "^10.4.27",
|
|
63
65
|
"bits-ui": "^2.17.3",
|
|
64
66
|
"csstype": "^3.2.3",
|
|
65
67
|
"eslint": "^9.39.4",
|
|
@@ -71,7 +73,6 @@
|
|
|
71
73
|
"prettier-plugin-svelte": "^3.5.1",
|
|
72
74
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
73
75
|
"publint": "^0.3.18",
|
|
74
|
-
"sass": "^1.99.0",
|
|
75
76
|
"svelte": "^5.55.3",
|
|
76
77
|
"svelte-check": "^4.4.6",
|
|
77
78
|
"tailwindcss": "^4.2.2",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate Tailwind 4 @theme CSS from Material Color Utilities theme output.
|
|
5
|
+
* Usage: bun index.ts <output-path>
|
|
6
|
+
*
|
|
7
|
+
* This script generates a CSS file with @variant and @theme directives,
|
|
8
|
+
* using the output of Material Color Utilities' themeFromSourceColor.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import materialDynamicColors from 'material-dynamic-colors';
|
|
12
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
|
|
15
|
+
// ---- CONFIGURABLE SOURCE COLOR / OUTPUT ----
|
|
16
|
+
const argv = process.argv.slice(2);
|
|
17
|
+
const getFlag = (names: string[]) => {
|
|
18
|
+
const i = argv.findIndex((a) => names.includes(a));
|
|
19
|
+
if (i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--')) return argv[i + 1];
|
|
20
|
+
const kv = argv.find((a) => names.some((n) => a.startsWith(`${n}=`)));
|
|
21
|
+
return kv ? kv.split('=').slice(1).join('=') : undefined;
|
|
22
|
+
};
|
|
23
|
+
const sourceColor = (getFlag(['--color', '-c']) || process.env.SOURCE_COLOR || '#ff907f').trim();
|
|
24
|
+
const outputPath = path.resolve(
|
|
25
|
+
process.cwd(),
|
|
26
|
+
getFlag(['--out', '-o']) || process.env.OUTPUT_PATH || 'src/styles/theme.css'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// ---- GENERATE THEME ----
|
|
30
|
+
const theme = await materialDynamicColors(sourceColor);
|
|
31
|
+
|
|
32
|
+
// ---- TAILWIND 4 @THEME CSS OUTPUT ----
|
|
33
|
+
function toThemeVariables(colors: Record<string, string>): string {
|
|
34
|
+
return Object.entries(colors)
|
|
35
|
+
.map(([k, v]) => ` --color-${k}: ${v};`)
|
|
36
|
+
.join('\n');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const lightVars = toThemeVariables(theme.light as unknown as Record<string, string>);
|
|
40
|
+
const darkVars = toThemeVariables(theme.dark as unknown as Record<string, string>);
|
|
41
|
+
|
|
42
|
+
const css = `/* Generated by index.ts */
|
|
43
|
+
/* Source color: ${sourceColor} */
|
|
44
|
+
|
|
45
|
+
@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));
|
|
46
|
+
|
|
47
|
+
@theme {
|
|
48
|
+
${lightVars}
|
|
49
|
+
--color-info: #1a3baa;
|
|
50
|
+
--color-onInfo: #e2ffff;
|
|
51
|
+
--color-success: #2b5f50;
|
|
52
|
+
--color-onSuccess: #e8fef5;
|
|
53
|
+
--color-warning: #8a5a00;
|
|
54
|
+
--color-onWarning: #fff8ec;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@variant dark {
|
|
58
|
+
${darkVars}
|
|
59
|
+
--color-info: #008eff;
|
|
60
|
+
--color-onInfo: #101a3b;
|
|
61
|
+
--color-success: #9bdac7;
|
|
62
|
+
--color-onSuccess: #184d3a;
|
|
63
|
+
--color-warning: #bfa060;
|
|
64
|
+
--color-onWarning: #4a3700;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
// ---- WRITE FILE ----
|
|
69
|
+
await mkdir(path.dirname(outputPath), { recursive: true });
|
|
70
|
+
await writeFile(outputPath, css);
|
|
71
|
+
console.log(`Material theme CSS written to ${outputPath}`);
|