unocss 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -5
- package/dist/vite.js +3 -1
- package/dist/vite.mjs +3 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -27,13 +27,13 @@ Inspired by [Windi CSS](http://windicss.org/), [Tailwind CSS](https://tailwindcs
|
|
|
27
27
|
###### Benchmark
|
|
28
28
|
|
|
29
29
|
```
|
|
30
|
-
|
|
30
|
+
11/5/2021, 4:26:57 AM
|
|
31
31
|
1656 utilities | x50 runs (min build time)
|
|
32
32
|
|
|
33
|
-
none 8.
|
|
34
|
-
unocss v0.
|
|
35
|
-
windicss v3.1
|
|
36
|
-
tailwindcss v3.0.0-alpha.1
|
|
33
|
+
none 8.30 ms / delta. 0.00 ms
|
|
34
|
+
unocss v0.4.15 13.58 ms / delta. 5.28 ms (x1.00)
|
|
35
|
+
windicss v3.2.1 989.57 ms / delta. 981.27 ms (x185.94)
|
|
36
|
+
tailwindcss v3.0.0-alpha.1 1290.96 ms / delta. 1282.66 ms (x243.05)
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
###### Non-goal
|
|
@@ -342,6 +342,8 @@ import '@unocss/reset/eric-meyer.css'
|
|
|
342
342
|
import '@unocss/reset/tailwind.css'
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
+
Learn more at [@unocss/reset](https://github.com/antfu/unocss/tree/main/packages/reset).
|
|
346
|
+
|
|
345
347
|
### Custom Variants
|
|
346
348
|
|
|
347
349
|
[Variants](https://windicss.org/utilities/variants.html#variants) allows you to apply some variations to your existing rules. For example, to implement the `hover:` variant from Tailwind:
|
|
@@ -387,6 +389,55 @@ With this, we could have `m-2` applied only when users hover over the element.
|
|
|
387
389
|
|
|
388
390
|
The variant system is very powerful and can't be covered fully in this guide, you can check [the default preset's implementation](https://github.com/antfu/unocss/tree/main/packages/preset-uno/src/variants) to see more advanced usages.
|
|
389
391
|
|
|
392
|
+
### Layers
|
|
393
|
+
|
|
394
|
+
The orders of CSS will affect their priorities. While we will [retain the order of rules](#ordering), sometimes you may want to group some utilities to have more explicit control of their orders.
|
|
395
|
+
|
|
396
|
+
Unlike Tailwind, which offers fixed 3 layers (`base`, `components`, `utilities`), UnoCSS allows you to define your own layers as you want. To set the layer, you can pass the metadata as the third item of your rules:
|
|
397
|
+
|
|
398
|
+
```ts
|
|
399
|
+
rules: [
|
|
400
|
+
[/^m-(\d)$/, ([, d]) => ({ margin: `${d / 4}rem` }), { layer: 'utilities' }],
|
|
401
|
+
// when you omit the layer, it will be `default`
|
|
402
|
+
['btn', { padding: '4px' }]
|
|
403
|
+
]
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
This will make it generates:
|
|
407
|
+
|
|
408
|
+
```css
|
|
409
|
+
/* layer: default */
|
|
410
|
+
.btn { padding: 4px; }
|
|
411
|
+
/* layer: utilities */
|
|
412
|
+
.m-2 { margin: 0.5rem; }
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
You can control the order of layers by:
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
layers: {
|
|
419
|
+
components: -1,
|
|
420
|
+
default: 1,
|
|
421
|
+
utilities: 2,
|
|
422
|
+
'my-layer': 3,
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Layers without specified order will be sorted alphabetically.
|
|
427
|
+
|
|
428
|
+
When you want to have your custom CSS between layers, you can update your entry module:
|
|
429
|
+
|
|
430
|
+
```ts
|
|
431
|
+
// 'uno:[layer-name].css'
|
|
432
|
+
import 'uno:components.css'
|
|
433
|
+
// layers that are not 'components' and 'utilities' will fallback to here
|
|
434
|
+
import 'uno.css'
|
|
435
|
+
// your own CSS
|
|
436
|
+
import './my-custom.css'
|
|
437
|
+
// "utilities" layer will have the highest priority
|
|
438
|
+
import 'uno:utilities.css'
|
|
439
|
+
```
|
|
440
|
+
|
|
390
441
|
### CSS Scoping
|
|
391
442
|
|
|
392
443
|
> 🚧 This part is still under experiment. You might want to read the code to see how it works currently.
|
package/dist/vite.js
CHANGED
|
@@ -5,7 +5,9 @@ var _presetuno = require('@unocss/preset-uno'); var _presetuno2 = _interopRequir
|
|
|
5
5
|
function UnocssVitePlugin(configOrPath) {
|
|
6
6
|
return _vite2.default.call(void 0, configOrPath, {
|
|
7
7
|
presets: [
|
|
8
|
-
_presetuno2.default.call(void 0,
|
|
8
|
+
_presetuno2.default.call(void 0, {
|
|
9
|
+
dev: process.env.NODE_ENV === "development"
|
|
10
|
+
})
|
|
9
11
|
]
|
|
10
12
|
});
|
|
11
13
|
}
|
package/dist/vite.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unocss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"*.d.ts"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@unocss/core": "0.
|
|
44
|
-
"@unocss/reset": "0.
|
|
45
|
-
"@unocss/preset-icons": "0.
|
|
46
|
-
"@unocss/preset-attributify": "0.
|
|
47
|
-
"@unocss/preset-uno": "0.
|
|
48
|
-
"@unocss/vite": "0.
|
|
43
|
+
"@unocss/core": "0.5.0",
|
|
44
|
+
"@unocss/reset": "0.5.0",
|
|
45
|
+
"@unocss/preset-icons": "0.5.0",
|
|
46
|
+
"@unocss/preset-attributify": "0.5.0",
|
|
47
|
+
"@unocss/preset-uno": "0.5.0",
|
|
48
|
+
"@unocss/vite": "0.5.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=14"
|