-
Notifications
You must be signed in to change notification settings - Fork 332
/
unocss.config.ts
78 lines (72 loc) · 2.39 KB
/
unocss.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {
defineConfig,
presetAttributify,
presetIcons,
presetUno,
transformerDirectives,
transformerVariantGroup,
transformerAttributifyJsx
} from "unocss";
const colorReg = (prefix: string) => new RegExp("^" + prefix + "-([0-9a-z]+)(/(\\d+))?$");
const colorAttr = (prefix: string, [, color, , opacity]: RegExpMatchArray) => {
let lightColor = "",
darkColor = "";
if (["black", "white"].includes(color)) {
lightColor = color;
darkColor = color === "white" ? "black" : "white";
} else {
lightColor = `gray-${color}`;
darkColor = `gray-${(
(+color === 900 || +color === 50 ? 950 : 900) - +color
).toString()}`;
}
const attr = `${prefix}-${lightColor}${opacity ? "/" + opacity : ""}`;
const darkAttr = `${prefix}-${darkColor}${opacity ? "/" + opacity : ""}`;
return `${attr} dark:${darkAttr}`;
};
export default defineConfig({
shortcuts: [
["flex-center", "flex items-center justify-center"],
["hstack", "flex items-center"],
["vstack", "hstack flex-col"],
["no-outline", "outline-none focus:outline-none"],
[colorReg("text-c"), (v) => colorAttr("text", v)],
[colorReg("border-c"), (v) => colorAttr("border", v)],
[colorReg("bg-c"), (v) => colorAttr("bg", v)],
["shadow-menu", "shadow-md shadow-black/25 dark:shadow-black/50"],
["window-btn", "size-3 text-black rounded-full flex-center no-outline"],
["border-menu", "border-gray-500/50"],
[
"menu-box",
"fixed top-8.5 text-c-black bg-c-200/90 border border-menu rounded-lg shadow-menu"
],
[
"safari-btn",
"h-6 outline-none focus:outline-none rounded flex-center border border-c-300"
],
["cc-btn", "flex-center rounded-full size-8 text-white bg-blue-500"],
[
"cc-btn-active",
"flex-center rounded-full size-8 text-c-700 bg-gray-400/25 dark:bg-gray-300/25"
],
["cc-text", "text-xs text-c-500"],
["cc-grid", "bg-c-200/80 rounded-xl cc-grid-shadow backdrop-blur-2xl"],
["battery-level", "absolute rounded-[1px] h-2 top-1/2 -mt-1 ml-0.5 left-0"]
],
rules: [["cc-grid-shadow", { "box-shadow": "0px 1px 5px 0px rgba(0, 0, 0, 0.3)" }]],
presets: [
presetUno(),
presetAttributify(),
presetIcons({
warn: true,
extraProperties: {
display: "inline-block"
}
})
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
transformerAttributifyJsx()
]
});