2024-09-26 11:30:21 +08:00
|
|
|
import { defineConfig, presetIcons, presetUno, transformerDirectives, transformerVariantGroup } from "unocss"
|
2024-10-12 21:31:33 +08:00
|
|
|
import { hex2rgba } from "@unocss/rule-utils"
|
|
|
|
import { colors } from "unocss/preset-mini"
|
|
|
|
import { sources } from "./shared/sources"
|
2024-09-26 11:30:21 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
mergeSelectors: false,
|
|
|
|
transformers: [transformerDirectives(), transformerVariantGroup()],
|
|
|
|
presets: [
|
|
|
|
presetUno(),
|
|
|
|
presetIcons({
|
|
|
|
scale: 1.2,
|
|
|
|
}),
|
|
|
|
],
|
2024-10-12 21:31:33 +08:00
|
|
|
rules: [
|
|
|
|
[/^sprinkle-(.+)$/, ([_, d]) => {
|
|
|
|
if (d in colors) {
|
|
|
|
// @ts-expect-error >_<
|
|
|
|
const hex: any = colors[d]?.[400]
|
|
|
|
if (hex) {
|
|
|
|
return {
|
|
|
|
"background-image": `radial-gradient(ellipse 80% 80% at 50% -30%,
|
|
|
|
rgba(${hex2rgba(hex)?.join(", ")}, 0.3),
|
|
|
|
rgba(255, 255, 255, 0));`,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
],
|
2024-09-26 11:30:21 +08:00
|
|
|
shortcuts: {
|
|
|
|
"color-base": "color-neutral-800 dark:color-neutral-300",
|
2024-10-12 15:50:44 +08:00
|
|
|
"bg-base": "bg-white dark:bg-dark-600",
|
2024-09-26 11:30:21 +08:00
|
|
|
|
|
|
|
"color-active": "color-primary-600 dark:color-primary-400",
|
|
|
|
"border-active": "border-primary-600/25 dark:border-primary-400/25",
|
2024-10-12 15:50:44 +08:00
|
|
|
"bg-active": "bg-primary-400/10",
|
2024-09-26 11:30:21 +08:00
|
|
|
|
2024-10-11 18:47:27 +08:00
|
|
|
"btn-pure": "op50 hover:op75",
|
2024-09-26 11:30:21 +08:00
|
|
|
},
|
2024-10-12 12:49:20 +08:00
|
|
|
safelist: [
|
2024-10-12 21:31:33 +08:00
|
|
|
...["bg", "color", "border", "sprinkle", "shadow"].map(t => Object.values(sources).map(c => `${t}-${c.color}`)).flat(1),
|
2024-10-12 12:49:20 +08:00
|
|
|
],
|
|
|
|
extendTheme: (theme) => {
|
|
|
|
// @ts-expect-error >_<
|
|
|
|
theme.colors.primary = theme.colors.red
|
|
|
|
return theme
|
2024-09-26 11:30:21 +08:00
|
|
|
},
|
|
|
|
})
|