mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-11-29 18:48:31 +08:00
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import type { Theme } from 'unocss/preset-uno'
|
|
import { entriesToCss, toArray } from '@unocss/core'
|
|
import {
|
|
defineConfig,
|
|
presetAttributify,
|
|
presetIcons,
|
|
presetTypography,
|
|
presetUno,
|
|
transformerCompileClass,
|
|
transformerDirectives,
|
|
transformerVariantGroup,
|
|
} from 'unocss'
|
|
import { presetScrollbar } from 'unocss-preset-scrollbar'
|
|
import { darkTheme, lightTheme } from './themes'
|
|
|
|
export default defineConfig<Theme>({
|
|
content: {
|
|
pipeline: {
|
|
include: [
|
|
/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
|
|
'src/**/*.{js,ts}',
|
|
],
|
|
},
|
|
},
|
|
shortcuts: [
|
|
[/^flex-?(col)?-(start|end|center|baseline|stretch)-?(start|end|center|between|around|evenly|left|right)?$/, ([, col, items, justify]) => {
|
|
const cls = ['flex']
|
|
if (col === 'col') {
|
|
cls.push('flex-col')
|
|
}
|
|
if (items === 'center' && !justify) {
|
|
cls.push('items-center')
|
|
cls.push('justify-center')
|
|
}
|
|
else {
|
|
cls.push(`items-${items}`)
|
|
if (justify) {
|
|
cls.push(`justify-${justify}`)
|
|
}
|
|
}
|
|
return cls.join(' ')
|
|
}],
|
|
],
|
|
preflights: [
|
|
{
|
|
getCSS: () => {
|
|
const returnCss: any = []
|
|
// 明亮主题
|
|
const lightCss = entriesToCss(Object.entries(lightTheme))
|
|
const lightRoots = toArray([`*,::before,::after`, `::backdrop`])
|
|
returnCss.push(lightRoots.map(root => `${root}{${lightCss}}`).join(''))
|
|
// 暗黑主题
|
|
const darkCss = entriesToCss(Object.entries(darkTheme))
|
|
const darkRoots = toArray([`html.dark,html.dark *,html.dark ::before,html.dark ::after`, `html.dark ::backdrop`])
|
|
returnCss.push(darkRoots.map(root => `${root}{${darkCss}}`).join(''))
|
|
|
|
return returnCss.join('')
|
|
},
|
|
},
|
|
],
|
|
theme: {
|
|
colors: {
|
|
'ui-primary': 'rgb(var(--ui-primary))',
|
|
'ui-text': 'rgb(var(--ui-text))',
|
|
},
|
|
},
|
|
presets: [
|
|
presetUno(),
|
|
presetAttributify(),
|
|
presetIcons({
|
|
extraProperties: {
|
|
'display': 'inline-block',
|
|
'vertical-align': 'middle',
|
|
},
|
|
}),
|
|
presetTypography(),
|
|
presetScrollbar(),
|
|
],
|
|
transformers: [
|
|
transformerDirectives(),
|
|
transformerVariantGroup(),
|
|
transformerCompileClass(),
|
|
],
|
|
configDeps: [
|
|
'themes/index.ts',
|
|
],
|
|
})
|