From 91b8f908d141d27765649bddbf40e6b06356c3b7 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:51:19 +0000 Subject: [PATCH] Move overrides from preflights to rules --- index.ts | 38 ++++++++++++++++++-------------------- package.json | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/index.ts b/index.ts index 53f9385..a4d29f9 100644 --- a/index.ts +++ b/index.ts @@ -35,7 +35,6 @@ export const presetDaisy = ( ): Preset => { const rules = new Map() const keyframes: string[] = [] - const overrides: string[] = [] const styles = [ // Components @@ -83,21 +82,25 @@ export const presetDaisy = ( ) } - for (const rule of [ - // Move after `btn-*` - 'btn-outline', - // Resolve conflicts with @unocss/preset-wind `link:` variant - 'link-primary', - 'link-secondary', - 'link-accent', - 'link-neutral', - 'link-success', - 'link-info', - 'link-warning', - 'link-error', - 'link-hover', + // Move after `btn-*` + const btnOutline = rules.get('btn-outline')! + rules.delete('btn-outline') + rules.set('btn-outline', btnOutline) + + // Resolve conflicts with @unocss/preset-wind `link:` variant + for (const modifier of [ + 'primary', + 'secondary', + 'accent', + 'neutral', + 'success', + 'info', + 'warning', + 'error', + 'hover', ]) { - overrides.push(rules.get(rule)!) + const rule = `link-${modifier}` + rules.set('link', rules.get('link')! + rules.get(rule)! + '\n') rules.delete(rule) } @@ -141,11 +144,6 @@ export const presetDaisy = ( // eslint-disable-next-line @typescript-eslint/naming-convention getCSS: () => keyframes.join('\n'), }, - { - layer: 'default', - // eslint-disable-next-line @typescript-eslint/naming-convention - getCSS: () => overrides.join('\n'), - }, ] if (options.base !== false) diff --git a/package.json b/package.json index af3d3e7..c92b047 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "scripts": { "build": "vite build demo", "prepack": "tsc --noEmit && unbuild", - "preview": "vite preview demo", - "start": "vite demo" + "preview": "vite preview demo --host", + "start": "vite demo --host" }, "repository": "kidonng/unocss-preset-daisy", "license": "MIT",