@cronocode/react-box 1.3.8 → 1.3.9
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/baseSvg.module.css.mjs +1 -1
- package/box.mjs +14 -14
- package/box.module.css.mjs +1 -1
- package/package.json +2 -2
- package/plugins/box-theme.ts +250 -0
- package/style.css +1 -1
- package/types.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronocode/react-box",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"main": "./box.mjs",
|
|
5
5
|
"module": "./box.mjs",
|
|
6
6
|
"types": "./box.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"preview": "vite preview",
|
|
29
29
|
"build": "vite build",
|
|
30
30
|
"build:dev": "vite build --mode dev",
|
|
31
|
-
"postbuild": "cp package.json dist & cp LICENSE dist & rm ./dist/index.d.ts & rm ./dist/index.js",
|
|
31
|
+
"postbuild": "cp package.json dist & cp LICENSE dist & cp -r plugins dist & rm ./dist/index.d.ts & rm ./dist/index.js",
|
|
32
32
|
"compile": "tsc --noEmit --skipLibCheck",
|
|
33
33
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
34
34
|
},
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { PluginOption } from 'vite';
|
|
3
|
+
|
|
4
|
+
interface BoxThemeOptions {
|
|
5
|
+
cssPath: string;
|
|
6
|
+
dtsPath: string;
|
|
7
|
+
colors: Record<string, string>;
|
|
8
|
+
shadows: Record<string, string>;
|
|
9
|
+
backgrounds: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function boxTheme(options: BoxThemeOptions): PluginOption {
|
|
13
|
+
return {
|
|
14
|
+
name: 'boxTheme',
|
|
15
|
+
configResolved(_config) {
|
|
16
|
+
const colorVariables = Object.entries(options.colors)
|
|
17
|
+
.map(([colorName, colorValue]) => `--color${colorName}: ${colorValue};`)
|
|
18
|
+
.join('\n');
|
|
19
|
+
const shadowVariables = Object.entries(options.shadows)
|
|
20
|
+
.map(([shadowName, shadowValue]) => `--shadow${shadowName}: ${shadowValue};`)
|
|
21
|
+
.join('\n');
|
|
22
|
+
const bgVariables = Object.entries(options.backgrounds)
|
|
23
|
+
.map(([backgroundName, backgroundValue]) => `--background${backgroundName}: ${backgroundValue};`)
|
|
24
|
+
.join('\n');
|
|
25
|
+
|
|
26
|
+
const variables = `:root {
|
|
27
|
+
${colorVariables}
|
|
28
|
+
${shadowVariables}
|
|
29
|
+
${bgVariables}
|
|
30
|
+
}`;
|
|
31
|
+
|
|
32
|
+
const colors = Object.keys(options.colors).map((colorName) => {
|
|
33
|
+
return `
|
|
34
|
+
.color_${colorName},
|
|
35
|
+
.color_h_${colorName}:hover,
|
|
36
|
+
._h:hover>.color_h_${colorName} {
|
|
37
|
+
color: var(--color${colorName});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.color_f_${colorName}:focus-within,
|
|
41
|
+
._f:focus-within>.color_f_${colorName} {
|
|
42
|
+
color: var(--color${colorName});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.color_a_${colorName}:active {
|
|
46
|
+
color: var(--color${colorName});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.bgColor_${colorName},
|
|
50
|
+
.bgColor_h_${colorName}:hover,
|
|
51
|
+
._h:hover>.bgColor_h_${colorName} {
|
|
52
|
+
background-color: var(--color${colorName});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.bgColor_f_${colorName}:focus-within,
|
|
56
|
+
._f:focus-within>.bgColor_f_${colorName} {
|
|
57
|
+
background-color: var(--color${colorName});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.bgColor_a_${colorName}:active {
|
|
61
|
+
background-color: var(--color${colorName});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.borderColor_${colorName},
|
|
65
|
+
.borderColor_h_${colorName}:hover,
|
|
66
|
+
._h:hover>.borderColor_h_${colorName} {
|
|
67
|
+
border-color: var(--color${colorName});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.borderColor_f_${colorName}:focus-within,
|
|
71
|
+
._f:focus-within>.borderColor_f_${colorName} {
|
|
72
|
+
border-color: var(--color${colorName});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.borderColor_a_${colorName}:active {
|
|
76
|
+
border-color: var(--color${colorName});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.outlineColor_${colorName},
|
|
80
|
+
.outlineColor_h_${colorName}:hover,
|
|
81
|
+
._h:hover>.outlineColor_h_${colorName} {
|
|
82
|
+
outline-color: var(--color${colorName});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.outlineColor_f_${colorName}:focus-within,
|
|
86
|
+
._f:focus-within>.outlineColor_f_${colorName} {
|
|
87
|
+
outline-color: var(--color${colorName});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.outlineColor_a_${colorName}:active {
|
|
91
|
+
outline-color: var(--color${colorName});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.fill_${colorName},
|
|
95
|
+
.fill_h_${colorName}:hover,
|
|
96
|
+
._h:hover>.fill_h_${colorName} {
|
|
97
|
+
path,
|
|
98
|
+
circle,
|
|
99
|
+
rect,
|
|
100
|
+
line {
|
|
101
|
+
fill: var(--color${colorName});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.fill_f_${colorName}:focus-within,
|
|
106
|
+
._f:focus-within>.fill_f_${colorName} {
|
|
107
|
+
path,
|
|
108
|
+
circle,
|
|
109
|
+
rect,
|
|
110
|
+
line {
|
|
111
|
+
fill: var(--color${colorName});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.fill_a_${colorName}:active {
|
|
116
|
+
path,
|
|
117
|
+
circle,
|
|
118
|
+
rect,
|
|
119
|
+
line {
|
|
120
|
+
fill: var(--color${colorName});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.stroke_${colorName},
|
|
125
|
+
.stroke_h_${colorName}:hover,
|
|
126
|
+
._h:hover>.stroke_h_${colorName} {
|
|
127
|
+
path,
|
|
128
|
+
circle,
|
|
129
|
+
rect,
|
|
130
|
+
line {
|
|
131
|
+
stroke: var(--color${colorName});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.stroke_f_${colorName}:focus-within,
|
|
136
|
+
._f:focus-within>.stroke_f_${colorName} {
|
|
137
|
+
path,
|
|
138
|
+
circle,
|
|
139
|
+
rect,
|
|
140
|
+
line {
|
|
141
|
+
stroke: var(--color${colorName});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.stroke_a_${colorName}:active {
|
|
146
|
+
path,
|
|
147
|
+
circle,
|
|
148
|
+
rect,
|
|
149
|
+
line {
|
|
150
|
+
stroke: var(--color${colorName});
|
|
151
|
+
}
|
|
152
|
+
}`;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const shadows = Object.keys(options.shadows).map((shadowName) => {
|
|
156
|
+
return `
|
|
157
|
+
.shadow_${shadowName},
|
|
158
|
+
.shadow_h_${shadowName}:hover,
|
|
159
|
+
._h:hover>.shadow_h_${shadowName} {
|
|
160
|
+
box-shadow: var(--shadow${shadowName});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.shadow_f_${shadowName}:focus-within,
|
|
164
|
+
._f:focus-within>.shadow_f_${shadowName} {
|
|
165
|
+
box-shadow: var(--shadow${shadowName});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.shadow_a_${shadowName}:active {
|
|
169
|
+
box-shadow: var(--shadow${shadowName});
|
|
170
|
+
}`;
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const backgrounds = Object.keys(options.backgrounds).map((backgroundName) => {
|
|
174
|
+
return `
|
|
175
|
+
.bg_${backgroundName},
|
|
176
|
+
.bg_h_${backgroundName}:hover,
|
|
177
|
+
._h:hover>.bg_h_${backgroundName} {
|
|
178
|
+
background: var(--background${backgroundName});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.bg_f_${backgroundName}:focus-within,
|
|
182
|
+
._f:focus-within>.bg_f_${backgroundName} {
|
|
183
|
+
background: var(--background${backgroundName});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.bg_a_${backgroundName}:active {
|
|
187
|
+
background: var(--background${backgroundName});
|
|
188
|
+
}`;
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const colorType = Object.keys(options.colors)
|
|
192
|
+
.map((item) => `'${item}'`)
|
|
193
|
+
.join(' | ');
|
|
194
|
+
const backgroundType = Object.keys(options.backgrounds)
|
|
195
|
+
.map((item) => `'${item}'`)
|
|
196
|
+
.join(' | ');
|
|
197
|
+
const shadowType = Object.keys(options.shadows)
|
|
198
|
+
.map((item) => `'${item}'`)
|
|
199
|
+
.join(' | ');
|
|
200
|
+
const typings = `import '@cronocode/react-box';
|
|
201
|
+
|
|
202
|
+
declare module '@cronocode/react-box' {
|
|
203
|
+
type ColorType = ${colorType};
|
|
204
|
+
type BackgroundType = ${backgroundType};
|
|
205
|
+
type ShadowType = ${shadowType};
|
|
206
|
+
|
|
207
|
+
namespace Augmented {
|
|
208
|
+
interface Props {
|
|
209
|
+
color?: ColorType;
|
|
210
|
+
colorH?: ColorType;
|
|
211
|
+
colorF?: ColorType;
|
|
212
|
+
colorA?: ColorType;
|
|
213
|
+
bgColor?: ColorType;
|
|
214
|
+
bgColorH?: ColorType;
|
|
215
|
+
bgColorF?: ColorType;
|
|
216
|
+
bgColorA?: ColorType;
|
|
217
|
+
backgroundColor?: ColorType;
|
|
218
|
+
backgroundColorH?: ColorType;
|
|
219
|
+
backgroundColorF?: ColorType;
|
|
220
|
+
backgroundColorA?: ColorType;
|
|
221
|
+
borderColor?: ColorType;
|
|
222
|
+
borderColorH?: ColorType;
|
|
223
|
+
borderColorF?: ColorType;
|
|
224
|
+
borderColorA?: ColorType;
|
|
225
|
+
outlineColor?: ColorType;
|
|
226
|
+
outlineColorH?: ColorType;
|
|
227
|
+
outlineColorF?: ColorType;
|
|
228
|
+
outlineColorA?: ColorType;
|
|
229
|
+
bg?: BackgroundType;
|
|
230
|
+
bgH?: BackgroundType;
|
|
231
|
+
bgF?: BackgroundType;
|
|
232
|
+
bgA?: BackgroundType;
|
|
233
|
+
background?: BackgroundType;
|
|
234
|
+
backgroundH?: BackgroundType;
|
|
235
|
+
backgroundF?: BackgroundType;
|
|
236
|
+
backgroundA?: BackgroundType;
|
|
237
|
+
shadow?: ShadowType;
|
|
238
|
+
shadowH?: ShadowType;
|
|
239
|
+
shadowF?: ShadowType;
|
|
240
|
+
shadowA?: ShadowType;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
|
|
246
|
+
fs.writeFileSync(options.cssPath, [variables, ...colors, ...shadows, ...backgrounds].join('\n'));
|
|
247
|
+
fs.writeFileSync(options.dtsPath, typings);
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
}
|