unocss.config.ts

c324b0458c36fa36f78c69aa633cfe1efbcd9690
wotaku/unocss.config.ts history · blame · raw

75 lines · 2058 bytes

 1/**
 2 *  Copyright (c) 2024 taskylizard
 3 *
 4 *  Licensed under the Apache License, Version 2.0 (the "License");
 5 *  you may not use this file except in compliance with the License.
 6 *  You may obtain a copy of the License at
 7 *
 8 *  http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16import { colors } from '@taskylizard/colors'
17import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
18import { resolve } from 'node:path'
19import {
20  defineConfig,
21  presetUno,
22  presetAttributify,
23  presetIcons,
24  transformerDirectives
25} from 'unocss'
26
27// Custom icons collection
28const customIcons = {
29  circle:
30    '<svg viewBox="0 0 120 120"><circle cx="60" cy="60" r="50"></circle></svg>'
31  // Add more custom icons here as needed
32}
33
34const safelist = Object.entries(colors).flatMap(([group, shades]) =>
35  Object.keys(shades).flatMap((shade) => [
36    `text-${group}-${shade}`,
37    `bg-${group}-${shade}`
38  ])
39)
40
41export default defineConfig({
42  content: {
43    filesystem: ['.vitepress/configs/constants.ts']
44  },
45  safelist,
46  theme: {
47    colors: {
48      ...colors,
49      primary: 'var(--vp-c-brand-1)',
50      bg: 'var(--vp-c-bg)',
51      'bg-alt': 'var(--vp-c-bg-alt)',
52      'bg-elv': 'var(--vp-c-bg-elv)',
53      text: 'var(--vp-c-text-1)',
54      'text-2': 'var(--vp-c-text-2)',
55      div: 'var(--vp-c-divider)'
56    }
57  },
58  presets: [
59    presetUno(),
60    presetAttributify(),
61    presetIcons({
62      scale: 1.2,
63      extraProperties: {
64        display: 'inline-block',
65        'vertical-align': 'middle'
66      },
67      warn: true,
68      collections: {
69        custom: FileSystemIconLoader(resolve(__dirname, 'docs/public/custom')),
70        inline: customIcons
71      }
72    })
73  ],
74  transformers: [transformerDirectives()]
75})