@starasia/theme 3.0.0 → 3.0.1
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/helpers/index.d.ts +0 -5
- package/dist/index.es.js +57 -220
- package/dist/index.umd.js +4 -29
- package/package.json +1 -1
- package/dist/helpers/brandcolor.d.ts +0 -3
- package/dist/helpers/colorpalette.d.ts +0 -3
- package/dist/helpers/components.d.ts +0 -3
- package/dist/helpers/font.d.ts +0 -8
- package/dist/helpers/generator.d.ts +0 -3
- package/dist/helpers/maincolor.d.ts +0 -3
- package/dist/helpers/metric.d.ts +0 -3
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1,213 +1,50 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
|
|
4
|
-
let o = "";
|
|
5
|
-
for (const n in r)
|
|
6
|
-
if (Object.hasOwnProperty.call(r, n)) {
|
|
7
|
-
const e = r[n];
|
|
8
|
-
o += `/* ${n} */
|
|
9
|
-
`;
|
|
10
|
-
for (const s in e)
|
|
11
|
-
if (Object.hasOwnProperty.call(e, s)) {
|
|
12
|
-
const i = e[s];
|
|
13
|
-
o += `--${t}-${n}-${s}: ${i};
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return o;
|
|
18
|
-
}
|
|
19
|
-
function C(r, t) {
|
|
20
|
-
let o = "";
|
|
21
|
-
for (const n in r) {
|
|
22
|
-
const e = r[n];
|
|
23
|
-
for (const s in e) {
|
|
24
|
-
const i = e[s], c = s ? `${t}-${n}-${s}` : `${t}-${n}`;
|
|
25
|
-
o += `--${c}: ${i};
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return o;
|
|
30
|
-
}
|
|
31
|
-
function M(r, t) {
|
|
32
|
-
let o = "";
|
|
33
|
-
function n(e, s, i = "", c = "", l = "") {
|
|
34
|
-
if (l) {
|
|
35
|
-
const a = `${i}${l}-${c}-${e}`;
|
|
36
|
-
o += `--${a}: ${s};
|
|
37
|
-
`;
|
|
38
|
-
} else {
|
|
39
|
-
const a = `${i}${e}-${c}`;
|
|
40
|
-
o += `--${a}: ${s};
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
for (const e in r) {
|
|
45
|
-
const s = r[e];
|
|
46
|
-
for (const i in s) {
|
|
47
|
-
const c = s[i];
|
|
48
|
-
if (typeof c == "object")
|
|
49
|
-
for (const l in c) {
|
|
50
|
-
const a = c[l], u = `${t}-`;
|
|
51
|
-
n(
|
|
52
|
-
i,
|
|
53
|
-
a,
|
|
54
|
-
u,
|
|
55
|
-
e,
|
|
56
|
-
l
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const l = `${t}-`;
|
|
61
|
-
n(i, c, l, e);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return o;
|
|
66
|
-
}
|
|
67
|
-
function B(r, t = "") {
|
|
68
|
-
let o = "";
|
|
69
|
-
function n(e, s, i = "") {
|
|
70
|
-
if (typeof s == "object")
|
|
71
|
-
for (const c in s) {
|
|
72
|
-
const l = s[c], a = `--${i}-${e}-${c}`;
|
|
73
|
-
o += `${a}: ${l};
|
|
74
|
-
`;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
const c = `--${i}-${e}`;
|
|
78
|
-
o += `${c}: ${s};
|
|
79
|
-
`;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
for (const e in r) {
|
|
83
|
-
const s = r[e];
|
|
84
|
-
if (typeof s == "object")
|
|
85
|
-
n(e, s, `${t}`);
|
|
86
|
-
else {
|
|
87
|
-
const i = `--${t}-${e}`;
|
|
88
|
-
o += `${i}: ${s};
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return o;
|
|
93
|
-
}
|
|
94
|
-
function D(r, t = "") {
|
|
95
|
-
let o = "";
|
|
96
|
-
for (const n in r) {
|
|
97
|
-
const e = r[n];
|
|
98
|
-
for (const s in e) {
|
|
99
|
-
const i = `--${t}-${n}-${s}`, c = e[s];
|
|
100
|
-
o += `${i}: ${c};
|
|
101
|
-
`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return o;
|
|
105
|
-
}
|
|
106
|
-
function H(r, t) {
|
|
107
|
-
let o = "";
|
|
108
|
-
for (const n in r)
|
|
109
|
-
if (Object.hasOwnProperty.call(r, n)) {
|
|
110
|
-
const e = r[n];
|
|
111
|
-
n === "default" ? o += `--${t}: ${e};
|
|
112
|
-
` : o += `--${t}-${n}: ${e};
|
|
113
|
-
`;
|
|
114
|
-
}
|
|
115
|
-
return o;
|
|
116
|
-
}
|
|
117
|
-
const J = (r) => {
|
|
1
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useState as g, useMemo as a, useRef as f, useEffect as v, useContext as j } from "react";
|
|
3
|
+
const w = (r) => {
|
|
118
4
|
const t = document.getElementById(r);
|
|
119
5
|
if (t)
|
|
120
6
|
return t;
|
|
121
|
-
const
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
function g(r, t) {
|
|
125
|
-
let o = "";
|
|
126
|
-
return Object.keys(r).forEach((n) => {
|
|
127
|
-
const e = r[n];
|
|
128
|
-
if (e && typeof e == "object") {
|
|
129
|
-
o += g(e, `${t}-${n}`);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
o += `${t}-${n}: ${e};
|
|
133
|
-
`;
|
|
134
|
-
}), o;
|
|
135
|
-
}
|
|
136
|
-
function L(r, t) {
|
|
137
|
-
let o = "";
|
|
138
|
-
return r && (o += g(r, t)), o;
|
|
139
|
-
}
|
|
140
|
-
function V(r) {
|
|
141
|
-
var u, $, p, f, b, d;
|
|
142
|
-
if (!r)
|
|
143
|
-
return;
|
|
144
|
-
const t = (u = r.colors) != null && u.raw ? C(
|
|
145
|
-
r.colors.raw,
|
|
146
|
-
"sa-ui-raw-color"
|
|
147
|
-
) : "", o = ($ = r.colors) != null && $.computed ? C(
|
|
148
|
-
r.colors.computed,
|
|
149
|
-
"sa-ui-color"
|
|
150
|
-
) : "", n = (p = r.colors) != null && p.main ? M(r.colors.main, "sa-ui") : "", e = (f = r.colors) != null && f.brand ? S(r.colors.brand, "sa-ui-brand") : "", s = (b = r.colors) != null && b.utility ? S(
|
|
151
|
-
r.colors.utility,
|
|
152
|
-
"sa-ui-utility"
|
|
153
|
-
) : "", i = (d = r.colors) != null && d.text ? H(
|
|
154
|
-
r.colors.text,
|
|
155
|
-
"sa-ui-color-text"
|
|
156
|
-
) : "", c = r.metrics ? B(r.metrics, "sa-ui") : "", l = r.font ? D(r.font, "sa-ui") : "", a = r.components ? L(r.components, "--sa-ui") : "";
|
|
157
|
-
return `
|
|
158
|
-
:root {
|
|
159
|
-
${t}
|
|
160
|
-
${o}
|
|
161
|
-
${n}
|
|
162
|
-
${e}
|
|
163
|
-
${s}
|
|
164
|
-
${i}
|
|
165
|
-
${c}
|
|
166
|
-
${l}
|
|
167
|
-
${a}
|
|
168
|
-
}
|
|
169
|
-
`;
|
|
170
|
-
}
|
|
171
|
-
const j = O({
|
|
7
|
+
const e = document.createElement("style");
|
|
8
|
+
return e.id = r, document.head.appendChild(e), e;
|
|
9
|
+
}, u = E({
|
|
172
10
|
theme: void 0,
|
|
173
11
|
setTheme: () => {
|
|
174
12
|
}
|
|
175
|
-
}),
|
|
176
|
-
function
|
|
177
|
-
const t = r.split(",").map((
|
|
178
|
-
return t.length !== 3 || t.some((
|
|
13
|
+
}), C = "sa-theme-style";
|
|
14
|
+
function O(r) {
|
|
15
|
+
const t = r.split(",").map((e) => Number(e.trim()));
|
|
16
|
+
return t.length !== 3 || t.some((e) => !Number.isFinite(e) || e < 0 || e > 255) ? null : "#" + t.map((e) => Math.round(e).toString(16).padStart(2, "0")).join("");
|
|
179
17
|
}
|
|
180
|
-
function
|
|
18
|
+
function N(r) {
|
|
181
19
|
if (!r)
|
|
182
20
|
return "";
|
|
183
|
-
const t = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]),
|
|
184
|
-
const s =
|
|
21
|
+
const t = /* @__PURE__ */ new Set(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), e = Object.entries(r).filter(([n]) => t.has(n)).map(([n, o]) => {
|
|
22
|
+
const s = O(o);
|
|
185
23
|
return s ? ` --sa-color-brand-${n}: ${s};` : "";
|
|
186
24
|
}).filter(Boolean).join(`
|
|
187
25
|
`);
|
|
188
|
-
return
|
|
189
|
-
${
|
|
26
|
+
return e ? `:root {
|
|
27
|
+
${e}
|
|
190
28
|
}` : "";
|
|
191
29
|
}
|
|
192
|
-
function
|
|
193
|
-
const [
|
|
194
|
-
() =>
|
|
195
|
-
[
|
|
196
|
-
), s =
|
|
197
|
-
|
|
198
|
-
var c,
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
p && (s != null && s.current) && (s.current.textContent = p);
|
|
30
|
+
function B({ value: r, children: t }) {
|
|
31
|
+
const [e, n] = g(r), o = a(
|
|
32
|
+
() => e ? JSON.stringify(e) : "",
|
|
33
|
+
[e]
|
|
34
|
+
), s = f(w(C));
|
|
35
|
+
v(() => {
|
|
36
|
+
var c, i;
|
|
37
|
+
if (o) {
|
|
38
|
+
const m = JSON.parse(o), l = N((i = (c = m == null ? void 0 : m.colors) == null ? void 0 : c.raw) == null ? void 0 : i.blue);
|
|
39
|
+
l && (s != null && s.current) && (s.current.textContent = l);
|
|
203
40
|
}
|
|
204
|
-
}, [
|
|
205
|
-
const
|
|
41
|
+
}, [o]);
|
|
42
|
+
const d = (c) => {
|
|
206
43
|
c && n(c);
|
|
207
44
|
};
|
|
208
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ S(u.Provider, { value: { theme: e, setTheme: d }, children: t });
|
|
209
46
|
}
|
|
210
|
-
const
|
|
47
|
+
const D = {
|
|
211
48
|
raw: {
|
|
212
49
|
white: {
|
|
213
50
|
900: "255, 255, 255"
|
|
@@ -306,7 +143,7 @@ const I = {
|
|
|
306
143
|
tertiary: "230, 237, 246"
|
|
307
144
|
}
|
|
308
145
|
}
|
|
309
|
-
},
|
|
146
|
+
}, H = {
|
|
310
147
|
radii: {
|
|
311
148
|
none: "0",
|
|
312
149
|
xs: "0.25rem",
|
|
@@ -364,7 +201,7 @@ const I = {
|
|
|
364
201
|
inner: "inset 0 2px 4px 0 #0000000d",
|
|
365
202
|
card: "0px 4px 35px 0px #7090b040"
|
|
366
203
|
}
|
|
367
|
-
},
|
|
204
|
+
}, J = {
|
|
368
205
|
fontSizes: {
|
|
369
206
|
xs: "0.625rem",
|
|
370
207
|
sm: "0.75rem",
|
|
@@ -404,64 +241,64 @@ const I = {
|
|
|
404
241
|
relaxed: 1.625,
|
|
405
242
|
loose: 2
|
|
406
243
|
}
|
|
407
|
-
},
|
|
408
|
-
colors:
|
|
409
|
-
metrics:
|
|
410
|
-
font:
|
|
411
|
-
},
|
|
412
|
-
const
|
|
244
|
+
}, M = {
|
|
245
|
+
colors: D,
|
|
246
|
+
metrics: H,
|
|
247
|
+
font: J
|
|
248
|
+
}, p = M, b = (r, t) => {
|
|
249
|
+
const e = {};
|
|
413
250
|
return Object.keys(r).forEach((n) => {
|
|
414
251
|
if (r != null && r[n] && typeof (r == null ? void 0 : r[n]) == "object") {
|
|
415
|
-
|
|
252
|
+
e[n] = {
|
|
416
253
|
...r == null ? void 0 : r[n],
|
|
417
254
|
...t == null ? void 0 : t[n],
|
|
418
|
-
...
|
|
255
|
+
...b(r == null ? void 0 : r[n], t == null ? void 0 : t[n])
|
|
419
256
|
};
|
|
420
257
|
return;
|
|
421
258
|
}
|
|
422
|
-
|
|
423
|
-
}),
|
|
259
|
+
e[n] = (t == null ? void 0 : t[n]) || (r == null ? void 0 : r[n]);
|
|
260
|
+
}), e;
|
|
424
261
|
};
|
|
425
262
|
function x() {
|
|
426
|
-
const r =
|
|
263
|
+
const r = j(u), t = a(
|
|
427
264
|
() => ({
|
|
428
|
-
...
|
|
265
|
+
...p,
|
|
429
266
|
...r.theme,
|
|
430
|
-
...
|
|
267
|
+
...b(p, r.theme)
|
|
431
268
|
}),
|
|
432
|
-
[r.theme,
|
|
269
|
+
[r.theme, p]
|
|
433
270
|
);
|
|
434
271
|
return { ...r, theme: t };
|
|
435
272
|
}
|
|
436
|
-
function
|
|
273
|
+
function F() {
|
|
437
274
|
const { theme: r } = x();
|
|
438
275
|
return r.colors;
|
|
439
276
|
}
|
|
440
|
-
function
|
|
277
|
+
function L() {
|
|
441
278
|
var t;
|
|
442
279
|
const { theme: r } = x();
|
|
443
280
|
return (t = r.metrics) == null ? void 0 : t.spacing;
|
|
444
281
|
}
|
|
445
|
-
function
|
|
282
|
+
function P() {
|
|
446
283
|
var t;
|
|
447
284
|
const { theme: r } = x();
|
|
448
285
|
return (t = r.metrics) == null ? void 0 : t.radii;
|
|
449
286
|
}
|
|
450
|
-
function
|
|
287
|
+
function _() {
|
|
451
288
|
var t;
|
|
452
289
|
const { theme: r } = x();
|
|
453
290
|
return (t = r == null ? void 0 : r.metrics) == null ? void 0 : t.shadows;
|
|
454
291
|
}
|
|
455
|
-
function
|
|
292
|
+
function y(r) {
|
|
456
293
|
return r;
|
|
457
294
|
}
|
|
458
295
|
export {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
296
|
+
u as ThemeContext,
|
|
297
|
+
B as ThemeProvider,
|
|
298
|
+
y as createTheme,
|
|
299
|
+
F as useColor,
|
|
300
|
+
P as useRadius,
|
|
301
|
+
_ as useShadow,
|
|
302
|
+
L as useSpacing,
|
|
466
303
|
x as useTheme
|
|
467
304
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`}else{const u=`${i}${n}-${c}`;o+=`--${u}: ${s};
|
|
6
|
-
`}}for(const n in r){const s=r[n];for(const i in s){const c=s[i];if(typeof c=="object")for(const a in c){const u=c[a],$=`${t}-`;e(i,u,$,n,a)}else{const a=`${t}-`;e(i,c,a,n)}}}return o}function P(r,t=""){let o="";function e(n,s,i=""){if(typeof s=="object")for(const c in s){const a=s[c],u=`--${i}-${n}-${c}`;o+=`${u}: ${a};
|
|
7
|
-
`}else{const c=`--${i}-${n}`;o+=`${c}: ${s};
|
|
8
|
-
`}}for(const n in r){const s=r[n];if(typeof s=="object")e(n,s,`${t}`);else{const i=`--${t}-${n}`;o+=`${i}: ${s};
|
|
9
|
-
`}}return o}function F(r,t=""){let o="";for(const e in r){const n=r[e];for(const s in n){const i=`--${t}-${e}-${s}`,c=n[s];o+=`${i}: ${c};
|
|
10
|
-
`}}return o}function N(r,t){let o="";for(const e in r)if(Object.hasOwnProperty.call(r,e)){const n=r[e];e==="default"?o+=`--${t}: ${n};
|
|
11
|
-
`:o+=`--${t}-${e}: ${n};
|
|
12
|
-
`}return o}const M=r=>{const t=document.getElementById(r);if(t)return t;const o=document.createElement("style");return o.id=r,document.head.appendChild(o),o};function j(r,t){let o="";return Object.keys(r).forEach(e=>{const n=r[e];if(n&&typeof n=="object"){o+=j(n,`${t}-${e}`);return}o+=`${t}-${e}: ${n};
|
|
13
|
-
`}),o}function B(r,t){let o="";return r&&(o+=j(r,t)),o}function D(r){var $,b,x,v,w,O;if(!r)return;const t=($=r.colors)!=null&&$.raw?y(r.colors.raw,"sa-ui-raw-color"):"",o=(b=r.colors)!=null&&b.computed?y(r.colors.computed,"sa-ui-color"):"",e=(x=r.colors)!=null&&x.main?E(r.colors.main,"sa-ui"):"",n=(v=r.colors)!=null&&v.brand?C(r.colors.brand,"sa-ui-brand"):"",s=(w=r.colors)!=null&&w.utility?C(r.colors.utility,"sa-ui-utility"):"",i=(O=r.colors)!=null&&O.text?N(r.colors.text,"sa-ui-color-text"):"",c=r.metrics?P(r.metrics,"sa-ui"):"",a=r.font?F(r.font,"sa-ui"):"",u=r.components?B(r.components,"--sa-ui"):"";return`
|
|
14
|
-
:root {
|
|
15
|
-
${t}
|
|
16
|
-
${o}
|
|
17
|
-
${e}
|
|
18
|
-
${n}
|
|
19
|
-
${s}
|
|
20
|
-
${i}
|
|
21
|
-
${c}
|
|
22
|
-
${a}
|
|
23
|
-
${u}
|
|
24
|
-
}
|
|
25
|
-
`}const d=m.createContext({theme:void 0,setTheme:()=>{}}),H="sa-theme-style";function R(r){const t=r.split(",").map(o=>Number(o.trim()));return t.length!==3||t.some(o=>!Number.isFinite(o)||o<0||o>255)?null:"#"+t.map(o=>Math.round(o).toString(16).padStart(2,"0")).join("")}function J(r){if(!r)return"";const t=new Set(["50","100","200","300","400","500","600","700","800","900"]),o=Object.entries(r).filter(([e])=>t.has(e)).map(([e,n])=>{const s=R(n);return s?` --sa-color-brand-${e}: ${s};`:""}).filter(Boolean).join(`
|
|
26
|
-
`);return o?`:root {
|
|
27
|
-
${o}
|
|
28
|
-
}`:""}function L({value:r,children:t}){const[o,e]=m.useState(r),n=m.useMemo(()=>o?JSON.stringify(o):"",[o]),s=m.useRef(M(H));m.useEffect(()=>{var c,a;if(n){const u=JSON.parse(n),$=D(u)??"",b=J((a=(c=u==null?void 0:u.colors)==null?void 0:c.raw)==null?void 0:a.blue),x=[$,b].filter(Boolean).join(`
|
|
29
|
-
`);x&&(s!=null&&s.current)&&(s.current.textContent=x)}},[n]);const i=c=>{c&&e(c)};return p.jsx(d.Provider,{value:{theme:o,setTheme:i},children:t})}const S={colors:{raw:{white:{900:"255, 255, 255"},black:{900:"0, 0, 0"},blue:{50:"230, 237, 246",100:"204, 217, 237",200:"153, 179, 219",300:"102, 140, 201",400:"51, 102, 183",500:"26, 79, 160",600:"4, 37, 79",700:"3, 31, 67",800:"2, 25, 55",900:"2, 19, 43"},pink:{50:"251, 219, 241",100:"248, 183, 228",200:"245, 147, 215",300:"241, 111, 202",400:"238, 75, 189",500:"235, 39, 176",600:"215, 19, 157",700:"179, 16, 131",800:"143, 13, 104",900:"107, 9, 78"},purple:{50:"249, 229, 252",100:"240, 196, 248",200:"230, 162, 244",300:"220, 128, 240",400:"210, 95, 236",500:"200, 61, 232",600:"180, 41, 212",700:"150, 34, 177",800:"120, 27, 142",900:"90, 21, 106"},red:{50:"251, 222, 222",100:"247, 188, 188",200:"243, 153, 153",300:"239, 119, 119",400:"235, 84, 84",500:"231, 50, 50",600:"212, 30, 30",700:"176, 25, 25",800:"141, 20, 20",900:"105, 15, 15"},orange:{50:"253, 235, 217",100:"251, 215, 179",200:"249, 195, 141",300:"247, 175, 103",400:"245, 155, 65",500:"243, 135, 27",600:"224, 116, 8",700:"187, 96, 7",800:"150, 77, 6",900:"112, 58, 4"},yellow:{50:"255, 250, 219",100:"255, 246, 184",200:"255, 241, 149",300:"255, 237, 114",400:"255, 232, 79",500:"255, 228, 44",600:"236, 209, 25",700:"197, 174, 21",800:"157, 139, 17",900:"118, 104, 12"},green:{50:"236, 255, 246",100:"151, 230, 193",200:"117, 222, 173",300:"82, 214, 152",400:"48, 206, 132",500:"40, 172, 110",600:"32, 137, 88",700:"24, 103, 66",800:"16, 68, 44",900:"16, 68, 44"},brand:{default:"4, 37, 79",active:"2, 19, 43",secondary:"153, 179, 219",tertiary:"230, 237, 246"}}},metrics:{radii:{none:"0",xs:"0.25rem",sm:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"0.875rem","2xl":"1rem",full:"12rem"},spacing:{0:"0rem",1:"0.063rem",2:"0.125rem",4:"0.25rem",6:"0.375rem",8:"0.5rem",10:"0.625rem",12:"0.75rem",14:"0.875rem",16:"1rem",18:"1.125rem",20:"1.25rem",24:"1.5rem",28:"1.75rem",32:"2rem",36:"2.25rem",40:"2.5rem",48:"3rem",64:"4rem",80:"5rem",96:"6rem",128:"8rem",160:"10rem",192:"12rem",224:"14rem",256:"16rem",xs:"0.25rem",sm:"0.5rem",md:"0.75rem",lg:"1rem",xl:"1.5rem","2xl":"2rem","3xl":"4rem"},border:{default:"1px solid var(--sa-border-subtle, #0b120e24)"},shadows:{sm:"0 1px 2px 0 #0000000d",md:"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",lg:"0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a",xl:"0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a","2xl":"0 25px 50px -12px #00000040",inner:"inset 0 2px 4px 0 #0000000d",card:"0px 4px 35px 0px #7090b040"}},font:{fontSizes:{xs:"0.625rem",sm:"0.75rem",md:"0.875rem",lg:"1rem",xl:"1.125rem","2xl":"1.25rem","3xl":"1.5rem","4xl":"2rem","5xl":"2.25rem","6xl":"3rem"},fontWeights:{hairline:100,thin:100,light:200,normal:300,medium:400,semibold:500,bold:600,extrabold:700,black:800},lineHeights:{3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"1.875rem",9:"2.25rem",10:"2.5rem",none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2}}},g=(r,t)=>{const o={};return Object.keys(r).forEach(e=>{if(r!=null&&r[e]&&typeof(r==null?void 0:r[e])=="object"){o[e]={...r==null?void 0:r[e],...t==null?void 0:t[e],...g(r==null?void 0:r[e],t==null?void 0:t[e])};return}o[e]=(t==null?void 0:t[e])||(r==null?void 0:r[e])}),o};function f(){const r=m.useContext(d),t=m.useMemo(()=>({...S,...r.theme,...g(S,r.theme)}),[r.theme,S]);return{...r,theme:t}}function _(){const{theme:r}=f();return r.colors}function q(){var t;const{theme:r}=f();return(t=r.metrics)==null?void 0:t.spacing}function A(){var t;const{theme:r}=f();return(t=r.metrics)==null?void 0:t.radii}function U(){var t;const{theme:r}=f();return(t=r==null?void 0:r.metrics)==null?void 0:t.shadows}function V(r){return r}l.ThemeContext=d,l.ThemeProvider=L,l.createTheme=V,l.useColor=_,l.useRadius=A,l.useShadow=U,l.useSpacing=q,l.useTheme=f,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s["@starasia/theme"]={},s.jsxRuntime,s.React))})(this,function(s,c,o){"use strict";const S=e=>{const r=document.getElementById(e);if(r)return r;const t=document.createElement("style");return t.id=e,document.head.appendChild(t),t},p=o.createContext({theme:void 0,setTheme:()=>{}}),E="sa-theme-style";function j(e){const r=e.split(",").map(t=>Number(t.trim()));return r.length!==3||r.some(t=>!Number.isFinite(t)||t<0||t>255)?null:"#"+r.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}function h(e){if(!e)return"";const r=new Set(["50","100","200","300","400","500","600","700","800","900"]),t=Object.entries(e).filter(([n])=>r.has(n)).map(([n,x])=>{const i=j(x);return i?` --sa-color-brand-${n}: ${i};`:""}).filter(Boolean).join(`
|
|
2
|
+
`);return t?`:root {
|
|
3
|
+
${t}
|
|
4
|
+
}`:""}function g({value:e,children:r}){const[t,n]=o.useState(e),x=o.useMemo(()=>t?JSON.stringify(t):"",[t]),i=o.useRef(S(E));o.useEffect(()=>{var u,b;if(x){const a=JSON.parse(x),f=h((b=(u=a==null?void 0:a.colors)==null?void 0:u.raw)==null?void 0:b.blue);f&&(i!=null&&i.current)&&(i.current.textContent=f)}},[x]);const y=u=>{u&&n(u)};return c.jsx(p.Provider,{value:{theme:t,setTheme:y},children:r})}const l={colors:{raw:{white:{900:"255, 255, 255"},black:{900:"0, 0, 0"},blue:{50:"230, 237, 246",100:"204, 217, 237",200:"153, 179, 219",300:"102, 140, 201",400:"51, 102, 183",500:"26, 79, 160",600:"4, 37, 79",700:"3, 31, 67",800:"2, 25, 55",900:"2, 19, 43"},pink:{50:"251, 219, 241",100:"248, 183, 228",200:"245, 147, 215",300:"241, 111, 202",400:"238, 75, 189",500:"235, 39, 176",600:"215, 19, 157",700:"179, 16, 131",800:"143, 13, 104",900:"107, 9, 78"},purple:{50:"249, 229, 252",100:"240, 196, 248",200:"230, 162, 244",300:"220, 128, 240",400:"210, 95, 236",500:"200, 61, 232",600:"180, 41, 212",700:"150, 34, 177",800:"120, 27, 142",900:"90, 21, 106"},red:{50:"251, 222, 222",100:"247, 188, 188",200:"243, 153, 153",300:"239, 119, 119",400:"235, 84, 84",500:"231, 50, 50",600:"212, 30, 30",700:"176, 25, 25",800:"141, 20, 20",900:"105, 15, 15"},orange:{50:"253, 235, 217",100:"251, 215, 179",200:"249, 195, 141",300:"247, 175, 103",400:"245, 155, 65",500:"243, 135, 27",600:"224, 116, 8",700:"187, 96, 7",800:"150, 77, 6",900:"112, 58, 4"},yellow:{50:"255, 250, 219",100:"255, 246, 184",200:"255, 241, 149",300:"255, 237, 114",400:"255, 232, 79",500:"255, 228, 44",600:"236, 209, 25",700:"197, 174, 21",800:"157, 139, 17",900:"118, 104, 12"},green:{50:"236, 255, 246",100:"151, 230, 193",200:"117, 222, 173",300:"82, 214, 152",400:"48, 206, 132",500:"40, 172, 110",600:"32, 137, 88",700:"24, 103, 66",800:"16, 68, 44",900:"16, 68, 44"},brand:{default:"4, 37, 79",active:"2, 19, 43",secondary:"153, 179, 219",tertiary:"230, 237, 246"}}},metrics:{radii:{none:"0",xs:"0.25rem",sm:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"0.875rem","2xl":"1rem",full:"12rem"},spacing:{0:"0rem",1:"0.063rem",2:"0.125rem",4:"0.25rem",6:"0.375rem",8:"0.5rem",10:"0.625rem",12:"0.75rem",14:"0.875rem",16:"1rem",18:"1.125rem",20:"1.25rem",24:"1.5rem",28:"1.75rem",32:"2rem",36:"2.25rem",40:"2.5rem",48:"3rem",64:"4rem",80:"5rem",96:"6rem",128:"8rem",160:"10rem",192:"12rem",224:"14rem",256:"16rem",xs:"0.25rem",sm:"0.5rem",md:"0.75rem",lg:"1rem",xl:"1.5rem","2xl":"2rem","3xl":"4rem"},border:{default:"1px solid var(--sa-border-subtle, #0b120e24)"},shadows:{sm:"0 1px 2px 0 #0000000d",md:"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",lg:"0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a",xl:"0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a","2xl":"0 25px 50px -12px #00000040",inner:"inset 0 2px 4px 0 #0000000d",card:"0px 4px 35px 0px #7090b040"}},font:{fontSizes:{xs:"0.625rem",sm:"0.75rem",md:"0.875rem",lg:"1rem",xl:"1.125rem","2xl":"1.25rem","3xl":"1.5rem","4xl":"2rem","5xl":"2.25rem","6xl":"3rem"},fontWeights:{hairline:100,thin:100,light:200,normal:300,medium:400,semibold:500,bold:600,extrabold:700,black:800},lineHeights:{3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"1.875rem",9:"2.25rem",10:"2.5rem",none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2}}},d=(e,r)=>{const t={};return Object.keys(e).forEach(n=>{if(e!=null&&e[n]&&typeof(e==null?void 0:e[n])=="object"){t[n]={...e==null?void 0:e[n],...r==null?void 0:r[n],...d(e==null?void 0:e[n],r==null?void 0:r[n])};return}t[n]=(r==null?void 0:r[n])||(e==null?void 0:e[n])}),t};function m(){const e=o.useContext(p),r=o.useMemo(()=>({...l,...e.theme,...d(l,e.theme)}),[e.theme,l]);return{...e,theme:r}}function v(){const{theme:e}=m();return e.colors}function C(){var r;const{theme:e}=m();return(r=e.metrics)==null?void 0:r.spacing}function w(){var r;const{theme:e}=m();return(r=e.metrics)==null?void 0:r.radii}function O(){var r;const{theme:e}=m();return(r=e==null?void 0:e.metrics)==null?void 0:r.shadows}function M(e){return e}s.ThemeContext=p,s.ThemeProvider=g,s.createTheme=M,s.useColor=v,s.useRadius=w,s.useShadow=O,s.useSpacing=C,s.useTheme=m,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/dist/helpers/font.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Font } from '../types/theme';
|
|
2
|
-
|
|
3
|
-
export declare function generateFontCSSFromTheme(theme: Font, prefix?: string): string;
|
|
4
|
-
interface Theme {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function generateTextCSSFromTheme(theme: Theme, prefix: string): string;
|
|
8
|
-
export {};
|
package/dist/helpers/metric.d.ts
DELETED