@unocss/preset-uno 0.48.4 → 0.49.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 +1 -1
- package/dist/index.cjs +30 -21
- package/dist/index.mjs +31 -22
- package/package.json +4 -4
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -33,32 +33,41 @@ const shift = (color, weight) => {
|
|
|
33
33
|
return num > 0 ? shade(color, weight) : tint(color, -num);
|
|
34
34
|
};
|
|
35
35
|
const fns = { tint, shade, shift };
|
|
36
|
-
const variantColorMix = (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const variantColorMix = () => {
|
|
37
|
+
let re;
|
|
38
|
+
return {
|
|
39
|
+
name: "mix",
|
|
40
|
+
match(matcher, ctx) {
|
|
41
|
+
if (!re)
|
|
42
|
+
re = new RegExp(`^mix-(tint|shade|shift)-(-?\\d{1,3})(?:${ctx.generator.config.separators.join("|")})`);
|
|
43
|
+
const m = matcher.match(re);
|
|
44
|
+
if (m) {
|
|
45
|
+
return {
|
|
46
|
+
matcher: matcher.slice(m[0].length),
|
|
47
|
+
body: (body) => {
|
|
48
|
+
body.forEach((v) => {
|
|
49
|
+
if (v[1]) {
|
|
50
|
+
const color = utils.parseCssColor(`${v[1]}`);
|
|
51
|
+
if (color) {
|
|
52
|
+
const mixed = fns[m[1]](color, m[2]);
|
|
53
|
+
if (mixed)
|
|
54
|
+
v[1] = utils.colorToString(mixed);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return body;
|
|
50
59
|
}
|
|
51
|
-
}
|
|
52
|
-
return body;
|
|
60
|
+
};
|
|
53
61
|
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
const presetUno = (options = {}) => {
|
|
59
67
|
options.dark = options.dark ?? "class";
|
|
60
68
|
options.attributifyPseudo = options.attributifyPseudo ?? false;
|
|
61
69
|
options.preflight = options.preflight ?? true;
|
|
70
|
+
options.variablePrefix = options.variablePrefix ?? "un-";
|
|
62
71
|
return {
|
|
63
72
|
name: "@unocss/preset-uno",
|
|
64
73
|
theme: presetWind.theme,
|
|
@@ -66,11 +75,11 @@ const presetUno = (options = {}) => {
|
|
|
66
75
|
shortcuts: presetWind.shortcuts,
|
|
67
76
|
variants: [
|
|
68
77
|
...presetWind.variants(options),
|
|
69
|
-
variantColorMix
|
|
78
|
+
variantColorMix()
|
|
70
79
|
],
|
|
71
80
|
options,
|
|
72
|
-
postprocess:
|
|
73
|
-
preflights: options.preflight ? presetMini.preflights : [],
|
|
81
|
+
postprocess: presetMini.VarPrefixPostprocessor(options.variablePrefix),
|
|
82
|
+
preflights: options.preflight ? presetMini.normalizePreflights(presetMini.preflights, options.variablePrefix) : [],
|
|
74
83
|
prefix: options.prefix
|
|
75
84
|
};
|
|
76
85
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { theme, rules, shortcuts, variants } from '@unocss/preset-wind';
|
|
2
|
-
import { VarPrefixPostprocessor, preflights } from '@unocss/preset-mini';
|
|
2
|
+
import { VarPrefixPostprocessor, normalizePreflights, preflights } from '@unocss/preset-mini';
|
|
3
3
|
import { parseCssColor, colorToString } from '@unocss/preset-mini/utils';
|
|
4
4
|
|
|
5
5
|
const mixComponent = (v1, v2, w) => `calc(${v2} + (${v1} - ${v2}) * ${w} / 100)`;
|
|
@@ -29,32 +29,41 @@ const shift = (color, weight) => {
|
|
|
29
29
|
return num > 0 ? shade(color, weight) : tint(color, -num);
|
|
30
30
|
};
|
|
31
31
|
const fns = { tint, shade, shift };
|
|
32
|
-
const variantColorMix = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
const variantColorMix = () => {
|
|
33
|
+
let re;
|
|
34
|
+
return {
|
|
35
|
+
name: "mix",
|
|
36
|
+
match(matcher, ctx) {
|
|
37
|
+
if (!re)
|
|
38
|
+
re = new RegExp(`^mix-(tint|shade|shift)-(-?\\d{1,3})(?:${ctx.generator.config.separators.join("|")})`);
|
|
39
|
+
const m = matcher.match(re);
|
|
40
|
+
if (m) {
|
|
41
|
+
return {
|
|
42
|
+
matcher: matcher.slice(m[0].length),
|
|
43
|
+
body: (body) => {
|
|
44
|
+
body.forEach((v) => {
|
|
45
|
+
if (v[1]) {
|
|
46
|
+
const color = parseCssColor(`${v[1]}`);
|
|
47
|
+
if (color) {
|
|
48
|
+
const mixed = fns[m[1]](color, m[2]);
|
|
49
|
+
if (mixed)
|
|
50
|
+
v[1] = colorToString(mixed);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return body;
|
|
46
55
|
}
|
|
47
|
-
}
|
|
48
|
-
return body;
|
|
56
|
+
};
|
|
49
57
|
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
const presetUno = (options = {}) => {
|
|
55
63
|
options.dark = options.dark ?? "class";
|
|
56
64
|
options.attributifyPseudo = options.attributifyPseudo ?? false;
|
|
57
65
|
options.preflight = options.preflight ?? true;
|
|
66
|
+
options.variablePrefix = options.variablePrefix ?? "un-";
|
|
58
67
|
return {
|
|
59
68
|
name: "@unocss/preset-uno",
|
|
60
69
|
theme,
|
|
@@ -62,11 +71,11 @@ const presetUno = (options = {}) => {
|
|
|
62
71
|
shortcuts,
|
|
63
72
|
variants: [
|
|
64
73
|
...variants(options),
|
|
65
|
-
variantColorMix
|
|
74
|
+
variantColorMix()
|
|
66
75
|
],
|
|
67
76
|
options,
|
|
68
|
-
postprocess:
|
|
69
|
-
preflights: options.preflight ? preflights : [],
|
|
77
|
+
postprocess: VarPrefixPostprocessor(options.variablePrefix),
|
|
78
|
+
preflights: options.preflight ? normalizePreflights(preflights, options.variablePrefix) : [],
|
|
70
79
|
prefix: options.prefix
|
|
71
80
|
};
|
|
72
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-uno",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "The default preset for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"*.css"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@unocss/core": "0.
|
|
54
|
-
"@unocss/preset-mini": "0.
|
|
55
|
-
"@unocss/preset-wind": "0.
|
|
53
|
+
"@unocss/core": "0.49.0",
|
|
54
|
+
"@unocss/preset-mini": "0.49.0",
|
|
55
|
+
"@unocss/preset-wind": "0.49.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "unbuild",
|