-
-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add option to output the internal layers as CSS Cascade L…
…ayers (#3587) Co-authored-by: Simon He <57086651+Simon-He95@users.noreply.github.com>
- Loading branch information
1 parent
cc09252
commit b798da0
Showing
6 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`output-to-css-layer > static 1`] = ` | ||
"/* layer: shortcuts */ | ||
@layer shortcuts{ | ||
.abc{name:bar1;name:bar2;name:4;} | ||
} | ||
/* layer: a */ | ||
@layer a{ | ||
.a{name:bar1;} | ||
} | ||
/* layer: b */ | ||
@layer b{ | ||
.b{name:bar2;} | ||
} | ||
/* layer: c */ | ||
@layer c{ | ||
.c5{name:5;} | ||
} | ||
/* layer: d */ | ||
@layer d{ | ||
/* RAW 4 */ | ||
/* RAW 3 */ | ||
} | ||
/* layer: s */ | ||
@layer s{ | ||
.abcd{name:bar1;name:bar2;name:2;} | ||
}" | ||
`; | ||
|
||
exports[`use-css-layer > static 1`] = ` | ||
"/* layer: shortcuts */ | ||
@layer shortcuts{ | ||
.abc{name:bar1;name:bar2;name:4;} | ||
} | ||
/* layer: a */ | ||
@layer a{ | ||
.a{name:bar1;} | ||
} | ||
/* layer: b */ | ||
@layer b{ | ||
.b{name:bar2;} | ||
} | ||
/* layer: c */ | ||
@layer c{ | ||
.c5{name:5;} | ||
} | ||
/* layer: d */ | ||
@layer d{ | ||
/* RAW 4 */ | ||
/* RAW 3 */ | ||
} | ||
/* layer: s */ | ||
@layer s{ | ||
.abcd{name:bar1;name:bar2;name:2;} | ||
}" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createGenerator } from '@unocss/core' | ||
import { describe, expect, it } from 'vitest' | ||
|
||
describe('use-css-layer', () => { | ||
it('static', async () => { | ||
const uno = createGenerator({ | ||
rules: [ | ||
['a', { name: 'bar1' }, { layer: 'a' }], | ||
['b', { name: 'bar2' }, { layer: 'b' }], | ||
[/^c(\d+)$/, ([, d]) => ({ name: d }), { layer: 'c' }], | ||
[/^d(\d+)$/, ([, d]) => `/* RAW ${d} */`, { layer: 'd' }], | ||
], | ||
shortcuts: [ | ||
['abcd', 'a b c2 d3', { layer: 's' }], | ||
['abc', 'a b c4'], | ||
], | ||
presets: [], | ||
outputToCssLayers: true, | ||
}) | ||
const { css } = await uno.generate('a b abc abcd d4 c5', { preflights: false }) | ||
expect(css).toMatchSnapshot() | ||
}) | ||
}) |