newsnow/uno.config.ts

50 lines
1.5 KiB
TypeScript
Raw Normal View History

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 { 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: [
2024-10-17 13:07:48 +08:00
[/^sprinkle-(.+)$/, ([_, d], { theme }) => {
// @ts-expect-error >_<
2024-10-22 14:54:31 +08:00
const hex: any = theme.colors?.[d]?.[400]
if (hex) {
return {
"background-image": `radial-gradient(ellipse 80% 80% at 50% -30%,
2024-10-17 13:07:48 +08:00
rgba(${hex2rgba(hex)?.join(", ")}, 0.3), rgba(255, 255, 255, 0));`,
2024-10-12 21:31:33 +08:00
}
}
}],
2024-10-13 02:09:36 +08:00
[
"font-brand",
{
"font-family": `"Baloo 2", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace; `,
},
],
2024-10-12 21:31:33 +08:00
],
2024-09-26 11:30:21 +08:00
shortcuts: {
"color-base": "color-neutral-800 dark:color-neutral-300",
2024-10-22 14:54:31 +08:00
"bg-base": "bg-zinc-50 dark:bg-dark-600",
2024-10-17 13:07:48 +08:00
"btn": "op50 hover:op85",
2024-09-26 11:30:21 +08:00
},
2024-10-12 12:49:20 +08:00
safelist: [
2024-10-23 02:43:38 +08:00
...["orange", ...new Set(Object.values(sources).map(k => k.color))].map(k =>
2024-10-22 14:54:31 +08:00
`bg-${k} color-${k} border-${k} sprinkle-${k} shadow-${k}
bg-${k}-500 color-${k}-500
dark:bg-${k} dark:color-${k}`.trim().split(/\s+/)).flat(),
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
},
})