@unocss/preset-uno 0.23.0 → 0.24.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 +2 -2
- package/dist/index.cjs +63 -3
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +64 -3
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @unocss/preset-uno
|
|
2
2
|
|
|
3
|
-
The default preset for [UnoCSS](https://github.com/
|
|
3
|
+
The default preset for [UnoCSS](https://github.com/unocss/unocss).
|
|
4
4
|
|
|
5
5
|
> Please note that this preset is more like a playground at the current stage to experiment with the possibility of UnoCSS and also as a reference for making a custom preset. It does NOT follow semver and subjects to changes without further notice. We don't recommend using it on serious works. Use custom rules instead to ensure a stable outcome.
|
|
6
6
|
|
|
@@ -33,7 +33,7 @@ For example, both `ml-3` (Tailwind), `ms-2` (Bootstrap), `ma4` (Tachyons), `mt-1
|
|
|
33
33
|
.mt-10px { margin-top: 10px; }
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
For more details about the default preset, you can check out our [playground](https://unocss.antfu.me/) and try out. Meanwhile, you can also check out [the
|
|
36
|
+
For more details about the default preset, you can check out our [playground](https://unocss.antfu.me/) and try out. Meanwhile, you can also check out [the implementations](https://github.com/unocss/unocss/tree/main/packages).
|
|
37
37
|
|
|
38
38
|
## License
|
|
39
39
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,70 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const presetWind = require('@unocss/preset-wind');
|
|
6
|
+
const utils = require('@unocss/preset-mini/utils');
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const mixComponent = (v1, v2, w) => `calc(${v2} + (${v1} - ${v2}) * ${w} / 100)`;
|
|
9
|
+
const mixColor = (color1, color2, weight) => {
|
|
10
|
+
const colors = [color1, color2];
|
|
11
|
+
const cssColors = [];
|
|
12
|
+
for (let c = 0; c < 2; ++c) {
|
|
13
|
+
const color = typeof colors[c] === "string" ? utils.parseCssColor(colors[c]) : colors[c];
|
|
14
|
+
if (!color || !["rgb", "rgba"].includes(color.type))
|
|
15
|
+
return;
|
|
16
|
+
cssColors.push(color);
|
|
17
|
+
}
|
|
18
|
+
const newComponents = [];
|
|
19
|
+
for (let x = 0; x < 3; ++x)
|
|
20
|
+
newComponents.push(mixComponent(cssColors[0].components[x], cssColors[1].components[x], weight));
|
|
21
|
+
return {
|
|
22
|
+
type: "rgb",
|
|
23
|
+
components: newComponents,
|
|
24
|
+
alpha: mixComponent(cssColors[0].alpha ?? 1, cssColors[1].alpha ?? 1, weight)
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const tint = (color, weight) => mixColor("#fff", color, weight);
|
|
28
|
+
const shade = (color, weight) => mixColor("#000", color, weight);
|
|
29
|
+
const shift = (color, weight) => parseInt(`${weight}`, 10) > 0 ? shade(color, weight) : tint(color, `-${weight}`);
|
|
30
|
+
const fns = { tint, shade, shift };
|
|
31
|
+
const variantColorMix = (matcher) => {
|
|
32
|
+
const m = matcher.match(/^mix-(tint|shade|shift)-(-?\d{1,3})[-:]/);
|
|
33
|
+
if (m) {
|
|
34
|
+
return {
|
|
35
|
+
matcher: matcher.slice(m[0].length),
|
|
36
|
+
body: (body) => {
|
|
37
|
+
body.forEach((v) => {
|
|
38
|
+
if (v[1]) {
|
|
39
|
+
const color = utils.parseCssColor(`${v[1]}`);
|
|
40
|
+
if (color) {
|
|
41
|
+
const mixed = fns[m[1]](color, m[2]);
|
|
42
|
+
if (mixed) {
|
|
43
|
+
const { alpha, components } = mixed;
|
|
44
|
+
v[1] = `rgb(${components.join(",")},${alpha})`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return body;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const presetUno = (options = {}) => {
|
|
56
|
+
options.dark = options.dark ?? "class";
|
|
57
|
+
options.attributifyPseudo = options.attributifyPseudo ?? false;
|
|
58
|
+
return {
|
|
59
|
+
name: "@unocss/preset-uno",
|
|
60
|
+
theme: presetWind.theme,
|
|
61
|
+
rules: presetWind.rules,
|
|
62
|
+
shortcuts: presetWind.shortcuts,
|
|
63
|
+
variants: [
|
|
64
|
+
...presetWind.variants(options),
|
|
65
|
+
variantColorMix
|
|
66
|
+
],
|
|
67
|
+
options
|
|
68
|
+
};
|
|
69
|
+
};
|
|
8
70
|
|
|
9
|
-
exports.colors = presetWind.colors;
|
|
10
|
-
exports.theme = presetWind.theme;
|
|
11
71
|
exports["default"] = presetUno;
|
|
12
72
|
exports.presetUno = presetUno;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as _unocss_preset_wind from '@unocss/preset-wind';
|
|
3
|
-
export { colors, theme } from '@unocss/preset-wind';
|
|
1
|
+
import { Preset } from '@unocss/core';
|
|
4
2
|
import { PresetMiniOptions, Theme } from '@unocss/preset-mini';
|
|
5
3
|
export { Theme } from '@unocss/preset-mini';
|
|
6
4
|
|
|
7
5
|
interface PresetUnoOptions extends PresetMiniOptions {
|
|
8
6
|
}
|
|
9
|
-
declare const presetUno: (options?:
|
|
7
|
+
declare const presetUno: (options?: PresetUnoOptions) => Preset<Theme>;
|
|
10
8
|
|
|
11
9
|
export { PresetUnoOptions, presetUno as default, presetUno };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { theme, rules, shortcuts, variants } from '@unocss/preset-wind';
|
|
2
|
+
import { parseCssColor } from '@unocss/preset-mini/utils';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const mixComponent = (v1, v2, w) => `calc(${v2} + (${v1} - ${v2}) * ${w} / 100)`;
|
|
5
|
+
const mixColor = (color1, color2, weight) => {
|
|
6
|
+
const colors = [color1, color2];
|
|
7
|
+
const cssColors = [];
|
|
8
|
+
for (let c = 0; c < 2; ++c) {
|
|
9
|
+
const color = typeof colors[c] === "string" ? parseCssColor(colors[c]) : colors[c];
|
|
10
|
+
if (!color || !["rgb", "rgba"].includes(color.type))
|
|
11
|
+
return;
|
|
12
|
+
cssColors.push(color);
|
|
13
|
+
}
|
|
14
|
+
const newComponents = [];
|
|
15
|
+
for (let x = 0; x < 3; ++x)
|
|
16
|
+
newComponents.push(mixComponent(cssColors[0].components[x], cssColors[1].components[x], weight));
|
|
17
|
+
return {
|
|
18
|
+
type: "rgb",
|
|
19
|
+
components: newComponents,
|
|
20
|
+
alpha: mixComponent(cssColors[0].alpha ?? 1, cssColors[1].alpha ?? 1, weight)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const tint = (color, weight) => mixColor("#fff", color, weight);
|
|
24
|
+
const shade = (color, weight) => mixColor("#000", color, weight);
|
|
25
|
+
const shift = (color, weight) => parseInt(`${weight}`, 10) > 0 ? shade(color, weight) : tint(color, `-${weight}`);
|
|
26
|
+
const fns = { tint, shade, shift };
|
|
27
|
+
const variantColorMix = (matcher) => {
|
|
28
|
+
const m = matcher.match(/^mix-(tint|shade|shift)-(-?\d{1,3})[-:]/);
|
|
29
|
+
if (m) {
|
|
30
|
+
return {
|
|
31
|
+
matcher: matcher.slice(m[0].length),
|
|
32
|
+
body: (body) => {
|
|
33
|
+
body.forEach((v) => {
|
|
34
|
+
if (v[1]) {
|
|
35
|
+
const color = parseCssColor(`${v[1]}`);
|
|
36
|
+
if (color) {
|
|
37
|
+
const mixed = fns[m[1]](color, m[2]);
|
|
38
|
+
if (mixed) {
|
|
39
|
+
const { alpha, components } = mixed;
|
|
40
|
+
v[1] = `rgb(${components.join(",")},${alpha})`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return body;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const presetUno = (options = {}) => {
|
|
52
|
+
options.dark = options.dark ?? "class";
|
|
53
|
+
options.attributifyPseudo = options.attributifyPseudo ?? false;
|
|
54
|
+
return {
|
|
55
|
+
name: "@unocss/preset-uno",
|
|
56
|
+
theme,
|
|
57
|
+
rules,
|
|
58
|
+
shortcuts,
|
|
59
|
+
variants: [
|
|
60
|
+
...variants(options),
|
|
61
|
+
variantColorMix
|
|
62
|
+
],
|
|
63
|
+
options
|
|
64
|
+
};
|
|
65
|
+
};
|
|
5
66
|
|
|
6
67
|
export { presetUno as default, presetUno };
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-uno",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "The default preset for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
7
7
|
"unocss-preset"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/
|
|
9
|
+
"homepage": "https://github.com/unocss/unocss/tree/main/packages/preset-uno#readme",
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/unocss/unocss/issues"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/
|
|
15
|
+
"url": "git+https://github.com/unocss/unocss.git",
|
|
16
16
|
"directory": "packages/preset-uno"
|
|
17
17
|
},
|
|
18
18
|
"funding": "https://github.com/sponsors/antfu",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"*.css"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@unocss/core": "0.
|
|
54
|
-
"@unocss/preset-wind": "0.
|
|
55
|
-
"@unocss/preset-mini": "0.
|
|
53
|
+
"@unocss/core": "0.24.0",
|
|
54
|
+
"@unocss/preset-wind": "0.24.0",
|
|
55
|
+
"@unocss/preset-mini": "0.24.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "unbuild",
|