Skip to content

Commit

Permalink
feat: 扩充 unocss 自定义 shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Aug 5, 2024
1 parent ee3ce95 commit 6258eec
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions unocss.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,30 @@ export default defineConfig<Theme>({
},
},
shortcuts: [
{
'flex-center': 'flex justify-center items-center',
'flex-col-center': 'flex flex-col justify-center items-center',
},
[/^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(' ')
}],
[/^square-\[?(.*?)\]?$/, ([, size]) => `w-${size} h-${size}`],
[/^circle-\[?(.*?)\]?$/, ([, size]) => `square-${size} rounded-full`],
],
preflights: [
{
getCSS: () => {
const returnCss: any = []
const returnCss: string[] = []
// 明亮主题
const lightCss = entriesToCss(Object.entries(lightTheme))
const lightRoots = toArray([`*,::before,::after`, `::backdrop`])
Expand Down

0 comments on commit 6258eec

Please sign in to comment.