Skip to content

Commit

Permalink
fix(presets): move content-x utility from preset-wind to preset-mini (
Browse files Browse the repository at this point in the history
  • Loading branch information
chu121su12 committed Apr 28, 2022
1 parent 4d5a18e commit 9b1d783
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
5 changes: 4 additions & 1 deletion packages/preset-mini/src/rules/static.ts
Expand Up @@ -50,7 +50,10 @@ export const whitespaces: Rule[] = [
]

export const contents: Rule[] = [
[/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
[/^content-(.+)$/, ([, v]) => {
const c = h.bracket.cssvar(v)
return { content: c == null ? `"${v}"` : c }
}],
['content-empty', { content: '""' }],
['content-none', { content: '""' }],
]
Expand Down
3 changes: 2 additions & 1 deletion packages/preset-wind/src/rules/default.ts
Expand Up @@ -8,6 +8,7 @@ import {
borders,
boxShadows,
boxSizing,
contents,
cssProperty,
cursors,
displays,
Expand Down Expand Up @@ -56,7 +57,7 @@ import { container } from './container'
import { backgroundStyles } from './background'
import { filters } from './filters'
import { spaces } from './spacing'
import { backgroundBlendModes, contents, hyphens, isolations, mixBlendModes, objectPositions, screenReadersAccess, textTransforms, writingModes, writingOrientations } from './static'
import { backgroundBlendModes, hyphens, isolations, mixBlendModes, objectPositions, screenReadersAccess, textTransforms, writingModes, writingOrientations } from './static'
import { tables } from './table'
import { accents, carets, imageRenderings, listStyle, overscrolls, scrollBehaviors } from './behaviors'
import { animations } from './animation'
Expand Down
13 changes: 1 addition & 12 deletions packages/preset-wind/src/rules/static.ts
@@ -1,5 +1,5 @@
import type { Rule } from '@unocss/core'
import { handler as h, positionMap } from '@unocss/preset-mini/utils'
import { positionMap } from '@unocss/preset-mini/utils'

export const textTransforms: Rule[] = [
// tailwind compact
Expand Down Expand Up @@ -68,17 +68,6 @@ export const screenReadersAccess: Rule[] = [
],
]

export const contents: Rule[] = [
[/^content-(.+)$/, ([, v]) => {
const c = h.bracket.cssvar(v)
if (c != null)
return { content: c }
return { content: `"${v}"` }
}],
['content-empty', { content: '""' }],
['content-none', { content: '""' }],
]

export const isolations: Rule[] = [
['isolate', { isolation: 'isolate' }],
['isolate-auto', { isolation: 'auto' }],
Expand Down
5 changes: 3 additions & 2 deletions test/__snapshots__/preset-mini.test.ts.snap
Expand Up @@ -236,8 +236,9 @@ div:hover .group-\\\\[div\\\\:hover\\\\]-\\\\[combinator\\\\:test-4\\\\]{combina
.border-block-style-double{border-block-start-style:double;border-block-end-style:double;}
.border-is-style-double{border-inline-start-style:double;}
.after\\\\:content-\\\\[unocss\\\\]::after,
.content-\\\\[unocss\\\\]{content:\\"unocss\\";}
.content-\\\\[attr\\\\(dashed-attr\\\\)\\\\]{content:\\"attr(dashed-attr)\\";}
.content-\\\\[unocss\\\\]{content:unocss;}
.content-\\\\[attr\\\\(dashed-attr\\\\)\\\\]{content:attr(dashed-attr);}
.content-unocss{content:\\"unocss\\";}
.content-empty,
.content-none{content:\\"\\";}
.font-\\\\[system-ui\\\\]{font-family:system-ui;}
Expand Down
1 change: 1 addition & 0 deletions test/assets/preset-mini-targets.ts
Expand Up @@ -513,6 +513,7 @@ export const presetMiniTargets: string[] = [
'ws-nowrap',
'content-empty',
'content-none',
'content-unocss',
'content-[unocss]',
'content-[attr(dashed-attr)]',
'break-normal',
Expand Down

0 comments on commit 9b1d783

Please sign in to comment.