Skip to content

Commit

Permalink
Support UnoCSS 0.57.0 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsyncBanana committed Oct 26, 2023
1 parent 7e0544a commit ecde416
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 162 deletions.
13 changes: 3 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ const processor = postcss(autoprefixer)
const process = (object: CssInJs) => processor.process(object, {parser: parse})

const replacePrefix = (css: string) => css.replaceAll('--tw-', '--un-')
// UnoCSS uses comma syntax
// var(--foo) / 0.1 -> var(--foo), 0.1
const replaceSlash = (css: string) => css.replaceAll(') / ', '), ')
const replaceSpace = (css: string) =>
// HSL
// 123 4% 5% -> 123, 4%, 5%
css.replaceAll(/([\d.]+) ([\d.%]+) ([\d.%]+)/g, '$1, $2, $3')

const defaultOptions = {
styled: true,
Expand Down Expand Up @@ -107,7 +100,7 @@ export const presetDaisy = (
if (options.base) {
preflights.unshift({
// eslint-disable-next-line @typescript-eslint/naming-convention
getCSS: () => replaceSlash(replacePrefix(process(base).css)),
getCSS: () => replacePrefix(process(base).css),
layer: 'daisy-base',
})
}
Expand All @@ -116,7 +109,7 @@ export const presetDaisy = (
theme => {
preflights.push({
// eslint-disable-next-line @typescript-eslint/naming-convention
getCSS: () => replaceSpace(process(theme).css),
getCSS: () => process(theme).css,
layer: 'daisy-themes',
})
},
Expand Down Expand Up @@ -162,7 +155,7 @@ export const presetDaisy = (
([base, rule]) =>
[
new RegExp(`^${base}$`),
() => replaceSlash(replacePrefix(rule)),
() => replacePrefix(rule),
{
layer: base.startsWith('checkbox-')
? 'daisy-components-post'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"peerDependencies": {
"daisyui": "^3.0.0",
"unocss": ">0.53.0"
"unocss": ">0.57.0"
},
"devDependencies": {
"@iconify-json/octicon": "^1.1.48",
Expand Down

0 comments on commit ecde416

Please sign in to comment.