unocss-preset-magicolor 0.1.0 → 0.3.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/dist/common-Dv0krm1V.js +59 -0
- package/dist/helper.js +37 -2
- package/dist/index.js +254 -262
- package/dist/types/helper.d.ts +12 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/preflights/index.d.ts +3 -0
- package/dist/types/rules/color-style.d.ts +2 -1
- package/dist/types/rules/utils/border.d.ts +3 -0
- package/dist/types/rules/utils/index.d.ts +6 -0
- package/dist/types/rules/utils/theme-colors.d.ts +10 -0
- package/dist/types/{utils → rules/utils}/utilities.d.ts +1 -8
- package/dist/types/types.d.ts +2 -0
- package/dist/types/utils/common.d.ts +20 -0
- package/dist/types/utils/index.d.ts +1 -5
- package/dist/types/utils/transforms.d.ts +2 -0
- package/package.json +4 -6
- package/dist/types/utils/border.d.ts +0 -3
- /package/dist/types/{utils → rules/utils}/bg-gradient.d.ts +0 -0
- /package/dist/types/{utils → rules/utils}/mask.d.ts +0 -0
- /package/dist/types/{utils → rules/utils}/shadow.d.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { mc as f } from "magic-color";
|
|
2
|
+
function r(t) {
|
|
3
|
+
return t && Number.parseFloat(t.toString()) || 0;
|
|
4
|
+
}
|
|
5
|
+
function g(t) {
|
|
6
|
+
if (!t)
|
|
7
|
+
return;
|
|
8
|
+
if (t.type === "oklch")
|
|
9
|
+
return t.components[0].toString().includes("%") && (t.components[0] = r(t.components[0]) / 100), t.components = t.components.map(r), t;
|
|
10
|
+
const n = f(
|
|
11
|
+
t.type === "hex" ? t.components[0].toString() : t.components,
|
|
12
|
+
t.type
|
|
13
|
+
).toOklch().values;
|
|
14
|
+
if (n)
|
|
15
|
+
return {
|
|
16
|
+
type: "oklch",
|
|
17
|
+
components: [n[0] / 100, n[1], n[2]],
|
|
18
|
+
alpha: t.alpha
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function u(t) {
|
|
22
|
+
return Math.round(t * 1e3) / 1e3;
|
|
23
|
+
}
|
|
24
|
+
const m = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
25
|
+
function b(t) {
|
|
26
|
+
let n = Number(t);
|
|
27
|
+
n = n <= 50 ? 50 : n, n = n >= 950 ? 950 : n;
|
|
28
|
+
let o = Math.floor(n / 100) * 100;
|
|
29
|
+
o = o <= 50 ? 50 : o;
|
|
30
|
+
let e = Math.floor((n + 100) / 100) * 100;
|
|
31
|
+
return e = e >= 950 ? 950 : e, { originDepth: n, beforeDepth: o, afterDepth: e };
|
|
32
|
+
}
|
|
33
|
+
function N(t) {
|
|
34
|
+
return !t || !Number.isNaN(Number(t)) ? (console.error(`[unocss-preset-margicolor] The color '${t}' is invalid.`), !0) : !1;
|
|
35
|
+
}
|
|
36
|
+
function $(t) {
|
|
37
|
+
const { originDepth: n, beforeDepth: o, beforeComponents: e, afterComponents: i } = t, a = (n - o) / (n < 100 || n > 900 ? 50 : 100);
|
|
38
|
+
return `oklch(${Array.from({ length: 3 }).map((l, c) => {
|
|
39
|
+
const p = r(e[c]) + (r(i[c]) - r(e[c])) * a;
|
|
40
|
+
return u(p);
|
|
41
|
+
}).join(" ")})`;
|
|
42
|
+
}
|
|
43
|
+
function k(t, n) {
|
|
44
|
+
const o = {};
|
|
45
|
+
for (const e of m)
|
|
46
|
+
if (n[e]) {
|
|
47
|
+
const i = n[e].components;
|
|
48
|
+
o[`--mc-${t}-${e}-l`] = u(r(i[0])), o[`--mc-${t}-${e}-c`] = u(r(i[1])), o[`--mc-${t}-${e}-h`] = u(r(i[2]));
|
|
49
|
+
}
|
|
50
|
+
return o;
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
g as a,
|
|
54
|
+
$ as c,
|
|
55
|
+
k as g,
|
|
56
|
+
N as i,
|
|
57
|
+
b as r,
|
|
58
|
+
m as t
|
|
59
|
+
};
|
package/dist/helper.js
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { mc as m } from "magic-color";
|
|
2
|
+
import { i as h, t as C, a as g, c as d, g as u, r as b } from "./common-Dv0krm1V.js";
|
|
3
|
+
function M(p) {
|
|
4
|
+
const { name: c, color: a, dom: i } = p;
|
|
5
|
+
if (!i)
|
|
6
|
+
return;
|
|
7
|
+
const s = a?.split(/-\d+-?/)[0];
|
|
8
|
+
if (h(s))
|
|
9
|
+
return;
|
|
10
|
+
const e = {}, t = {};
|
|
11
|
+
try {
|
|
12
|
+
if (m.valid(s)) {
|
|
13
|
+
e[`--mc-${c}-color`] = s;
|
|
14
|
+
const o = m.theme(s, { type: "hex" });
|
|
15
|
+
for (const r of C) {
|
|
16
|
+
const n = g({ type: "hex", components: [o[r]], alpha: 1 });
|
|
17
|
+
t[r] = n;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} catch (o) {
|
|
21
|
+
console.error(`[updateMagicColor] get ${s} theme fail, please use another color.`), console.error(o);
|
|
22
|
+
}
|
|
23
|
+
const l = a.match(/.*-(\d+)/)?.[1];
|
|
24
|
+
if (l) {
|
|
25
|
+
const { originDepth: o, beforeDepth: r, afterDepth: n } = b(l);
|
|
26
|
+
t[r] && t[n] && (e[`--mc-${c}-color`] = d({
|
|
27
|
+
originDepth: o,
|
|
28
|
+
beforeDepth: r,
|
|
29
|
+
beforeComponents: t[r].components,
|
|
30
|
+
afterComponents: t[n].components
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
const f = u(c, t);
|
|
34
|
+
Object.assign(e, f);
|
|
35
|
+
for (const o in e)
|
|
36
|
+
e[o] && i.style.setProperty(o, e[o].toString());
|
|
2
37
|
}
|
|
3
38
|
export {
|
|
4
|
-
|
|
39
|
+
M as updateMagicColor
|
|
5
40
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,136 +1,111 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
return;
|
|
13
|
-
if (r.type === "oklch")
|
|
14
|
-
return r.components[0].toString().includes("%") && (r.components[0] = h(r.components[0]) / 100), r.components = r.components.map(h), r;
|
|
15
|
-
const o = r.components.join(" "), e = Q(r.type === "hex" ? o : `${r.type}(${o})`);
|
|
16
|
-
if (e)
|
|
17
|
-
return {
|
|
18
|
-
type: "oklch",
|
|
19
|
-
components: [e.l, e.c, e.h ?? 0],
|
|
20
|
-
alpha: r.alpha
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const M = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
24
|
-
function O(r) {
|
|
25
|
-
let o = Number(r);
|
|
26
|
-
o = o <= 50 ? 50 : o, o = o >= 950 ? 950 : o;
|
|
27
|
-
let e = Math.floor(o / 100) * 100;
|
|
28
|
-
e = e <= 50 ? 50 : e;
|
|
29
|
-
let n = Math.floor((o + 100) / 100) * 100;
|
|
30
|
-
return n = n >= 950 ? 950 : n, { originDepth: o, beforeDepth: e, afterDepth: n };
|
|
31
|
-
}
|
|
32
|
-
function U(r, o) {
|
|
33
|
-
let e = y(r, o);
|
|
34
|
-
if (e?.color)
|
|
35
|
-
return e;
|
|
36
|
-
const [n, a, c] = r.split(/[:/]/), s = n.match(/.*-(\d+)/)?.[1], t = n?.split(/-\d+-?/)[0];
|
|
37
|
-
if (e = {
|
|
1
|
+
import { colorCSSGenerator as R, parseColor as f, defineProperty as m, generateThemeVariable as B, themeTracking as z, detectThemeValue as E, h, SpecialColorKey as G, numberResolver as M, hyphenate as C } from "@unocss/preset-wind4/utils";
|
|
2
|
+
import { mc as y } from "magic-color";
|
|
3
|
+
import { r as V, t as v, i as L, a as x, c as P, g as H } from "./common-Dv0krm1V.js";
|
|
4
|
+
import { notNull as U } from "unocss";
|
|
5
|
+
import { notLastChildSelectorVariant as q } from "@unocss/preset-wind4/rules";
|
|
6
|
+
function A(e, o) {
|
|
7
|
+
let r = f(e, o);
|
|
8
|
+
if (r?.color)
|
|
9
|
+
return r;
|
|
10
|
+
const [t, a, s] = e.split(/[:/]/), c = t.match(/.*-(\d+)/)?.[1], n = t?.split(/-\d+-?/)[0];
|
|
11
|
+
if (r = {
|
|
38
12
|
opacity: a,
|
|
39
|
-
modifier:
|
|
40
|
-
name:
|
|
41
|
-
no:
|
|
13
|
+
modifier: s,
|
|
14
|
+
name: n,
|
|
15
|
+
no: c,
|
|
42
16
|
color: "",
|
|
43
17
|
alpha: a && `${a}%`,
|
|
44
18
|
keys: void 0,
|
|
45
19
|
cssColor: void 0
|
|
46
|
-
},
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let l = y(`${t}-${u}`, o)?.cssColor, m = y(`${t}-${$}`, o)?.cssColor;
|
|
52
|
-
if (!l || !m)
|
|
20
|
+
}, L(n) || !c)
|
|
21
|
+
return r;
|
|
22
|
+
const { originDepth: i, beforeDepth: l, afterDepth: p } = V(c);
|
|
23
|
+
let $ = f(`${n}-${l}`, o)?.cssColor, d = f(`${n}-${p}`, o)?.cssColor;
|
|
24
|
+
if (!$ || !d)
|
|
53
25
|
try {
|
|
54
|
-
const g =
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
|
|
26
|
+
const g = f(n, o);
|
|
27
|
+
if (g?.color && y.valid(g.color)) {
|
|
28
|
+
const b = y.theme(g.color, { type: "hex" });
|
|
29
|
+
$ || ($ = { type: "hex", components: [b[l]], alpha: 1 }), d || (d = { type: "hex", components: [b[p]], alpha: 1 });
|
|
58
30
|
}
|
|
59
31
|
} catch (g) {
|
|
60
|
-
console.error(`[unocss-preset-margicolor] Error parsing ${
|
|
32
|
+
console.error(`[unocss-preset-margicolor] Error parsing ${e}: get ${n} theme fail, please use another color.`), console.error(g);
|
|
61
33
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
return e.color = `oklch(${d.join(" ")})`, e;
|
|
34
|
+
return $ = x($), d = x(d), !$ || !d || (r.color = P({
|
|
35
|
+
originDepth: i,
|
|
36
|
+
beforeDepth: l,
|
|
37
|
+
beforeComponents: $.components,
|
|
38
|
+
afterComponents: d.components
|
|
39
|
+
})), r;
|
|
69
40
|
}
|
|
70
|
-
function
|
|
71
|
-
const o =
|
|
72
|
-
if (!
|
|
73
|
-
return { colorData:
|
|
74
|
-
const { name:
|
|
75
|
-
if (!
|
|
76
|
-
return
|
|
77
|
-
const { originDepth: a, beforeDepth:
|
|
78
|
-
if (!
|
|
79
|
-
const
|
|
80
|
-
|
|
41
|
+
function F(e) {
|
|
42
|
+
const o = [];
|
|
43
|
+
if (!e || e.color)
|
|
44
|
+
return { colorData: e, cssVariables: o };
|
|
45
|
+
const { name: r, no: t } = e;
|
|
46
|
+
if (!t)
|
|
47
|
+
return e.color = `var(--mc-${r}-color)`, { colorData: e, cssVariables: o };
|
|
48
|
+
const { originDepth: a, beforeDepth: s, afterDepth: c } = V(t), n = `--mc-${r}-${a}-l`, i = `--mc-${r}-${a}-c`, l = `--mc-${r}-${a}-h`;
|
|
49
|
+
if (!v.includes(a)) {
|
|
50
|
+
const p = (a - s) / (a < 100 || a > 900 ? 50 : 100), [$, d, g] = ["l", "c", "h"].map((b) => {
|
|
51
|
+
const O = `var(--mc-${r}-${s}-${b})`, N = `var(--mc-${r}-${c}-${b})`;
|
|
52
|
+
return `calc(${O} + ${p} * (${N} - ${O}))`;
|
|
53
|
+
});
|
|
54
|
+
o.push({ [n]: $, [i]: d, [l]: g });
|
|
81
55
|
}
|
|
82
|
-
return
|
|
56
|
+
return e.color = `oklch(var(${n}) var(${i}) var(${l}))`, { colorData: e, cssVariables: o };
|
|
83
57
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
function w(e, o) {
|
|
59
|
+
return F(
|
|
60
|
+
A(e, o)
|
|
61
|
+
);
|
|
87
62
|
}
|
|
88
|
-
function
|
|
89
|
-
return ([,
|
|
90
|
-
const { colorData: a,
|
|
63
|
+
function u(e, o) {
|
|
64
|
+
return ([, r], t) => {
|
|
65
|
+
const { colorData: a, cssVariables: s } = w(r ?? "", t.theme);
|
|
91
66
|
if (a?.color) {
|
|
92
|
-
const
|
|
93
|
-
return
|
|
94
|
-
[
|
|
95
|
-
...
|
|
96
|
-
}),
|
|
67
|
+
const c = R(a, e, o, t);
|
|
68
|
+
return c && s.length && c.push(...s.map((n) => ({
|
|
69
|
+
[t.symbols.selector]: (i) => i,
|
|
70
|
+
...n
|
|
71
|
+
}))), c;
|
|
97
72
|
}
|
|
98
73
|
};
|
|
99
74
|
}
|
|
100
|
-
const
|
|
75
|
+
const J = {
|
|
101
76
|
transparent: "transparent",
|
|
102
77
|
current: "currentColor",
|
|
103
78
|
inherit: "inherit"
|
|
104
|
-
},
|
|
105
|
-
"gradient-position":
|
|
106
|
-
"gradient-from":
|
|
107
|
-
"gradient-via":
|
|
108
|
-
"gradient-to":
|
|
109
|
-
"gradient-stops":
|
|
110
|
-
"gradient-via-stops":
|
|
111
|
-
"gradient-from-position":
|
|
112
|
-
"gradient-via-position":
|
|
113
|
-
"gradient-to-position":
|
|
79
|
+
}, Q = {
|
|
80
|
+
"gradient-position": m("--un-gradient-position"),
|
|
81
|
+
"gradient-from": m("--un-gradient-from", { syntax: "<color>", initialValue: "#0000" }),
|
|
82
|
+
"gradient-via": m("--un-gradient-via", { syntax: "<color>", initialValue: "#0000" }),
|
|
83
|
+
"gradient-to": m("--un-gradient-to", { syntax: "<color>", initialValue: "#0000" }),
|
|
84
|
+
"gradient-stops": m("--un-gradient-stops"),
|
|
85
|
+
"gradient-via-stops": m("--un-gradient-via-stops"),
|
|
86
|
+
"gradient-from-position": m("--un-gradient-from-position", { syntax: "<length-percentage>", initialValue: "0%" }),
|
|
87
|
+
"gradient-via-position": m("--un-gradient-via-position", { syntax: "<length-percentage>", initialValue: "50%" }),
|
|
88
|
+
"gradient-to-position": m("--un-gradient-to-position", { syntax: "<length-percentage>", initialValue: "100%" })
|
|
114
89
|
};
|
|
115
|
-
function
|
|
116
|
-
return function* ([,
|
|
117
|
-
const a = {}, { colorData:
|
|
118
|
-
if (
|
|
119
|
-
const { color:
|
|
120
|
-
if (
|
|
121
|
-
if (Object.values(
|
|
122
|
-
a[`--un-gradient-${
|
|
90
|
+
function W() {
|
|
91
|
+
return function* ([, e, o], { theme: r, symbols: t }) {
|
|
92
|
+
const a = {}, { colorData: s, cssVariables: c } = w(o, r);
|
|
93
|
+
if (s) {
|
|
94
|
+
const { color: n, keys: i, alpha: l } = s;
|
|
95
|
+
if (n) {
|
|
96
|
+
if (Object.values(J).includes(n))
|
|
97
|
+
a[`--un-gradient-${e}`] = n;
|
|
123
98
|
else {
|
|
124
|
-
a[`--un-${
|
|
125
|
-
const
|
|
126
|
-
a[`--un-gradient-${
|
|
99
|
+
a[`--un-${e}-opacity`] = l;
|
|
100
|
+
const p = i ? B("colors", i) : n;
|
|
101
|
+
a[`--un-gradient-${e}`] = `color-mix(in oklab, ${p} var(--un-${e}-opacity), transparent)`, yield m(`--un-${e}-opacity`, { syntax: "<percentage>", initialValue: "100%" });
|
|
127
102
|
}
|
|
128
|
-
i &&
|
|
103
|
+
i && z("colors", i), r && E(n, r);
|
|
129
104
|
}
|
|
130
105
|
} else
|
|
131
|
-
a[`--un-gradient-${
|
|
132
|
-
if (a[`--un-gradient-${
|
|
133
|
-
switch (
|
|
106
|
+
a[`--un-gradient-${e}`] = h.bracket.cssvar(o);
|
|
107
|
+
if (a[`--un-gradient-${e}`]) {
|
|
108
|
+
switch (e) {
|
|
134
109
|
case "from":
|
|
135
110
|
yield {
|
|
136
111
|
...a,
|
|
@@ -154,16 +129,17 @@ function Z() {
|
|
|
154
129
|
yield { ...a };
|
|
155
130
|
break;
|
|
156
131
|
}
|
|
157
|
-
for (const
|
|
158
|
-
yield
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
132
|
+
for (const n of Object.values(Q))
|
|
133
|
+
yield n;
|
|
134
|
+
for (const n of c)
|
|
135
|
+
yield {
|
|
136
|
+
[t.selector]: (i) => i,
|
|
137
|
+
...n
|
|
138
|
+
};
|
|
163
139
|
}
|
|
164
140
|
};
|
|
165
141
|
}
|
|
166
|
-
const
|
|
142
|
+
const S = {
|
|
167
143
|
l: ["-left"],
|
|
168
144
|
r: ["-right"],
|
|
169
145
|
t: ["-top"],
|
|
@@ -182,202 +158,218 @@ const T = {
|
|
|
182
158
|
block: ["-block-start", "-block-end"],
|
|
183
159
|
inline: ["-inline-start", "-inline-end"]
|
|
184
160
|
};
|
|
185
|
-
function
|
|
186
|
-
if (
|
|
187
|
-
const { colorData:
|
|
188
|
-
if (
|
|
189
|
-
const
|
|
161
|
+
function k([, e = "", o], r) {
|
|
162
|
+
if (e in S) {
|
|
163
|
+
const { colorData: t, cssVariables: a } = w(o ?? "", r.theme);
|
|
164
|
+
if (t) {
|
|
165
|
+
const s = S[e].map((c) => X(c)(t, r)).filter(U);
|
|
190
166
|
return [
|
|
191
|
-
|
|
192
|
-
...
|
|
193
|
-
{
|
|
194
|
-
[
|
|
195
|
-
...
|
|
196
|
-
}
|
|
167
|
+
s.map((c) => c[0]).reduce((c, n) => (Object.assign(c, n), c), {}),
|
|
168
|
+
...s.flatMap((c) => c.slice(1)),
|
|
169
|
+
...a.map((c) => ({
|
|
170
|
+
[r.symbols.selector]: (n) => n,
|
|
171
|
+
...c
|
|
172
|
+
}))
|
|
197
173
|
];
|
|
198
174
|
}
|
|
199
175
|
}
|
|
200
176
|
}
|
|
201
|
-
function
|
|
202
|
-
return (o,
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const a =
|
|
206
|
-
return o?.color && !Object.values(
|
|
177
|
+
function X(e) {
|
|
178
|
+
return (o, r) => {
|
|
179
|
+
const t = R(o, `border${e}-color`, `border${e}`, r);
|
|
180
|
+
if (t) {
|
|
181
|
+
const a = t[0];
|
|
182
|
+
return o?.color && !Object.values(G).includes(o.color) && !o.alpha && e && e !== "" && (a[`--un-border${e}-opacity`] = "var(--un-border-opacity)"), t;
|
|
207
183
|
}
|
|
208
184
|
};
|
|
209
185
|
}
|
|
210
|
-
const
|
|
186
|
+
const Y = {
|
|
211
187
|
"mask-image": "var(--un-mask-linear), var(--un-mask-radial), var(--un-mask-conic)",
|
|
212
188
|
"mask-composite": "intersect"
|
|
213
|
-
},
|
|
189
|
+
}, j = {
|
|
214
190
|
t: ["top"],
|
|
215
191
|
b: ["bottom"],
|
|
216
192
|
l: ["left"],
|
|
217
193
|
r: ["right"],
|
|
218
194
|
x: ["left", "right"],
|
|
219
195
|
y: ["top", "bottom"]
|
|
220
|
-
},
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
for (const
|
|
226
|
-
|
|
227
|
-
const i =
|
|
196
|
+
}, D = "linear-gradient(#fff, #fff)";
|
|
197
|
+
function T([e, o = "", r, t], a) {
|
|
198
|
+
const s = { ...Y }, c = [];
|
|
199
|
+
if (c.push(...["linear", "radial", "conic"].map((n) => m(`--un-mask-${n}`, { initialValue: D }))), o in j) {
|
|
200
|
+
s["--un-mask-linear"] = "var(--un-mask-left), var(--un-mask-right), var(--un-mask-bottom), var(--un-mask-top)";
|
|
201
|
+
for (const n of j[o]) {
|
|
202
|
+
s[`--un-mask-${n}`] = `linear-gradient(to ${n}, var(--un-mask-${n}-from-color) var(--un-mask-${n}-from-position), var(--un-mask-${n}-to-color) var(--un-mask-${n}-to-position))`, M(t) != null ? (z("spacing"), s[`--un-mask-${n}-${r}-position`] = `calc(var(--spacing) * ${h.bracket.cssvar.fraction.number(t)})`) : s[`--un-mask-${n}-${r}-position`] = h.bracket.cssvar.fraction.rem(t);
|
|
203
|
+
const i = u(`--un-mask-${n}-${r}-color`, C("colors"))([e, t], a);
|
|
228
204
|
if (i) {
|
|
229
|
-
const [
|
|
230
|
-
Object.assign(
|
|
205
|
+
const [l, ...p] = i;
|
|
206
|
+
Object.assign(s, l), c.push(...p);
|
|
231
207
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
208
|
+
c.push(...["from", "to"].flatMap((l) => [
|
|
209
|
+
m(`--un-mask-${n}-${l}-position`, { syntax: "<length-percentage>", initialValue: l === "from" ? "0%" : "100%" }),
|
|
210
|
+
m(`--un-mask-${n}-${l}-color`, { syntax: "<color>", initialValue: l === "from" ? "black" : "transparent" })
|
|
235
211
|
]));
|
|
236
212
|
}
|
|
237
|
-
|
|
213
|
+
c.push(...["top", "right", "bottom", "left"].map((n) => m(`--un-mask-${n}`, { initialValue: D })));
|
|
238
214
|
} else {
|
|
239
|
-
if (
|
|
240
|
-
o === "radial" ? (
|
|
215
|
+
if (r == null)
|
|
216
|
+
o === "radial" ? (s["--un-mask-radial"] = "radial-gradient(var(--un-mask-radial-stops, var(--un-mask-radial-size)))", s["--un-mask-radial-size"] = h.bracket.cssvar.rem(t)) : (s[`--un-mask-${o}`] = `${o}-gradient(var(--un-mask-${o}-stops, var(--un-mask-${o}-position)))`, s[`--un-mask-${o}-position`] = M(t) ? `calc(1deg * ${h.bracket.cssvar.number(t)})` : h.bracket.cssvar.fraction(t));
|
|
241
217
|
else {
|
|
242
|
-
const
|
|
218
|
+
const n = {
|
|
243
219
|
linear: "",
|
|
244
220
|
radial: "var(--un-mask-radial-shape) var(--un-mask-radial-size) at ",
|
|
245
221
|
conic: "from "
|
|
246
222
|
};
|
|
247
|
-
|
|
248
|
-
const i =
|
|
223
|
+
s[`--un-mask-${o}-stops`] = `${n[o]}var(--un-mask-${o}-position), var(--un-mask-${o}-from-color) var(--un-mask-${o}-from-position), var(--un-mask-${o}-to-color) var(--un-mask-${o}-to-position)`, s[`--un-mask-${o}`] = `${o}-gradient(var(--un-mask-${o}-stops))`;
|
|
224
|
+
const i = u(`--un-mask-${o}-${r}-color`, C("colors"))([e, t], a);
|
|
249
225
|
if (i) {
|
|
250
|
-
const [
|
|
251
|
-
Object.assign(
|
|
226
|
+
const [l, ...p] = i;
|
|
227
|
+
Object.assign(s, l), c.push(...p);
|
|
252
228
|
}
|
|
253
229
|
}
|
|
254
|
-
o === "radial" &&
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
230
|
+
o === "radial" && c.push(m("--un-mask-radial-shape", { initialValue: "ellipse" }), m("--un-mask-radial-size", { initialValue: "farthest-corner" })), c.push(...["from", "to"].flatMap((n) => [
|
|
231
|
+
m(`--un-mask-${o}-position`, { initialValue: o === "radial" ? "center" : "0deg" }),
|
|
232
|
+
m(`--un-mask-${o}-${n}-position`, { syntax: "<length-percentage>", initialValue: n === "from" ? "0%" : "100%" }),
|
|
233
|
+
m(`--un-mask-${o}-${n}-color`, { syntax: "<color>", initialValue: n === "from" ? "black" : "transparent" })
|
|
258
234
|
]));
|
|
259
235
|
}
|
|
260
|
-
return [
|
|
236
|
+
return [s, ...c];
|
|
261
237
|
}
|
|
262
|
-
function
|
|
263
|
-
return (o,
|
|
264
|
-
const
|
|
265
|
-
return
|
|
238
|
+
function I(e) {
|
|
239
|
+
return (o, r) => {
|
|
240
|
+
const t = C(e);
|
|
241
|
+
return u(`--un-${t}-color`, t)(o, r);
|
|
266
242
|
};
|
|
267
243
|
}
|
|
268
|
-
|
|
244
|
+
function Z(e, o) {
|
|
245
|
+
const r = e?.split(/-\d+-?/)[0];
|
|
246
|
+
if (L(r))
|
|
247
|
+
return;
|
|
248
|
+
const t = {};
|
|
249
|
+
let a = !1;
|
|
250
|
+
for (const s of v) {
|
|
251
|
+
const c = f(`${r}-${s}`, o)?.cssColor;
|
|
252
|
+
c ? t[s] = c : a = !0;
|
|
253
|
+
}
|
|
254
|
+
if (a)
|
|
255
|
+
try {
|
|
256
|
+
let s = f(r, o);
|
|
257
|
+
if (s?.color || (s = f(`[${r}]`, o)), s?.color && y.valid(s.color)) {
|
|
258
|
+
const c = y.theme(s.color, { type: "hex" });
|
|
259
|
+
for (const n of v)
|
|
260
|
+
t[n] || (t[n] = { type: "hex", components: [c[n]], alpha: 1 });
|
|
261
|
+
}
|
|
262
|
+
} catch (s) {
|
|
263
|
+
console.error(`[unocss-preset-margicolor] get ${r} theme fail, please use another color.`), console.error(s);
|
|
264
|
+
}
|
|
265
|
+
for (const s of v)
|
|
266
|
+
t[s] = x(t[s]);
|
|
267
|
+
return t;
|
|
268
|
+
}
|
|
269
|
+
function _(e, o, r, t) {
|
|
270
|
+
const a = o.match(/.*-(\d+)/)?.[1], s = {};
|
|
271
|
+
let c = f(o, t)?.color;
|
|
272
|
+
if (!c && !a && (c = f(`[${o}]`, t)?.color), c)
|
|
273
|
+
s[`--mc-${e}-color`] = c;
|
|
274
|
+
else if (a) {
|
|
275
|
+
const { originDepth: i, beforeDepth: l, afterDepth: p } = V(a);
|
|
276
|
+
r[l] && r[p] && (s[`--mc-${e}-color`] = P({
|
|
277
|
+
originDepth: i,
|
|
278
|
+
beforeDepth: l,
|
|
279
|
+
beforeComponents: r[l].components,
|
|
280
|
+
afterComponents: r[p].components
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
const n = H(e, r);
|
|
284
|
+
return Object.assign(s, n);
|
|
285
|
+
}
|
|
286
|
+
function K(e, o, r = {}) {
|
|
287
|
+
if (f(e, r)?.color) {
|
|
288
|
+
console.error(`[unocss-preset-margicolor] The color name '${e}' has been configured in the theme, please use the another name.`);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const [t] = o.split(/[:/]/), a = Z(t, r);
|
|
292
|
+
if (a)
|
|
293
|
+
return _(e, t, a, r);
|
|
294
|
+
}
|
|
295
|
+
function oo(e) {
|
|
296
|
+
return e.colors ? [{
|
|
297
|
+
getCSS: ({ theme: o }) => {
|
|
298
|
+
const r = {};
|
|
299
|
+
for (const t in e.colors)
|
|
300
|
+
Object.assign(r, K(t, e.colors[t], o));
|
|
301
|
+
return `
|
|
302
|
+
:root {
|
|
303
|
+
${Object.entries(r).map(([t, a]) => `${t}: ${a};`).join(`
|
|
304
|
+
`)}
|
|
305
|
+
}
|
|
306
|
+
`;
|
|
307
|
+
}
|
|
308
|
+
}] : [];
|
|
309
|
+
}
|
|
310
|
+
const ro = [
|
|
269
311
|
// common style colors
|
|
270
|
-
[/^(?:color|c)-mc-(.+)$/,
|
|
271
|
-
[/^text-(?:color-)?mc-(.+)$/,
|
|
272
|
-
[/^outline-(?:color-)?mc-(.+)$/,
|
|
273
|
-
[/^accent-mc-(.+)$/,
|
|
274
|
-
[/^caret-mc-(.+)$/,
|
|
275
|
-
[/^bg-mc-(.+)$/,
|
|
312
|
+
[/^(?:color|c)-mc-(.+)$/, u("color", "text"), { autocomplete: "(color|c)-mc-$colors" }],
|
|
313
|
+
[/^text-(?:color-)?mc-(.+)$/, u("color", "text"), { autocomplete: "(text|text-color)-mc-$colors" }],
|
|
314
|
+
[/^outline-(?:color-)?mc-(.+)$/, u("outline-color", "outline"), { autocomplete: "(outline|outline-color)-mc-$colors" }],
|
|
315
|
+
[/^accent-mc-(.+)$/, u("accent-color", "accent"), { autocomplete: "accent-mc-$colors" }],
|
|
316
|
+
[/^caret-mc-(.+)$/, u("caret-color", "caret"), { autocomplete: "caret-mc-$colors" }],
|
|
317
|
+
[/^bg-mc-(.+)$/, u("background-color", "bg"), { autocomplete: "bg-mc-$colors" }],
|
|
276
318
|
// from https://github.com/unocss/unocss/blob/main/packages-presets/preset-wind4/src/rules/decoration.ts
|
|
277
|
-
[/^(?:underline|decoration)-mc-(.+)$/, (
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
return
|
|
319
|
+
[/^(?:underline|decoration)-mc-(.+)$/, (e, o) => {
|
|
320
|
+
const r = u("text-decoration-color", "line")(e, o);
|
|
321
|
+
if (r) {
|
|
322
|
+
const t = r[0];
|
|
323
|
+
return t["-webkit-text-decoration-color"] = t["text-decoration-color"], r;
|
|
282
324
|
}
|
|
283
325
|
}, { autocomplete: "(underline|decoration)-mc-$colors" }],
|
|
284
326
|
// from https://github.com/unocss/unocss/blob/main/packages-presets/preset-wind4/src/rules/divide.ts
|
|
285
|
-
[/^divide-mc-(.+)$/, function* (
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
[o.symbols.variants]: [
|
|
289
|
-
...
|
|
290
|
-
}, yield
|
|
327
|
+
[/^divide-mc-(.+)$/, function* (e, o) {
|
|
328
|
+
const r = u("border-color", "divide")(e, o);
|
|
329
|
+
r && (yield {
|
|
330
|
+
[o.symbols.variants]: [q(e[0])],
|
|
331
|
+
...r[0]
|
|
332
|
+
}, yield r[1]);
|
|
291
333
|
}, { autocomplete: "divide-mc-$colors" }],
|
|
292
|
-
[/^(?:filter-)?drop-shadow-color-mc-(.+)$/,
|
|
293
|
-
[/^\$ placeholder-mc-(.+)$/,
|
|
294
|
-
[/^ring-mc-(.+)$/,
|
|
295
|
-
[/^inset-ring-mc-(.+)$/,
|
|
296
|
-
[/^ring-offset-mc-(.+)$/,
|
|
297
|
-
[/^shadow-mc-(.+)$/,
|
|
298
|
-
[/^inset-shadow-mc(.+)$/,
|
|
299
|
-
[/^fill-mc-(.+)$/,
|
|
300
|
-
[/^stroke-mc-(.+)$/,
|
|
301
|
-
[/^text-stroke-mc-(.+)$/,
|
|
302
|
-
[/^text-shadow-(?:color-)?mc-(.+)$/,
|
|
303
|
-
[/^mask-(linear|radial|conic)-(from|to)-mc-(.+)$/,
|
|
304
|
-
[/^mask-([trblxy])-(from|to)-mc-(.+)$/,
|
|
334
|
+
[/^(?:filter-)?drop-shadow-color-mc-(.+)$/, u("--un-drop-shadow-color", "drop-shadow"), { autocomplete: "divide-mc-$colors" }],
|
|
335
|
+
[/^\$ placeholder-mc-(.+)$/, u("color", "placeholder"), { autocomplete: "placeholder-mc-$colors" }],
|
|
336
|
+
[/^ring-mc-(.+)$/, u("--un-ring-color", "ring"), { autocomplete: "ring-mc-$colors" }],
|
|
337
|
+
[/^inset-ring-mc-(.+)$/, u("--un-inset-ring-color", "inset-ring"), { autocomplete: "inset-ring-mc-$colors" }],
|
|
338
|
+
[/^ring-offset-mc-(.+)$/, u("--un-ring-offset-color", "ring-offset"), { autocomplete: "ring-offset-mc-$colors" }],
|
|
339
|
+
[/^shadow-mc-(.+)$/, I("shadow"), { autocomplete: ["shadow-$colors", "shadow-mc-$shadow"] }],
|
|
340
|
+
[/^inset-shadow-mc(.+)$/, I("insetShadow"), { autocomplete: ["inset-shadow-mc-$colors", "inset-shadow-mc-$insetShadow"] }],
|
|
341
|
+
[/^fill-mc-(.+)$/, u("fill", "fill"), { autocomplete: "fill-mc-$colors" }],
|
|
342
|
+
[/^stroke-mc-(.+)$/, u("stroke", "stroke"), { autocomplete: "stroke-mc-$colors" }],
|
|
343
|
+
[/^text-stroke-mc-(.+)$/, u("-webkit-text-stroke-color", "text-stroke"), { autocomplete: "text-stroke-mc-$colors" }],
|
|
344
|
+
[/^text-shadow-(?:color-)?mc-(.+)$/, u("--un-text-shadow-color", "text-shadow"), { autocomplete: ["text-shadow(-color)?-mc-$colors"] }],
|
|
345
|
+
[/^mask-(linear|radial|conic)-(from|to)-mc-(.+)$/, T, { autocomplete: ["mask-(linear|radial|conic)-(from|to)-mc-$colors"] }],
|
|
346
|
+
[/^mask-([trblxy])-(from|to)-mc-(.+)$/, T, { autocomplete: ["mask-(x|y|t|b|l|r)-(from|to)-mc-$colors"] }],
|
|
305
347
|
// border style colors
|
|
306
|
-
[/^(?:border|b)-()(?:color-)?mc-(.+)$/,
|
|
307
|
-
[/^(?:border|b)-([xy])-(?:color-)?mc-(.+)$/,
|
|
308
|
-
[/^(?:border|b)-([rltbse])-(?:color-)?mc-(.+)$/,
|
|
309
|
-
[/^(?:border|b)-(block|inline)-(?:color-)?mc-(.+)$/,
|
|
310
|
-
[/^(?:border|b)-([bi][se])-(?:color-)?mc-(.+)$/,
|
|
348
|
+
[/^(?:border|b)-()(?:color-)?mc-(.+)$/, k, { autocomplete: ["(border|b)-mc-$colors", "(border|b)-<directions>-mc-$colors"] }],
|
|
349
|
+
[/^(?:border|b)-([xy])-(?:color-)?mc-(.+)$/, k],
|
|
350
|
+
[/^(?:border|b)-([rltbse])-(?:color-)?mc-(.+)$/, k],
|
|
351
|
+
[/^(?:border|b)-(block|inline)-(?:color-)?mc-(.+)$/, k],
|
|
352
|
+
[/^(?:border|b)-([bi][se])-(?:color-)?mc-(.+)$/, k],
|
|
311
353
|
// bg gradient color
|
|
312
|
-
[/^(from|via|to|stops)-mc-(.+)$/,
|
|
313
|
-
],
|
|
314
|
-
[/^mc-(.+)$/,
|
|
354
|
+
[/^(from|via|to|stops)-mc-(.+)$/, W()]
|
|
355
|
+
], eo = [
|
|
356
|
+
[/^mc-(.+)$/, to]
|
|
315
357
|
];
|
|
316
|
-
function
|
|
317
|
-
const e =
|
|
318
|
-
|
|
319
|
-
return;
|
|
320
|
-
if (y(n, o)?.color) {
|
|
321
|
-
console.error(`[unocss-preset-margicolor][mc-${r}] The color name '${n}' has been configured in the theme, please use the another name.`);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
const [c] = a.split(/[:/]/), s = c.match(/.*-(\d+)/)?.[1], t = c?.split(/-\d+-?/)[0];
|
|
325
|
-
if (!t || !Number.isNaN(Number(t))) {
|
|
326
|
-
console.error(`[unocss-preset-margicolor][mc-${r}] The color '${t}' is invalid.`);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const i = {};
|
|
330
|
-
let u = !1;
|
|
331
|
-
for (const l of M) {
|
|
332
|
-
const m = y(`${t}-${l}`, o)?.cssColor;
|
|
333
|
-
m ? i[l] = m : u = !0;
|
|
334
|
-
}
|
|
335
|
-
if (u)
|
|
336
|
-
try {
|
|
337
|
-
const l = y(t, o)?.color, m = l ? K(l) : void 0;
|
|
338
|
-
if (m && N.valid(m)) {
|
|
339
|
-
const b = N.theme(m);
|
|
340
|
-
for (const d of M)
|
|
341
|
-
if (!i[d]) {
|
|
342
|
-
const g = C({ type: "hex", components: [b[d]], alpha: 1 });
|
|
343
|
-
i[d] = g;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
} catch (l) {
|
|
347
|
-
console.error(`[unocss-preset-margicolor] Error parsing ${r}: get ${t} theme fail, please use another color.`), console.error(l);
|
|
348
|
-
}
|
|
349
|
-
for (const l of M)
|
|
350
|
-
i[l] = C(i[l]);
|
|
351
|
-
const $ = y(c, o);
|
|
352
|
-
if ($?.color)
|
|
353
|
-
e[`--mc-${n}-color`] = $.color;
|
|
354
|
-
else if (s) {
|
|
355
|
-
const { originDepth: l, beforeDepth: m, afterDepth: b } = O(s);
|
|
356
|
-
if (i[m] && i[b]) {
|
|
357
|
-
const d = (l - m) / 100, g = Array.from({ length: 3 }).map((k, v) => {
|
|
358
|
-
const w = i[m].components, S = i[b].components, _ = h(w[v]) + (h(S[v]) - h(w[v])) * d;
|
|
359
|
-
return `${Math.round(_ * 1e3) / 1e3}`;
|
|
360
|
-
});
|
|
361
|
-
e[`--mc-${n}-color`] = `oklch(${g.join(" ")})`;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
for (const l of M)
|
|
365
|
-
if (i[l]) {
|
|
366
|
-
const m = i[l].components;
|
|
367
|
-
e[`--mc-${n}-${l}-l`] = Math.round(h(m[0]) * 1e3) / 1e3, e[`--mc-${n}-${l}-c`] = Math.round(h(m[1]) * 1e3) / 1e3, e[`--mc-${n}-${l}-h`] = Math.round(h(m[2]) * 1e3) / 1e3;
|
|
368
|
-
}
|
|
369
|
-
return e;
|
|
358
|
+
function to([, e], { theme: o }) {
|
|
359
|
+
const r = e.indexOf("_"), t = e.substring(0, r), a = e.substring(r + 1);
|
|
360
|
+
return a ? K(t, a, o) : void 0;
|
|
370
361
|
}
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
362
|
+
const no = [
|
|
363
|
+
ro,
|
|
364
|
+
eo
|
|
374
365
|
].flat();
|
|
375
|
-
function uo(
|
|
366
|
+
function uo(e = {}) {
|
|
376
367
|
return {
|
|
377
368
|
name: "unocss-preset-magicolor",
|
|
378
369
|
layer: "unocss-preset-magicolor",
|
|
379
370
|
layers: { "unocss-preset-magicolor": -100 },
|
|
380
|
-
rules:
|
|
371
|
+
rules: no,
|
|
372
|
+
preflights: oo(e)
|
|
381
373
|
};
|
|
382
374
|
}
|
|
383
375
|
export {
|
package/dist/types/helper.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Modify the value of the color variable
|
|
3
|
+
* @param params params Parameter object
|
|
4
|
+
* @param params.name Color name
|
|
5
|
+
* @param params.color Color
|
|
6
|
+
* @param params.dom params.dom Target element, modifying the entire page theme when passing `document.documentElement`
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateMagicColor(params: {
|
|
9
|
+
name: string;
|
|
10
|
+
color: string;
|
|
11
|
+
dom?: HTMLElement;
|
|
12
|
+
}): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Preset } from 'unocss';
|
|
2
2
|
import { PresetMcOptions } from './types';
|
|
3
|
-
export declare function presetMagicolor(
|
|
3
|
+
export declare function presetMagicolor(options?: PresetMcOptions): Preset;
|
|
4
4
|
export * from './types';
|
|
5
5
|
export default presetMagicolor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Theme } from '@unocss/preset-wind4';
|
|
2
|
+
import { CSSObject } from 'unocss';
|
|
3
|
+
/**
|
|
4
|
+
* resolve color variable
|
|
5
|
+
* @param name color name
|
|
6
|
+
* @param hue `color-depth`: color can be theme color or css color
|
|
7
|
+
* @param theme unocss theme
|
|
8
|
+
* @returns css variables
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveThemeColorVariable(name: string, hue: string, theme?: Theme): CSSObject | undefined;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { Theme } from '@unocss/preset-wind4';
|
|
2
2
|
import { CSSObject, CSSValueInput, RuleContext } from 'unocss';
|
|
3
|
-
import { ThemeKey } from '../typing';
|
|
4
|
-
export declare const themeMetaList: ThemeKey[];
|
|
5
|
-
export declare function resolveDepth(no: string): {
|
|
6
|
-
originDepth: number;
|
|
7
|
-
beforeDepth: number;
|
|
8
|
-
afterDepth: number;
|
|
9
|
-
};
|
|
10
3
|
export declare function parseMagicColor(body: string, theme: Theme): {
|
|
11
4
|
colorData: {
|
|
12
5
|
opacity: string | undefined;
|
|
@@ -18,6 +11,6 @@ export declare function parseMagicColor(body: string, theme: Theme): {
|
|
|
18
11
|
keys: string[] | undefined;
|
|
19
12
|
readonly cssColor: import('@unocss/preset-wind4/utils').CSSColorValue | undefined;
|
|
20
13
|
} | undefined;
|
|
21
|
-
|
|
14
|
+
cssVariables: CSSObject[];
|
|
22
15
|
};
|
|
23
16
|
export declare function mcColorResolver(property: string, varName: string): ([, body]: string[], ctx: RuleContext<Theme>) => (CSSValueInput | string)[] | undefined;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CSSColorValue } from '@unocss/preset-wind4/utils';
|
|
2
|
+
import { CSSObject } from 'unocss';
|
|
3
|
+
import { ThemeKey } from '../typing';
|
|
4
|
+
export declare const themeMetaList: ThemeKey[];
|
|
5
|
+
export declare function resolveDepth(no: string): {
|
|
6
|
+
originDepth: keyof import('magic-color').ThemeMetas;
|
|
7
|
+
beforeDepth: keyof import('magic-color').ThemeMetas;
|
|
8
|
+
afterDepth: keyof import('magic-color').ThemeMetas;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* is invalid color
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInvalidColor(color?: string): boolean;
|
|
14
|
+
export declare function countDiffColor(params: {
|
|
15
|
+
originDepth: number;
|
|
16
|
+
beforeDepth: number;
|
|
17
|
+
beforeComponents: (string | number)[];
|
|
18
|
+
afterComponents: (string | number)[];
|
|
19
|
+
}): string;
|
|
20
|
+
export declare function generateOklchVariable(name: string, themeMetaColors: Partial<Record<ThemeKey, CSSColorValue>>): CSSObject;
|
|
@@ -3,3 +3,5 @@ import { CSSColorValue } from '@unocss/preset-wind4/utils';
|
|
|
3
3
|
export declare function toNum(value?: string | number): number;
|
|
4
4
|
/** to oklch color */
|
|
5
5
|
export declare function toOklch(cssColor?: CSSColorValue): CSSColorValue | undefined;
|
|
6
|
+
/** Math.round(num * 1000) / 1000 */
|
|
7
|
+
export declare function roundNum(num: number): number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unocss-preset-magicolor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Unocss预设",
|
|
6
6
|
"author": "nxy",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,12 +26,10 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@unocss/preset-wind4": "66.5.
|
|
30
|
-
"
|
|
31
|
-
"magic-color": "^2.1.0"
|
|
29
|
+
"@unocss/preset-wind4": "~66.5.9",
|
|
30
|
+
"magic-color": "^2.2.3"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"
|
|
35
|
-
"unocss": "^66.5.4"
|
|
33
|
+
"unocss": "^66.5.9"
|
|
36
34
|
}
|
|
37
35
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|