@vinicunca/unocss-preset 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{akar-SLlHrcnC.js → akar-B30zjk5t.js} +134 -18
- package/dist/index.d.ts +8 -0
- package/dist/index.js +101 -9
- package/package.json +1 -1
|
@@ -2,33 +2,25 @@ import { compressCSS } from "./utils-DZIu2j5I.js";
|
|
|
2
2
|
import { isString } from "@vinicunca/perkakas";
|
|
3
3
|
import { theme } from "unocss/preset-wind4";
|
|
4
4
|
|
|
5
|
-
//#region src/presets/akar/akar.brand-
|
|
5
|
+
//#region src/presets/akar/akar.brand-css-variables.ts
|
|
6
6
|
function isHexColor(value) {
|
|
7
7
|
return /^#([A-F0-9]{6}|[A-F0-9]{3})$/i.test(value);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function getAkarPreflight(options) {
|
|
10
10
|
return {
|
|
11
11
|
layer: "theme",
|
|
12
12
|
getCSS: () => {
|
|
13
13
|
const brands = options.brands ?? {};
|
|
14
14
|
const lightVars = [];
|
|
15
15
|
const darkVars = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
if (isString(value) && isHexColor(value)) {
|
|
22
|
-
lightBrand = value;
|
|
23
|
-
darkBrand = value;
|
|
24
|
-
} else {
|
|
25
|
-
const colorValue = theme.colors[value];
|
|
26
|
-
lightBrand = colorValue?.[500];
|
|
27
|
-
darkBrand = colorValue?.[400];
|
|
28
|
-
}
|
|
29
|
-
lightVars.push(`--akar-brand-${brandName}: ${lightBrand};`);
|
|
30
|
-
darkVars.push(`--akar-brand-${brandName}: ${darkBrand};`);
|
|
16
|
+
addBrandsVariables({
|
|
17
|
+
brands,
|
|
18
|
+
lightVars,
|
|
19
|
+
darkVars
|
|
31
20
|
});
|
|
21
|
+
const { lightVars: pohonLightVars, darkVars: pohonDarkVars } = addPohonNeutralVariables(options);
|
|
22
|
+
lightVars.push(...pohonLightVars);
|
|
23
|
+
darkVars.push(...pohonDarkVars);
|
|
32
24
|
return compressCSS(`
|
|
33
25
|
:root {
|
|
34
26
|
${lightVars.join("\n ")}
|
|
@@ -41,6 +33,67 @@ function getBrandPreflight(options) {
|
|
|
41
33
|
}
|
|
42
34
|
};
|
|
43
35
|
}
|
|
36
|
+
function addBrandsVariables({ brands = {}, lightVars, darkVars }) {
|
|
37
|
+
Object.entries(brands).forEach(([brandName, value]) => {
|
|
38
|
+
let lightBrand, darkBrand;
|
|
39
|
+
/**
|
|
40
|
+
* If the value is a hex color, use it directly.
|
|
41
|
+
*/
|
|
42
|
+
if (isString(value) && isHexColor(value)) {
|
|
43
|
+
lightBrand = value;
|
|
44
|
+
darkBrand = value;
|
|
45
|
+
} else {
|
|
46
|
+
const colorValue = theme.colors[value];
|
|
47
|
+
lightBrand = colorValue?.[500];
|
|
48
|
+
darkBrand = colorValue?.[400];
|
|
49
|
+
}
|
|
50
|
+
lightVars.push(`--akar-brand-${brandName}: ${lightBrand};`);
|
|
51
|
+
darkVars.push(`--akar-brand-${brandName}: ${darkBrand};`);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function addPohonNeutralVariables(options) {
|
|
55
|
+
if (!Boolean(options.pohonThemes)) return {
|
|
56
|
+
lightVars: [],
|
|
57
|
+
darkVars: []
|
|
58
|
+
};
|
|
59
|
+
const brandColor = options.brands?.neutral;
|
|
60
|
+
const neutralColor = theme.colors[brandColor ?? "slate"];
|
|
61
|
+
return {
|
|
62
|
+
lightVars: [
|
|
63
|
+
`--pohon-text-muted: ${neutralColor[500]}`,
|
|
64
|
+
`--pohon-text-toned: ${neutralColor[600]}`,
|
|
65
|
+
`--pohon-text: ${neutralColor[700]}`,
|
|
66
|
+
`--pohon-text-highlighted: ${neutralColor[900]}`,
|
|
67
|
+
`--pohon-text-inverted: ${neutralColor[100]}`,
|
|
68
|
+
`--pohon-bg: ${neutralColor[100]}`,
|
|
69
|
+
`--pohon-bg-muted: ${neutralColor[50]}`,
|
|
70
|
+
`--pohon-bg-elevated: ${neutralColor[100]}`,
|
|
71
|
+
`--pohon-bg-accented: ${neutralColor[200]}`,
|
|
72
|
+
`--pohon-bg-inverted: ${neutralColor[900]}`,
|
|
73
|
+
`--pohon-border: ${neutralColor[200]}`,
|
|
74
|
+
`--pohon-border-muted: ${neutralColor[200]}`,
|
|
75
|
+
`--pohon-border-accented: ${neutralColor[300]}`,
|
|
76
|
+
`--pohon-border-inverted: ${neutralColor[900]}`
|
|
77
|
+
],
|
|
78
|
+
darkVars: [
|
|
79
|
+
`--pohon-text-dimmed: ${neutralColor[500]}`,
|
|
80
|
+
`--pohon-text-muted: ${neutralColor[400]}`,
|
|
81
|
+
`--pohon-text-toned: ${neutralColor[300]}`,
|
|
82
|
+
`--pohon-text: ${neutralColor[200]}`,
|
|
83
|
+
`--pohon-text-highlighted: ${neutralColor[100]}`,
|
|
84
|
+
`--pohon-text-inverted: ${neutralColor[900]}`,
|
|
85
|
+
`--pohon-bg: ${neutralColor[900]}`,
|
|
86
|
+
`--pohon-bg-muted: ${neutralColor[800]}`,
|
|
87
|
+
`--pohon-bg-elevated: ${neutralColor[800]}`,
|
|
88
|
+
`--pohon-bg-accented: ${neutralColor[700]}`,
|
|
89
|
+
`--pohon-bg-inverted: ${neutralColor[100]}`,
|
|
90
|
+
`--pohon-border: ${neutralColor[800]}`,
|
|
91
|
+
`--pohon-border-muted: ${neutralColor[700]}`,
|
|
92
|
+
`--pohon-border-accented: ${neutralColor[700]}`,
|
|
93
|
+
`--pohon-border-inverted: ${neutralColor[100]}`
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
44
97
|
|
|
45
98
|
//#endregion
|
|
46
99
|
//#region src/presets/akar/akar.drawer-preflights.ts
|
|
@@ -234,9 +287,72 @@ const drawerPreflight = {
|
|
|
234
287
|
//#endregion
|
|
235
288
|
//#region src/presets/akar/index.ts
|
|
236
289
|
function presetAkar(options) {
|
|
290
|
+
const preflights = [getAkarPreflight(options)];
|
|
291
|
+
if (options.enableDrawer) preflights.push(drawerPreflight);
|
|
237
292
|
return {
|
|
238
293
|
name: "unocss-preset-akar",
|
|
239
|
-
preflights
|
|
294
|
+
preflights,
|
|
295
|
+
theme: { colors: { ...resolveTheme(options.pohonThemes) } }
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function resolveTheme(pohon) {
|
|
299
|
+
if (!Boolean(pohon)) return {};
|
|
300
|
+
return {
|
|
301
|
+
text: {
|
|
302
|
+
dimmed: "var(--pohon-text-dimmed)",
|
|
303
|
+
muted: "var(--pohon-text-muted)",
|
|
304
|
+
toned: "var(--pohon-text-toned)",
|
|
305
|
+
DEFAULT: "var(--pohon-text)",
|
|
306
|
+
highlighted: "var(--pohon-text-highlighted)",
|
|
307
|
+
inverted: "var(--pohon-text-inverted)"
|
|
308
|
+
},
|
|
309
|
+
background: {
|
|
310
|
+
DEFAULT: "var(--pohon-bg)",
|
|
311
|
+
muted: "var(--pohon-bg-muted)",
|
|
312
|
+
elevated: "var(--pohon-bg-elevated)",
|
|
313
|
+
accented: "var(--pohon-bg-accented)",
|
|
314
|
+
inverted: "var(--pohon-bg-inverted)",
|
|
315
|
+
border: "var(--pohon-border)"
|
|
316
|
+
},
|
|
317
|
+
border: {
|
|
318
|
+
DEFAULT: "var(--pohon-border)",
|
|
319
|
+
muted: "var(--pohon-border-muted)",
|
|
320
|
+
accented: "var(--pohon-border-accented)",
|
|
321
|
+
inverted: "var(--pohon-border-inverted)",
|
|
322
|
+
bg: "var(--pohon-bg)"
|
|
323
|
+
},
|
|
324
|
+
ring: {
|
|
325
|
+
DEFAULT: "var(--pohon-border)",
|
|
326
|
+
muted: "var(--pohon-border-muted)",
|
|
327
|
+
accented: "var(--pohon-border-accented)",
|
|
328
|
+
inverted: "var(--pohon-border-inverted)",
|
|
329
|
+
bg: "var(--pohon-bg)",
|
|
330
|
+
offset: {
|
|
331
|
+
DEFAULT: "var(--pohon-border)",
|
|
332
|
+
muted: "var(--pohon-border-muted)",
|
|
333
|
+
accented: "var(--pohon-border-accented)",
|
|
334
|
+
inverted: "var(--pohon-border-inverted)",
|
|
335
|
+
bg: "var(--pohon-bg)"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
divide: {
|
|
339
|
+
DEFAULT: "var(--pohon-border)",
|
|
340
|
+
muted: "var(--pohon-border-muted)",
|
|
341
|
+
accented: "var(--pohon-border-accented)",
|
|
342
|
+
inverted: "var(--pohon-border-inverted)"
|
|
343
|
+
},
|
|
344
|
+
outline: {
|
|
345
|
+
DEFAULT: "var(--pohon-border)",
|
|
346
|
+
inverted: "var(--pohon-border-inverted)"
|
|
347
|
+
},
|
|
348
|
+
stroke: {
|
|
349
|
+
DEFAULT: "var(--pohon-border)",
|
|
350
|
+
inverted: "var(--pohon-border-inverted)"
|
|
351
|
+
},
|
|
352
|
+
fill: {
|
|
353
|
+
DEFAULT: "var(--pohon-border)",
|
|
354
|
+
inverted: "var(--pohon-border-inverted)"
|
|
355
|
+
}
|
|
240
356
|
};
|
|
241
357
|
}
|
|
242
358
|
|
package/dist/index.d.ts
CHANGED
|
@@ -157,6 +157,14 @@ interface VinicuncaAkarOptions {
|
|
|
157
157
|
keyframes?: VinicuncaExtends['keyframes'];
|
|
158
158
|
animation?: VinicuncaExtends['animation'];
|
|
159
159
|
brands?: Theme$1['colors'];
|
|
160
|
+
enableDrawer?: boolean;
|
|
161
|
+
pohonThemes?: boolean | {
|
|
162
|
+
variables?: {
|
|
163
|
+
light?: Record<string, string>;
|
|
164
|
+
dark?: Record<string, string>;
|
|
165
|
+
};
|
|
166
|
+
themes?: Theme$1['colors'];
|
|
167
|
+
};
|
|
160
168
|
}
|
|
161
169
|
interface PreflightOptions {
|
|
162
170
|
/**
|
package/dist/index.js
CHANGED
|
@@ -577,13 +577,97 @@ const DEFAULT_AKAR_OPTIONS = {
|
|
|
577
577
|
"collapsible-up": {
|
|
578
578
|
from: { height: "var(--akar-collapsible-content-height)" },
|
|
579
579
|
to: { height: 0 }
|
|
580
|
+
},
|
|
581
|
+
"toast-collapsed-closed": {
|
|
582
|
+
from: { transform: "var(--transform)" },
|
|
583
|
+
to: { transform: "translateY(calc((var(--before) - var(--height)) * var(--gap))) scale(var(--scale))" }
|
|
584
|
+
},
|
|
585
|
+
"toast-closed": {
|
|
586
|
+
from: { transform: "var(--transform)" },
|
|
587
|
+
to: { transform: "translateY(calc((var(--offset) - var(--height)) * var(--translate-factor)))" }
|
|
588
|
+
},
|
|
589
|
+
"carousel": {
|
|
590
|
+
"0%, 100%": { width: "50%" },
|
|
591
|
+
"0%": { transform: "translateX(-100%)" },
|
|
592
|
+
"100%": { transform: "translateX(200%)" }
|
|
593
|
+
},
|
|
594
|
+
"carousel-rtl": {
|
|
595
|
+
"0%, 100%": { width: "50%" },
|
|
596
|
+
"0%": { transform: "translateX(100%)" },
|
|
597
|
+
"100%": { transform: "translateX(-200%)" }
|
|
598
|
+
},
|
|
599
|
+
"carousel-vertical": {
|
|
600
|
+
"0%, 100%": { height: "50%" },
|
|
601
|
+
"0%": { transform: "translateY(-100%)" },
|
|
602
|
+
"100%": { transform: "translateY(200%)" }
|
|
603
|
+
},
|
|
604
|
+
"carousel-inverse": {
|
|
605
|
+
"0%, 100%": { width: "50%" },
|
|
606
|
+
"0%": { transform: "translateX(200%)" },
|
|
607
|
+
"100%": { transform: "translateX(-100%)" }
|
|
608
|
+
},
|
|
609
|
+
"carousel-inverse-rtl": {
|
|
610
|
+
"0%, 100%": { width: "50%" },
|
|
611
|
+
"0%": { transform: "translateX(-200%)" },
|
|
612
|
+
"100%": { transform: "translateX(100%)" }
|
|
613
|
+
},
|
|
614
|
+
"carousel-inverse-vertical": {
|
|
615
|
+
"0%, 100%": { height: "50%" },
|
|
616
|
+
"0%": { transform: "translateY(200%)" },
|
|
617
|
+
"100%": { transform: "translateY(-100%)" }
|
|
618
|
+
},
|
|
619
|
+
"swing": {
|
|
620
|
+
"0%, 100%": {
|
|
621
|
+
width: "50%",
|
|
622
|
+
transform: "translateX(-25%)"
|
|
623
|
+
},
|
|
624
|
+
"50%": { transform: "translateX(125%)" }
|
|
625
|
+
},
|
|
626
|
+
"swing-vertical": {
|
|
627
|
+
"0%, 100%": {
|
|
628
|
+
height: "50%",
|
|
629
|
+
transform: "translateY(-25%)"
|
|
630
|
+
},
|
|
631
|
+
"50%": { transform: "translateY(125%)" }
|
|
632
|
+
},
|
|
633
|
+
"elastic": {
|
|
634
|
+
"0%, 100%": {
|
|
635
|
+
"width": "50%",
|
|
636
|
+
"margin-left": "25%"
|
|
637
|
+
},
|
|
638
|
+
"50%": {
|
|
639
|
+
"width": "90%",
|
|
640
|
+
"margin-left": "5%"
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
"elastic-vertical": {
|
|
644
|
+
"0%, 100%": {
|
|
645
|
+
"height": "50%",
|
|
646
|
+
"margin-top": "25%"
|
|
647
|
+
},
|
|
648
|
+
"50%": {
|
|
649
|
+
"height": "90%",
|
|
650
|
+
"margin-top": "5%"
|
|
651
|
+
}
|
|
580
652
|
}
|
|
581
653
|
},
|
|
582
654
|
animation: {
|
|
583
655
|
"collapsible-down": "collapsible-down 0.2s ease-in-out",
|
|
584
656
|
"collapsible-up": "collapsible-up 0.2s ease-in-out",
|
|
585
657
|
"accordion-down": "accordion-down 0.2s ease-out",
|
|
586
|
-
"accordion-up": "accordion-up 0.2s ease-out"
|
|
658
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
|
659
|
+
"toast-collapsed-closed": "toast-collapsed-closed 200ms ease-in-out",
|
|
660
|
+
"toast-closed": "toast-closed 200ms ease-in-out",
|
|
661
|
+
"carousel": "carousel 2s ease-in-out infinite",
|
|
662
|
+
"carousel-rtl": "carousel-rtl 2s ease-in-out infinite",
|
|
663
|
+
"carousel-vertical": "carousel-vertical 2s ease-in-out infinite",
|
|
664
|
+
"carousel-inverse": "carousel-inverse 2s ease-in-out infinite",
|
|
665
|
+
"carousel-inverse-rtl": "carousel-inverse-rtl 2s ease-in-out infinite",
|
|
666
|
+
"carousel-inverse-vertical": "carousel-inverse-vertical 2s ease-in-out infinite",
|
|
667
|
+
"swing": "swing 2s ease-in-out infinite",
|
|
668
|
+
"swing-vertical": "swing-vertical 2s ease-in-out infinite",
|
|
669
|
+
"elastic": "elastic 2s ease-in-out infinite",
|
|
670
|
+
"elastic-vertical": "elastic-vertical 2s ease-in-out infinite"
|
|
587
671
|
},
|
|
588
672
|
brands: {
|
|
589
673
|
primary: "violet",
|
|
@@ -593,7 +677,9 @@ const DEFAULT_AKAR_OPTIONS = {
|
|
|
593
677
|
warning: "yellow",
|
|
594
678
|
error: "red",
|
|
595
679
|
neutral: "slate"
|
|
596
|
-
}
|
|
680
|
+
},
|
|
681
|
+
pohonThemes: true,
|
|
682
|
+
enableDrawer: true
|
|
597
683
|
};
|
|
598
684
|
const DEFAULT_FLUID_OPTIONS = {
|
|
599
685
|
maxWidth: 1440,
|
|
@@ -670,7 +756,7 @@ async function resolvePresets(options) {
|
|
|
670
756
|
magicCss: import("./magic-css-BxO5zv5z.js").then((mod) => mod.presetMagicss),
|
|
671
757
|
animation: import("./animation-KZDlcVMl.js").then((mod) => mod.presetAnimation),
|
|
672
758
|
fluid: import("./fluid-Ne2qtSnB.js").then((mod) => mod.presetFluid),
|
|
673
|
-
akar: import("./akar-
|
|
759
|
+
akar: import("./akar-B30zjk5t.js").then((mod) => mod.presetAkar)
|
|
674
760
|
};
|
|
675
761
|
for (const [key, preset] of Object.entries(presetMap)) {
|
|
676
762
|
const option = options[key];
|
|
@@ -704,13 +790,19 @@ function resolveExtend(options) {
|
|
|
704
790
|
let { animation = {}, keyframes = {} } = options.theme.extend ?? {};
|
|
705
791
|
const safelist = [];
|
|
706
792
|
/**
|
|
707
|
-
* If akar is enabled we want to safelist
|
|
793
|
+
* If akar is enabled we want to safelist the drawer animations.
|
|
794
|
+
* The drawer preflight uses these animations but they are not
|
|
795
|
+
* directly referenced in the code so we need to safelist them
|
|
796
|
+
* to ensure they are included in the final CSS.
|
|
708
797
|
*/
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
798
|
+
const enableAkar = Boolean(options.akar);
|
|
799
|
+
let akarOptions = {};
|
|
800
|
+
if (enableAkar) akarOptions = defu(options.akar, DEFAULT_AKAR_OPTIONS);
|
|
801
|
+
if (enableAkar && akarOptions.enableDrawer) {
|
|
802
|
+
animation = mergeDeep(animation, akarOptions.animation ?? {});
|
|
803
|
+
keyframes = mergeDeep(keyframes, akarOptions.keyframes ?? {});
|
|
804
|
+
let akarAnimation = akarOptions.animation ?? {};
|
|
805
|
+
let akarKeyframes = akarOptions.keyframes ?? {};
|
|
714
806
|
if (isObjectType(options.akar)) {
|
|
715
807
|
akarAnimation = mergeDeep(akarAnimation, options.akar.animation ?? {});
|
|
716
808
|
akarKeyframes = mergeDeep(akarKeyframes, options.akar.keyframes ?? {});
|