@rokkit/core 1.0.0-next.122 → 1.0.0-next.124
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/colors/index.d.ts +2 -2
- package/dist/constants.d.ts +2 -1
- package/dist/theme.d.ts +63 -384
- package/dist/types.d.ts +55 -0
- package/package.json +2 -2
- package/src/colors/index.js +1 -1
- package/src/colors/syntax.json +4 -4
- package/src/constants.js +6 -5
- package/src/theme.js +19 -5
- package/src/types.js +36 -0
- package/src/utils.js +19 -17
package/dist/colors/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const syntaxColors: {
|
|
|
16
16
|
"--code-operator": string;
|
|
17
17
|
"--code-function": string;
|
|
18
18
|
"--code-gutter-marker": string;
|
|
19
|
-
"--code-gutter-
|
|
19
|
+
"--code-gutter-z2": string;
|
|
20
20
|
"--code-cursor": string;
|
|
21
21
|
"--code-cursor-block": string;
|
|
22
22
|
"--code-linenumbers": string;
|
|
@@ -35,7 +35,7 @@ export const syntaxColors: {
|
|
|
35
35
|
"--code-operator": string;
|
|
36
36
|
"--code-function": string;
|
|
37
37
|
"--code-gutter-marker": string;
|
|
38
|
-
"--code-gutter-
|
|
38
|
+
"--code-gutter-z2": string;
|
|
39
39
|
"--code-cursor": string;
|
|
40
40
|
"--code-cursor-block": string;
|
|
41
41
|
"--code-linenumbers": string;
|
package/dist/constants.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export namespace defaultKeyMap {
|
|
|
26
26
|
let Escape: string;
|
|
27
27
|
}
|
|
28
28
|
export namespace defaultThemeMapping {
|
|
29
|
-
let
|
|
29
|
+
let surface: string;
|
|
30
30
|
let primary: string;
|
|
31
31
|
let secondary: string;
|
|
32
32
|
let accent: string;
|
|
@@ -37,6 +37,7 @@ export namespace defaultThemeMapping {
|
|
|
37
37
|
let info: string;
|
|
38
38
|
}
|
|
39
39
|
export namespace TONE_MAP {
|
|
40
|
+
let z0: number;
|
|
40
41
|
let z1: number;
|
|
41
42
|
let z2: number;
|
|
42
43
|
let z3: number;
|
package/dist/theme.d.ts
CHANGED
|
@@ -26,382 +26,11 @@ export function semanticShortcuts(name: string): any[];
|
|
|
26
26
|
* Theme class for managing color palettes, mappings, and semantic shortcuts.
|
|
27
27
|
*/
|
|
28
28
|
export class Theme {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"100": string;
|
|
35
|
-
"200": string;
|
|
36
|
-
"300": string;
|
|
37
|
-
"400": string;
|
|
38
|
-
"500": string;
|
|
39
|
-
"600": string;
|
|
40
|
-
"700": string;
|
|
41
|
-
"800": string;
|
|
42
|
-
"900": string;
|
|
43
|
-
"950": string;
|
|
44
|
-
};
|
|
45
|
-
inherit: string;
|
|
46
|
-
current: string;
|
|
47
|
-
transparent: string;
|
|
48
|
-
black: string;
|
|
49
|
-
white: string;
|
|
50
|
-
rose: {
|
|
51
|
-
50: string;
|
|
52
|
-
100: string;
|
|
53
|
-
200: string;
|
|
54
|
-
300: string;
|
|
55
|
-
400: string;
|
|
56
|
-
500: string;
|
|
57
|
-
600: string;
|
|
58
|
-
700: string;
|
|
59
|
-
800: string;
|
|
60
|
-
900: string;
|
|
61
|
-
950: string;
|
|
62
|
-
};
|
|
63
|
-
pink: {
|
|
64
|
-
50: string;
|
|
65
|
-
100: string;
|
|
66
|
-
200: string;
|
|
67
|
-
300: string;
|
|
68
|
-
400: string;
|
|
69
|
-
500: string;
|
|
70
|
-
600: string;
|
|
71
|
-
700: string;
|
|
72
|
-
800: string;
|
|
73
|
-
900: string;
|
|
74
|
-
950: string;
|
|
75
|
-
};
|
|
76
|
-
fuchsia: {
|
|
77
|
-
50: string;
|
|
78
|
-
100: string;
|
|
79
|
-
200: string;
|
|
80
|
-
300: string;
|
|
81
|
-
400: string;
|
|
82
|
-
500: string;
|
|
83
|
-
600: string;
|
|
84
|
-
700: string;
|
|
85
|
-
800: string;
|
|
86
|
-
900: string;
|
|
87
|
-
950: string;
|
|
88
|
-
};
|
|
89
|
-
purple: {
|
|
90
|
-
50: string;
|
|
91
|
-
100: string;
|
|
92
|
-
200: string;
|
|
93
|
-
300: string;
|
|
94
|
-
400: string;
|
|
95
|
-
500: string;
|
|
96
|
-
600: string;
|
|
97
|
-
700: string;
|
|
98
|
-
800: string;
|
|
99
|
-
900: string;
|
|
100
|
-
950: string;
|
|
101
|
-
};
|
|
102
|
-
violet: {
|
|
103
|
-
50: string;
|
|
104
|
-
100: string;
|
|
105
|
-
200: string;
|
|
106
|
-
300: string;
|
|
107
|
-
400: string;
|
|
108
|
-
500: string;
|
|
109
|
-
600: string;
|
|
110
|
-
700: string;
|
|
111
|
-
800: string;
|
|
112
|
-
900: string;
|
|
113
|
-
950: string;
|
|
114
|
-
};
|
|
115
|
-
indigo: {
|
|
116
|
-
50: string;
|
|
117
|
-
100: string;
|
|
118
|
-
200: string;
|
|
119
|
-
300: string;
|
|
120
|
-
400: string;
|
|
121
|
-
500: string;
|
|
122
|
-
600: string;
|
|
123
|
-
700: string;
|
|
124
|
-
800: string;
|
|
125
|
-
900: string;
|
|
126
|
-
950: string;
|
|
127
|
-
};
|
|
128
|
-
blue: {
|
|
129
|
-
50: string;
|
|
130
|
-
100: string;
|
|
131
|
-
200: string;
|
|
132
|
-
300: string;
|
|
133
|
-
400: string;
|
|
134
|
-
500: string;
|
|
135
|
-
600: string;
|
|
136
|
-
700: string;
|
|
137
|
-
800: string;
|
|
138
|
-
900: string;
|
|
139
|
-
950: string;
|
|
140
|
-
};
|
|
141
|
-
sky: {
|
|
142
|
-
50: string;
|
|
143
|
-
100: string;
|
|
144
|
-
200: string;
|
|
145
|
-
300: string;
|
|
146
|
-
400: string;
|
|
147
|
-
500: string;
|
|
148
|
-
600: string;
|
|
149
|
-
700: string;
|
|
150
|
-
800: string;
|
|
151
|
-
900: string;
|
|
152
|
-
950: string;
|
|
153
|
-
};
|
|
154
|
-
cyan: {
|
|
155
|
-
50: string;
|
|
156
|
-
100: string;
|
|
157
|
-
200: string;
|
|
158
|
-
300: string;
|
|
159
|
-
400: string;
|
|
160
|
-
500: string;
|
|
161
|
-
600: string;
|
|
162
|
-
700: string;
|
|
163
|
-
800: string;
|
|
164
|
-
900: string;
|
|
165
|
-
950: string;
|
|
166
|
-
};
|
|
167
|
-
teal: {
|
|
168
|
-
50: string;
|
|
169
|
-
100: string;
|
|
170
|
-
200: string;
|
|
171
|
-
300: string;
|
|
172
|
-
400: string;
|
|
173
|
-
500: string;
|
|
174
|
-
600: string;
|
|
175
|
-
700: string;
|
|
176
|
-
800: string;
|
|
177
|
-
900: string;
|
|
178
|
-
950: string;
|
|
179
|
-
};
|
|
180
|
-
emerald: {
|
|
181
|
-
50: string;
|
|
182
|
-
100: string;
|
|
183
|
-
200: string;
|
|
184
|
-
300: string;
|
|
185
|
-
400: string;
|
|
186
|
-
500: string;
|
|
187
|
-
600: string;
|
|
188
|
-
700: string;
|
|
189
|
-
800: string;
|
|
190
|
-
900: string;
|
|
191
|
-
950: string;
|
|
192
|
-
};
|
|
193
|
-
green: {
|
|
194
|
-
50: string;
|
|
195
|
-
100: string;
|
|
196
|
-
200: string;
|
|
197
|
-
300: string;
|
|
198
|
-
400: string;
|
|
199
|
-
500: string;
|
|
200
|
-
600: string;
|
|
201
|
-
700: string;
|
|
202
|
-
800: string;
|
|
203
|
-
900: string;
|
|
204
|
-
950: string;
|
|
205
|
-
};
|
|
206
|
-
lime: {
|
|
207
|
-
50: string;
|
|
208
|
-
100: string;
|
|
209
|
-
200: string;
|
|
210
|
-
300: string;
|
|
211
|
-
400: string;
|
|
212
|
-
500: string;
|
|
213
|
-
600: string;
|
|
214
|
-
700: string;
|
|
215
|
-
800: string;
|
|
216
|
-
900: string;
|
|
217
|
-
950: string;
|
|
218
|
-
};
|
|
219
|
-
yellow: {
|
|
220
|
-
50: string;
|
|
221
|
-
100: string;
|
|
222
|
-
200: string;
|
|
223
|
-
300: string;
|
|
224
|
-
400: string;
|
|
225
|
-
500: string;
|
|
226
|
-
600: string;
|
|
227
|
-
700: string;
|
|
228
|
-
800: string;
|
|
229
|
-
900: string;
|
|
230
|
-
950: string;
|
|
231
|
-
};
|
|
232
|
-
amber: {
|
|
233
|
-
50: string;
|
|
234
|
-
100: string;
|
|
235
|
-
200: string;
|
|
236
|
-
300: string;
|
|
237
|
-
400: string;
|
|
238
|
-
500: string;
|
|
239
|
-
600: string;
|
|
240
|
-
700: string;
|
|
241
|
-
800: string;
|
|
242
|
-
900: string;
|
|
243
|
-
950: string;
|
|
244
|
-
};
|
|
245
|
-
orange: {
|
|
246
|
-
50: string;
|
|
247
|
-
100: string;
|
|
248
|
-
200: string;
|
|
249
|
-
300: string;
|
|
250
|
-
400: string;
|
|
251
|
-
500: string;
|
|
252
|
-
600: string;
|
|
253
|
-
700: string;
|
|
254
|
-
800: string;
|
|
255
|
-
900: string;
|
|
256
|
-
950: string;
|
|
257
|
-
};
|
|
258
|
-
red: {
|
|
259
|
-
50: string;
|
|
260
|
-
100: string;
|
|
261
|
-
200: string;
|
|
262
|
-
300: string;
|
|
263
|
-
400: string;
|
|
264
|
-
500: string;
|
|
265
|
-
600: string;
|
|
266
|
-
700: string;
|
|
267
|
-
800: string;
|
|
268
|
-
900: string;
|
|
269
|
-
950: string;
|
|
270
|
-
};
|
|
271
|
-
gray: {
|
|
272
|
-
50: string;
|
|
273
|
-
100: string;
|
|
274
|
-
200: string;
|
|
275
|
-
300: string;
|
|
276
|
-
400: string;
|
|
277
|
-
500: string;
|
|
278
|
-
600: string;
|
|
279
|
-
700: string;
|
|
280
|
-
800: string;
|
|
281
|
-
900: string;
|
|
282
|
-
950: string;
|
|
283
|
-
};
|
|
284
|
-
slate: {
|
|
285
|
-
50: string;
|
|
286
|
-
100: string;
|
|
287
|
-
200: string;
|
|
288
|
-
300: string;
|
|
289
|
-
400: string;
|
|
290
|
-
500: string;
|
|
291
|
-
600: string;
|
|
292
|
-
700: string;
|
|
293
|
-
800: string;
|
|
294
|
-
900: string;
|
|
295
|
-
950: string;
|
|
296
|
-
};
|
|
297
|
-
zinc: {
|
|
298
|
-
50: string;
|
|
299
|
-
100: string;
|
|
300
|
-
200: string;
|
|
301
|
-
300: string;
|
|
302
|
-
400: string;
|
|
303
|
-
500: string;
|
|
304
|
-
600: string;
|
|
305
|
-
700: string;
|
|
306
|
-
800: string;
|
|
307
|
-
900: string;
|
|
308
|
-
950: string;
|
|
309
|
-
};
|
|
310
|
-
neutral: {
|
|
311
|
-
50: string;
|
|
312
|
-
100: string;
|
|
313
|
-
200: string;
|
|
314
|
-
300: string;
|
|
315
|
-
400: string;
|
|
316
|
-
500: string;
|
|
317
|
-
600: string;
|
|
318
|
-
700: string;
|
|
319
|
-
800: string;
|
|
320
|
-
900: string;
|
|
321
|
-
950: string;
|
|
322
|
-
};
|
|
323
|
-
stone: {
|
|
324
|
-
50: string;
|
|
325
|
-
100: string;
|
|
326
|
-
200: string;
|
|
327
|
-
300: string;
|
|
328
|
-
400: string;
|
|
329
|
-
500: string;
|
|
330
|
-
600: string;
|
|
331
|
-
700: string;
|
|
332
|
-
800: string;
|
|
333
|
-
900: string;
|
|
334
|
-
950: string;
|
|
335
|
-
};
|
|
336
|
-
light: {
|
|
337
|
-
50: string;
|
|
338
|
-
100: string;
|
|
339
|
-
200: string;
|
|
340
|
-
300: string;
|
|
341
|
-
400: string;
|
|
342
|
-
500: string;
|
|
343
|
-
600: string;
|
|
344
|
-
700: string;
|
|
345
|
-
800: string;
|
|
346
|
-
900: string;
|
|
347
|
-
950: string;
|
|
348
|
-
};
|
|
349
|
-
dark: {
|
|
350
|
-
50: string;
|
|
351
|
-
100: string;
|
|
352
|
-
200: string;
|
|
353
|
-
300: string;
|
|
354
|
-
400: string;
|
|
355
|
-
500: string;
|
|
356
|
-
600: string;
|
|
357
|
-
700: string;
|
|
358
|
-
800: string;
|
|
359
|
-
900: string;
|
|
360
|
-
950: string;
|
|
361
|
-
};
|
|
362
|
-
lightblue: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
363
|
-
DEFAULT?: string;
|
|
364
|
-
});
|
|
365
|
-
lightBlue: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
366
|
-
DEFAULT?: string;
|
|
367
|
-
});
|
|
368
|
-
warmgray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
369
|
-
DEFAULT?: string;
|
|
370
|
-
});
|
|
371
|
-
warmGray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
372
|
-
DEFAULT?: string;
|
|
373
|
-
});
|
|
374
|
-
truegray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
375
|
-
DEFAULT?: string;
|
|
376
|
-
});
|
|
377
|
-
trueGray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
378
|
-
DEFAULT?: string;
|
|
379
|
-
});
|
|
380
|
-
coolgray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
381
|
-
DEFAULT?: string;
|
|
382
|
-
});
|
|
383
|
-
coolGray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
384
|
-
DEFAULT?: string;
|
|
385
|
-
});
|
|
386
|
-
bluegray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
387
|
-
DEFAULT?: string;
|
|
388
|
-
});
|
|
389
|
-
blueGray: string | (import("@unocss/preset-mini/dist/shared/preset-mini.BjJC-NnU.mjs").C & {
|
|
390
|
-
DEFAULT?: string;
|
|
391
|
-
});
|
|
392
|
-
} | undefined;
|
|
393
|
-
mapping?: {
|
|
394
|
-
neutral: string;
|
|
395
|
-
primary: string;
|
|
396
|
-
secondary: string;
|
|
397
|
-
accent: string;
|
|
398
|
-
success: string;
|
|
399
|
-
warning: string;
|
|
400
|
-
danger: string;
|
|
401
|
-
error: string;
|
|
402
|
-
info: string;
|
|
403
|
-
} | undefined;
|
|
404
|
-
});
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {import('./types.js').ColorTheme} param0
|
|
32
|
+
*/
|
|
33
|
+
constructor({ colors, mapping }?: import("./types.js").ColorTheme);
|
|
405
34
|
set colors(colors: {
|
|
406
35
|
shark: {
|
|
407
36
|
DEFAULT: string;
|
|
@@ -1129,26 +758,76 @@ export class Theme {
|
|
|
1129
758
|
});
|
|
1130
759
|
};
|
|
1131
760
|
set mapping(mapping: {
|
|
1132
|
-
|
|
761
|
+
/**
|
|
762
|
+
* - The primary color.
|
|
763
|
+
*/
|
|
1133
764
|
primary: string;
|
|
765
|
+
/**
|
|
766
|
+
* - The secondary color.
|
|
767
|
+
*/
|
|
1134
768
|
secondary: string;
|
|
1135
|
-
|
|
769
|
+
/**
|
|
770
|
+
* - The tertiary color.
|
|
771
|
+
*/
|
|
772
|
+
tertiary?: string | undefined;
|
|
773
|
+
/**
|
|
774
|
+
* - The surface color.
|
|
775
|
+
*/
|
|
776
|
+
surface: string;
|
|
777
|
+
/**
|
|
778
|
+
* - The info color.
|
|
779
|
+
*/
|
|
780
|
+
info: string;
|
|
781
|
+
/**
|
|
782
|
+
* - The success color.
|
|
783
|
+
*/
|
|
1136
784
|
success: string;
|
|
785
|
+
/**
|
|
786
|
+
* - The warning color.
|
|
787
|
+
*/
|
|
1137
788
|
warning: string;
|
|
1138
|
-
|
|
789
|
+
/**
|
|
790
|
+
* - The error color.
|
|
791
|
+
*/
|
|
1139
792
|
error: string;
|
|
1140
|
-
|
|
793
|
+
accent: string;
|
|
794
|
+
danger: string;
|
|
1141
795
|
});
|
|
1142
796
|
get mapping(): {
|
|
1143
|
-
|
|
797
|
+
/**
|
|
798
|
+
* - The primary color.
|
|
799
|
+
*/
|
|
1144
800
|
primary: string;
|
|
801
|
+
/**
|
|
802
|
+
* - The secondary color.
|
|
803
|
+
*/
|
|
1145
804
|
secondary: string;
|
|
1146
|
-
|
|
805
|
+
/**
|
|
806
|
+
* - The tertiary color.
|
|
807
|
+
*/
|
|
808
|
+
tertiary?: string | undefined;
|
|
809
|
+
/**
|
|
810
|
+
* - The surface color.
|
|
811
|
+
*/
|
|
812
|
+
surface: string;
|
|
813
|
+
/**
|
|
814
|
+
* - The info color.
|
|
815
|
+
*/
|
|
816
|
+
info: string;
|
|
817
|
+
/**
|
|
818
|
+
* - The success color.
|
|
819
|
+
*/
|
|
1147
820
|
success: string;
|
|
821
|
+
/**
|
|
822
|
+
* - The warning color.
|
|
823
|
+
*/
|
|
1148
824
|
warning: string;
|
|
1149
|
-
|
|
825
|
+
/**
|
|
826
|
+
* - The error color.
|
|
827
|
+
*/
|
|
1150
828
|
error: string;
|
|
1151
|
-
|
|
829
|
+
accent: string;
|
|
830
|
+
danger: string;
|
|
1152
831
|
};
|
|
1153
832
|
mapVariant(color: any, variant: any): {};
|
|
1154
833
|
getColorRules(mapping?: null): {};
|
package/dist/types.d.ts
CHANGED
|
@@ -243,3 +243,58 @@ export type CalendarDay = {
|
|
|
243
243
|
*/
|
|
244
244
|
weekend: boolean;
|
|
245
245
|
};
|
|
246
|
+
export type ColorPalette = {
|
|
247
|
+
/**
|
|
248
|
+
* 50 - The color for the 50 shade.
|
|
249
|
+
*/
|
|
250
|
+
"": string;
|
|
251
|
+
};
|
|
252
|
+
export type ColorCollection = {
|
|
253
|
+
[x: string]: ColorPalette;
|
|
254
|
+
};
|
|
255
|
+
export type ColorMapping = {
|
|
256
|
+
/**
|
|
257
|
+
* - The primary color.
|
|
258
|
+
*/
|
|
259
|
+
primary?: string | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* - The secondary color.
|
|
262
|
+
*/
|
|
263
|
+
secondary?: string | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* - The tertiary color.
|
|
266
|
+
*/
|
|
267
|
+
tertiary?: string | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* - The surface color.
|
|
270
|
+
*/
|
|
271
|
+
surface?: string | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* - The info color.
|
|
274
|
+
*/
|
|
275
|
+
info?: string | undefined;
|
|
276
|
+
/**
|
|
277
|
+
* - The success color.
|
|
278
|
+
*/
|
|
279
|
+
success?: string | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* - The warning color.
|
|
282
|
+
*/
|
|
283
|
+
warning?: string | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* - The error color.
|
|
286
|
+
*/
|
|
287
|
+
error?: string | undefined;
|
|
288
|
+
};
|
|
289
|
+
export type ColorTheme = {
|
|
290
|
+
/**
|
|
291
|
+
* - The color mapping.
|
|
292
|
+
*/
|
|
293
|
+
mapping?: ColorMapping | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* - The color collection.
|
|
296
|
+
*/
|
|
297
|
+
colors?: {
|
|
298
|
+
[x: string]: ColorPalette;
|
|
299
|
+
} | undefined;
|
|
300
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.124",
|
|
4
4
|
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"date-fns": "^4.1.0",
|
|
34
|
-
"ramda": "^0.
|
|
34
|
+
"ramda": "^0.31.3"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/colors/index.js
CHANGED
package/src/colors/syntax.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"one-dark": {
|
|
3
3
|
"dark": {
|
|
4
4
|
"--tab-size": "2",
|
|
5
|
-
"--code-fill": "var(--
|
|
5
|
+
"--code-fill": "var(--surface-100)",
|
|
6
6
|
"--code-normal": "#e06c75",
|
|
7
7
|
"--code-string": "#98c379",
|
|
8
8
|
"--code-number": "#d19a66",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"--code-operator": "#56b6c2",
|
|
15
15
|
"--code-function": "#61afef",
|
|
16
16
|
"--code-gutter-marker": "black",
|
|
17
|
-
"--code-gutter-
|
|
17
|
+
"--code-gutter-z2": "#999",
|
|
18
18
|
"--code-cursor": "#24292e",
|
|
19
19
|
"--code-cursor-block": "rgba(20, 255, 20, 0.5)",
|
|
20
20
|
"--code-linenumbers": "rgba(27, 31, 35, 0.3)"
|
|
21
21
|
},
|
|
22
22
|
"light": {
|
|
23
23
|
"--tab-size": "2",
|
|
24
|
-
"--code-fill": "var(--
|
|
24
|
+
"--code-fill": "var(--surface-100)",
|
|
25
25
|
"--code-normal": "#333333",
|
|
26
26
|
"--code-string": "#9D8248",
|
|
27
27
|
"--code-number": "#71A15D",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"--code-operator": "#bf5625",
|
|
34
34
|
"--code-function": "#a71d5d",
|
|
35
35
|
"--code-gutter-marker": "black",
|
|
36
|
-
"--code-gutter-
|
|
36
|
+
"--code-gutter-z2": "#999",
|
|
37
37
|
"--code-cursor": "#24292e",
|
|
38
38
|
"--code-cursor-block": "rgba(20, 255, 20, 0.5)",
|
|
39
39
|
"--code-linenumbers": "rgba(27, 31, 35, 0.3)"
|
package/src/constants.js
CHANGED
|
@@ -101,7 +101,7 @@ export const defaultKeyMap = {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export const defaultThemeMapping = {
|
|
104
|
-
|
|
104
|
+
surface: 'slate',
|
|
105
105
|
primary: 'orange',
|
|
106
106
|
secondary: 'pink',
|
|
107
107
|
accent: 'sky',
|
|
@@ -113,10 +113,11 @@ export const defaultThemeMapping = {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export const TONE_MAP = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
z0: 50,
|
|
117
|
+
z1: 100,
|
|
118
|
+
z2: 200,
|
|
119
|
+
z3: 300,
|
|
120
|
+
z4: 400,
|
|
120
121
|
z5: 500,
|
|
121
122
|
z6: 600,
|
|
122
123
|
z7: 700,
|
package/src/theme.js
CHANGED
|
@@ -41,7 +41,7 @@ function generateColorRules(variant, colors, mapping) {
|
|
|
41
41
|
return ['DEFAULT', ...shades].flatMap((shade) => [
|
|
42
42
|
{
|
|
43
43
|
key: shade === 'DEFAULT' ? `--color-${variant}` : `--color-${variant}-${shade}`,
|
|
44
|
-
value: colors[mapping[variant]][`${shade}`]
|
|
44
|
+
value: hex2rgb(colors[mapping[variant]][`${shade}`])
|
|
45
45
|
}
|
|
46
46
|
])
|
|
47
47
|
}
|
|
@@ -78,11 +78,18 @@ export function semanticShortcuts(name) {
|
|
|
78
78
|
|
|
79
79
|
for (const prefix of prefixes) {
|
|
80
80
|
// Variant-prefixed regex (e.g., hover:bg-primary-base)
|
|
81
|
-
const variantPattern = new RegExp(`^(.+):${prefix}-${name}-${toneName}
|
|
81
|
+
const variantPattern = new RegExp(`^(.+):${prefix}-${name}-${toneName}(\/\\d+)?$`)
|
|
82
82
|
shortcuts.push([
|
|
83
83
|
variantPattern,
|
|
84
|
-
([, variant]) =>
|
|
85
|
-
`${variant}:${prefix}-${name}-${lightValue} ${variant}:dark:${prefix}-${name}-${darkValue}`
|
|
84
|
+
([, variant, end]) =>
|
|
85
|
+
`${variant}:${prefix}-${name}-${lightValue}${end || ''} ${variant}:dark:${prefix}-${name}-${darkValue}${end || ''}`
|
|
86
|
+
])
|
|
87
|
+
|
|
88
|
+
const opacityPattern = new RegExp(`${prefix}-${name}-${toneName}(\/\\d+)?$`)
|
|
89
|
+
shortcuts.push([
|
|
90
|
+
opacityPattern,
|
|
91
|
+
([, end]) =>
|
|
92
|
+
`${prefix}-${name}-${lightValue}${end || ''} dark:${prefix}-${name}-${darkValue}${end || ''}`
|
|
86
93
|
])
|
|
87
94
|
|
|
88
95
|
// Exact static shortcut (e.g., bg-primary-base)
|
|
@@ -104,6 +111,10 @@ export class Theme {
|
|
|
104
111
|
#colors
|
|
105
112
|
#mapping
|
|
106
113
|
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param {import('./types.js').ColorTheme} param0
|
|
117
|
+
*/
|
|
107
118
|
constructor({ colors = defaultColors, mapping = defaultThemeMapping } = {}) {
|
|
108
119
|
this.#colors = { ...defaultColors, ...colors }
|
|
109
120
|
this.#mapping = { ...defaultThemeMapping, ...mapping }
|
|
@@ -127,7 +138,10 @@ export class Theme {
|
|
|
127
138
|
return Object.keys(color).reduce(
|
|
128
139
|
(acc, key) => ({
|
|
129
140
|
...acc,
|
|
130
|
-
[key]:
|
|
141
|
+
[key]:
|
|
142
|
+
key === 'DEFAULT'
|
|
143
|
+
? `rgba(var(--color-${variant}),<alpha-value>)`
|
|
144
|
+
: `rgba(var(--color-${variant}-${key}),<alpha-value>)`
|
|
131
145
|
}),
|
|
132
146
|
{}
|
|
133
147
|
)
|
package/src/types.js
CHANGED
|
@@ -121,4 +121,40 @@
|
|
|
121
121
|
* @property {boolean} weekend - Indicates if the day is on the weekend.
|
|
122
122
|
*/
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* @typedef {Object} ColorPalette
|
|
126
|
+
* @property {string} 50 - The color for the 50 shade.
|
|
127
|
+
* @property {string} 100 - The color for the 100 shade.
|
|
128
|
+
* @property {string} 200 - The color for the 200 shade.
|
|
129
|
+
* @property {string} 300 - The color for the 300 shade.
|
|
130
|
+
* @property {string} 400 - The color for the 400 shade.
|
|
131
|
+
* @property {string} 500 - The color for the 500 shade.
|
|
132
|
+
* @property {string} 600 - The color for the 600 shade.
|
|
133
|
+
* @property {string} 700 - The color for the 700 shade.
|
|
134
|
+
* @property {string} 800 - The color for the 800 shade.
|
|
135
|
+
* @property {string} 900 - The color for the 900 shade.
|
|
136
|
+
* @property {string} 950 - The color for the 950 shade.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @typedef {Object<string,ColorPalette>} ColorCollection
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @typedef {Object} ColorMapping
|
|
145
|
+
* @property {string} [primary] - The primary color.
|
|
146
|
+
* @property {string} [secondary] - The secondary color.
|
|
147
|
+
* @property {string} [tertiary] - The tertiary color.
|
|
148
|
+
* @property {string} [surface] - The surface color.
|
|
149
|
+
* @property {string} [info] - The info color.
|
|
150
|
+
* @property {string} [success] - The success color.
|
|
151
|
+
* @property {string} [warning] - The warning color.
|
|
152
|
+
* @property {string} [error] - The error color.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @typedef {Object} ColorTheme
|
|
157
|
+
* @property {ColorMapping} [mapping] - The color mapping.
|
|
158
|
+
* @property {ColorCollection} [colors] - The color collection.
|
|
159
|
+
*/
|
|
124
160
|
export default {}
|
package/src/utils.js
CHANGED
|
@@ -145,7 +145,7 @@ export const importIcons = (icons) => {
|
|
|
145
145
|
*/
|
|
146
146
|
export function hex2rgb(hex) {
|
|
147
147
|
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16))
|
|
148
|
-
return `${r}
|
|
148
|
+
return `${r},${g},${b}`
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -155,31 +155,33 @@ export function hex2rgb(hex) {
|
|
|
155
155
|
* @returns {boolean} - Returns true if the string is an image URL
|
|
156
156
|
*/
|
|
157
157
|
function isImageUrl(str) {
|
|
158
|
+
// Fallback regex-based validation
|
|
159
|
+
const fallbackValidation = () => {
|
|
160
|
+
const urlRegex = /^https?:\/\/.+\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff)(\?.*)?$/i
|
|
161
|
+
return urlRegex.test(str)
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
// Check if the string looks like a URL
|
|
159
165
|
try {
|
|
160
|
-
// Use browser-native URL constructor
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
// Use browser-native URL constructor if available
|
|
167
|
+
if (typeof URL !== 'undefined') {
|
|
168
|
+
const url = new URL(str)
|
|
169
|
+
// Only accept HTTP/HTTPS protocols
|
|
170
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
164
173
|
// Check common image extensions
|
|
165
174
|
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.tiff']
|
|
166
175
|
const path = url.pathname.toLowerCase()
|
|
167
|
-
|
|
168
|
-
if (imageExtensions.some((ext) => path.endsWith(ext))) {
|
|
169
|
-
return true
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
// Fallback regex-based URL validation for image extensions
|
|
173
|
-
const urlRegex = /^https?:\/\/.+\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff)(\?.*)?$/i
|
|
174
|
-
return urlRegex.test(str)
|
|
176
|
+
return imageExtensions.some((ext) => path.endsWith(ext))
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
// Fallback if URL constructor is not available
|
|
180
|
+
return fallbackValidation()
|
|
178
181
|
// eslint-disable-next-line no-unused-vars
|
|
179
182
|
} catch (e) {
|
|
180
|
-
// Fallback
|
|
181
|
-
|
|
182
|
-
return urlRegex.test(str)
|
|
183
|
+
// Fallback if URL constructor fails
|
|
184
|
+
return fallbackValidation()
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
/**
|