Skip to content

Commit

Permalink
Move overrides from preflights to rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kidonng committed Mar 25, 2023
1 parent 7ba784f commit 91b8f90
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
38 changes: 18 additions & 20 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const presetDaisy = (
): Preset => {
const rules = new Map<string, string>()
const keyframes: string[] = []
const overrides: string[] = []

const styles = [
// Components
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 91b8f90

Please sign in to comment.