From 6258eeca556612b12f1213028371d7a86f63de8d Mon Sep 17 00:00:00 2001 From: Hooray Hu <304327508@qq.com> Date: Mon, 5 Aug 2024 14:46:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A9=E5=85=85=20unocss=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20shortcuts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unocss.config.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/unocss.config.ts b/unocss.config.ts index 26c2b9c6..ac510ab3 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -22,15 +22,30 @@ export default defineConfig({ }, }, 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`])