winduum 2.0.0-next.34 → 2.0.0-next.35
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/package.json +1 -1
- package/plugin/index.cjs +79 -110
- package/plugin/index.d.ts +9 -9
- package/plugin/index.js +42 -91
- package/plugin/utilities/common.js +45 -5
- package/src/theme/config/font.css +13 -0
- package/src/theme/config/transition.css +1 -1
- package/tailwindcss/index.css +4 -0
package/package.json
CHANGED
package/plugin/index.cjs
CHANGED
|
@@ -6,20 +6,11 @@ var plugin = require('tailwindcss/plugin');
|
|
|
6
6
|
var flattenColorPalette = require('tailwindcss/src/util/flattenColorPalette');
|
|
7
7
|
var withAlphaVariable = require('tailwindcss/src/util/withAlphaVariable');
|
|
8
8
|
var toColorValue = require('tailwindcss/src/util/toColorValue');
|
|
9
|
+
var node_fs = require('node:fs');
|
|
10
|
+
var node_url = require('node:url');
|
|
11
|
+
var node_path = require('node:path');
|
|
9
12
|
|
|
10
|
-
var
|
|
11
|
-
'.dot': {
|
|
12
|
-
display: 'inline-flex',
|
|
13
|
-
inlineSize: '0.5rem',
|
|
14
|
-
blockSize: '0.5rem',
|
|
15
|
-
borderRadius: 'var(--radius-full)',
|
|
16
|
-
backgroundColor: 'currentColor',
|
|
17
|
-
flexShrink: '0',
|
|
18
|
-
justifyContent: 'center',
|
|
19
|
-
alignItems: 'center'
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
13
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
23
14
|
function divideGap ({ theme, e }) {
|
|
24
15
|
return [
|
|
25
16
|
...Object.entries(theme('spacing')).map(([key, value]) => {
|
|
@@ -119,7 +110,7 @@ const tailwindColors = (colors = [], colorMix = true, rgb = false) => {
|
|
|
119
110
|
current: 'color-mix(in var(--default-color-space), currentcolor calc(<alpha-value> * 100%), var(--default-color-mix, transparent))'
|
|
120
111
|
};
|
|
121
112
|
|
|
122
|
-
colors.forEach(name => {
|
|
113
|
+
colors.forEach((name) => {
|
|
123
114
|
if (rgb) {
|
|
124
115
|
result[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`;
|
|
125
116
|
}
|
|
@@ -139,13 +130,49 @@ const tailwindColors = (colors = [], colorMix = true, rgb = false) => {
|
|
|
139
130
|
* @returns {Object}
|
|
140
131
|
*/
|
|
141
132
|
const tailwindVariables = (type, variables = [], values = {}) => {
|
|
142
|
-
|
|
143
|
-
values
|
|
133
|
+
if (!Array.isArray(variables)) {
|
|
134
|
+
return values
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
variables.forEach((name) => {
|
|
138
|
+
values[name] = `var(--${type}-${name.replace(/\./g, '_')})`;
|
|
144
139
|
});
|
|
145
140
|
|
|
146
141
|
return values
|
|
147
142
|
};
|
|
148
143
|
|
|
144
|
+
const tailwindParseVariables = (type, file, customValues = {}, customPath, initialValues = true) => {
|
|
145
|
+
const parseFile = (fileContent) => {
|
|
146
|
+
const regex = /(--[\w-]+):\s*([^;]+);/g;
|
|
147
|
+
const matches = [...fileContent.matchAll(regex)];
|
|
148
|
+
const variables = matches.map(match => [match[1], match[2]]);
|
|
149
|
+
const values = {};
|
|
150
|
+
|
|
151
|
+
variables.forEach((match, index) => {
|
|
152
|
+
if (!match[0].startsWith(`--${type}-`) || match[0].endsWith('--line-height')) {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const name = match[0].replace(`--${type}-`, '');
|
|
157
|
+
|
|
158
|
+
values[name.replace(/_/g, '.')] = type === 'font-size' ? [`var(${match})`, `var(${variables[index + 1]})`] : `var(${initialValues ? match : match[0]})`;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return values
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const filename = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
165
|
+
const fileContent = node_fs.readFileSync(node_path.resolve(node_path.dirname(filename), file)).toString();
|
|
166
|
+
const values = parseFile(fileContent);
|
|
167
|
+
|
|
168
|
+
if (customPath) {
|
|
169
|
+
const customFileContent = node_fs.readFileSync(node_path.resolve(process.cwd(), customPath)).toString();
|
|
170
|
+
customValues = { ...customValues, ...parseFile(customFileContent) };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return { ...values, ...customValues }
|
|
174
|
+
};
|
|
175
|
+
|
|
149
176
|
/**
|
|
150
177
|
* @param {string} type
|
|
151
178
|
* @param {string[]} variables
|
|
@@ -168,7 +195,7 @@ const tailwindVariablesFont = (type, variables = [], values = {}) => {
|
|
|
168
195
|
const tailwindPropertyUtilities = (type, variables = []) => {
|
|
169
196
|
const result = {};
|
|
170
197
|
|
|
171
|
-
variables.forEach(name => {
|
|
198
|
+
variables.forEach((name) => {
|
|
172
199
|
result[`.${type}-${name}`] = {
|
|
173
200
|
[type]: `var(--${type}-${name})`
|
|
174
201
|
};
|
|
@@ -184,7 +211,7 @@ const tailwindPropertyUtilities = (type, variables = []) => {
|
|
|
184
211
|
const tailwindAnimations = (values) => {
|
|
185
212
|
const result = {};
|
|
186
213
|
|
|
187
|
-
values.forEach(value => {
|
|
214
|
+
values.forEach((value) => {
|
|
188
215
|
result[`.animation-${value}`] = {
|
|
189
216
|
'animation-name': value
|
|
190
217
|
};
|
|
@@ -197,88 +224,17 @@ const tailwindAnimations = (values) => {
|
|
|
197
224
|
* @type {import('./').PluginOptions} options.
|
|
198
225
|
*/
|
|
199
226
|
const defaultConfig = {
|
|
200
|
-
|
|
201
|
-
'primary', 'accent',
|
|
202
|
-
'warning', 'error', 'info', 'success', 'light', 'dark',
|
|
203
|
-
'main', 'main-primary', 'main-secondary', 'main-tertiary',
|
|
204
|
-
'body', 'body-primary', 'body-secondary', 'body-tertiary',
|
|
205
|
-
'primary-foreground', 'accent-foreground',
|
|
206
|
-
'warning-foreground', 'error-foreground', 'info-foreground', 'success-foreground', 'light-foreground', 'dark-foreground',
|
|
207
|
-
'main-foreground', 'main-primary-foreground', 'main-secondary-foreground', 'main-tertiary-foreground',
|
|
208
|
-
'body-foreground', 'body-primary-foreground', 'body-secondary-foreground', 'body-tertiary-foreground'
|
|
209
|
-
],
|
|
210
|
-
fontFamily: ['primary', 'secondary'],
|
|
211
|
-
fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
|
|
212
|
-
ease: ['linear', 'in', 'out', 'in-out'],
|
|
213
|
-
zIndex: ['10', '20', '30', '40', '50', '60'],
|
|
214
|
-
fontSize: [
|
|
215
|
-
{
|
|
216
|
-
value: 'xs',
|
|
217
|
-
initial: '0.75rem'
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
value: 'sm',
|
|
221
|
-
initial: '0.875rem'
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
value: 'base',
|
|
225
|
-
initial: '1rem'
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
value: 'lg',
|
|
229
|
-
initial: '1.125rem'
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
value: 'xl',
|
|
233
|
-
initial: '1.25rem'
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
value: '2xl',
|
|
237
|
-
initial: '1.5rem'
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
value: '3xl',
|
|
241
|
-
initial: '1.875rem'
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
value: '4xl',
|
|
245
|
-
initial: '2.25rem'
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
value: '5xl',
|
|
249
|
-
initial: '3rem'
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
value: '6xl',
|
|
253
|
-
initial: '3.75rem'
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
value: '7xl',
|
|
257
|
-
initial: '4.5rem'
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
value: '8xl',
|
|
261
|
-
initial: '6rem'
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
value: '9xl',
|
|
265
|
-
initial: '8rem'
|
|
266
|
-
}
|
|
267
|
-
],
|
|
268
|
-
spacing: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'],
|
|
269
|
-
borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
|
|
270
|
-
animations: ['ripple', 'spin', 'move-indeterminate'],
|
|
271
|
-
mask: ['check', 'radio', 'angle-up', 'angle-down'],
|
|
227
|
+
animations: ['ripple', 'spin', 'move-indeterminate', 'fade-in', 'fade-out'],
|
|
272
228
|
screens: {
|
|
273
|
-
xs: '22.5rem',
|
|
274
|
-
sm: '26rem',
|
|
275
|
-
md: '46.5rem',
|
|
276
|
-
lg: '60rem',
|
|
277
|
-
xl: '76rem',
|
|
229
|
+
'xs': '22.5rem',
|
|
230
|
+
'sm': '26rem',
|
|
231
|
+
'md': '46.5rem',
|
|
232
|
+
'lg': '60rem',
|
|
233
|
+
'xl': '76rem',
|
|
278
234
|
'2xl': '82rem',
|
|
279
235
|
'3xl': '88rem',
|
|
280
236
|
'4xl': '100rem',
|
|
281
|
-
xxl: '126rem',
|
|
237
|
+
'xxl': '126rem',
|
|
282
238
|
'2xxl': '158rem'
|
|
283
239
|
},
|
|
284
240
|
settings: {
|
|
@@ -316,11 +272,10 @@ const createPlugin = (userConfig = {}) => {
|
|
|
316
272
|
{ values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
|
|
317
273
|
);
|
|
318
274
|
addComponents(tailwindAnimations(userConfig.animations));
|
|
319
|
-
addComponents(tailwindPropertyUtilities('mask',
|
|
275
|
+
addComponents(tailwindPropertyUtilities('mask', Object.keys(tailwindParseVariables('mask', '../../src/theme/config/mask.css', {
|
|
276
|
+
...tailwindVariables('mask', userConfig.mask ?? [])
|
|
277
|
+
}, userConfig.mask, false))));
|
|
320
278
|
addComponents(divideGap({ theme, e }));
|
|
321
|
-
addComponents({
|
|
322
|
-
...DotUtility
|
|
323
|
-
});
|
|
324
279
|
}, {
|
|
325
280
|
corePlugins: {
|
|
326
281
|
preflight: false,
|
|
@@ -335,19 +290,33 @@ const createPlugin = (userConfig = {}) => {
|
|
|
335
290
|
transitionDuration: {
|
|
336
291
|
DEFAULT: 'var(--default-transition-duration)'
|
|
337
292
|
},
|
|
338
|
-
transitionTimingFunction:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
293
|
+
transitionTimingFunction: tailwindParseVariables('transition-timing-function', '../../src/theme/config/transition.css', {
|
|
294
|
+
...tailwindVariables('transition-timing-function', userConfig.ease ?? [])
|
|
295
|
+
}, userConfig.ease),
|
|
296
|
+
colors: tailwindColors(Object.keys(tailwindParseVariables('color', '../../src/theme/default.css', {
|
|
297
|
+
...tailwindVariables('color', userConfig.colors ?? [])
|
|
298
|
+
}, userConfig.colors)), settings.colorMix, settings.rgb),
|
|
299
|
+
fontSize: tailwindParseVariables('font-size', '../../src/theme/config/font.css', {
|
|
300
|
+
...tailwindVariables('font-weight', userConfig.fontSize ?? [])
|
|
301
|
+
}, userConfig.fontSize),
|
|
302
|
+
fontFamily: tailwindParseVariables('font-family', '../../src/theme/config/font.css', {
|
|
303
|
+
...tailwindVariables('font-weight', userConfig.fontFamily ?? [])
|
|
304
|
+
}, userConfig.fontFamily),
|
|
305
|
+
fontWeight: tailwindParseVariables('font-weight', '../../src/theme/config/font.css', {
|
|
306
|
+
...tailwindVariables('font-weight', userConfig.fontWeight ?? [])
|
|
307
|
+
}, userConfig.fontWeight),
|
|
308
|
+
zIndex: tailwindParseVariables('z-index', '../../src/theme/config/z.css', {
|
|
309
|
+
...tailwindVariables('z-index', userConfig.zIndex ?? []),
|
|
344
310
|
0: 0,
|
|
345
311
|
auto: 'auto'
|
|
346
|
-
}),
|
|
347
|
-
spacing:
|
|
348
|
-
|
|
312
|
+
}, userConfig.zIndex),
|
|
313
|
+
spacing: tailwindParseVariables('spacing', '../../src/theme/config/spacing.css', {
|
|
314
|
+
...tailwindVariables('spacing', userConfig.spacing ?? [])
|
|
315
|
+
}, userConfig.spacing),
|
|
316
|
+
borderRadius: tailwindParseVariables('radius', '../../src/theme/config/radius.css', {
|
|
317
|
+
...tailwindVariables('radius', userConfig.borderRadius ?? []),
|
|
349
318
|
DEFAULT: 'var(--radius)'
|
|
350
|
-
}),
|
|
319
|
+
}, userConfig.borderRadius),
|
|
351
320
|
screens: userConfig.screens
|
|
352
321
|
}
|
|
353
322
|
}
|
package/plugin/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "tailwindcss/types/config";
|
|
2
2
|
|
|
3
3
|
export interface PluginOptions {
|
|
4
|
-
colors?: string[]
|
|
5
|
-
fontFamily?: string[],
|
|
6
|
-
fontWeight?: string[],
|
|
7
|
-
ease?: string[],
|
|
8
|
-
zIndex?: string[],
|
|
9
|
-
fontSize?: string[],
|
|
10
|
-
spacing?: string[],
|
|
11
|
-
borderRadius?: string[],
|
|
4
|
+
colors?: string[] | string
|
|
5
|
+
fontFamily?: string[] | string,
|
|
6
|
+
fontWeight?: string[] | string,
|
|
7
|
+
ease?: string[] | string,
|
|
8
|
+
zIndex?: string[] | string,
|
|
9
|
+
fontSize?: string[] | string,
|
|
10
|
+
spacing?: string[] | string,
|
|
11
|
+
borderRadius?: string[] | string,
|
|
12
|
+
mask?: string[] | string,
|
|
12
13
|
animations?: string[],
|
|
13
|
-
mask?: string[],
|
|
14
14
|
screens?: {
|
|
15
15
|
[key: string]: string
|
|
16
16
|
},
|
package/plugin/index.js
CHANGED
|
@@ -1,96 +1,31 @@
|
|
|
1
1
|
import plugin from 'tailwindcss/plugin'
|
|
2
2
|
import flattenColorPalette from 'tailwindcss/src/util/flattenColorPalette'
|
|
3
|
-
import DotUtility from './utilities/dot.js'
|
|
4
3
|
import divideGap from './utilities/divide-gap.js'
|
|
5
4
|
import { accentColor, textColor } from './utilities/color.js'
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
tailwindAnimations,
|
|
7
|
+
tailwindColors,
|
|
8
|
+
tailwindParseVariables,
|
|
9
|
+
tailwindPropertyUtilities,
|
|
10
|
+
tailwindVariables,
|
|
11
|
+
tailwindVariablesFont
|
|
12
|
+
} from './utilities/common.js'
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
15
|
* @type {import('./').PluginOptions} options.
|
|
10
16
|
*/
|
|
11
17
|
export const defaultConfig = {
|
|
12
|
-
|
|
13
|
-
'primary', 'accent',
|
|
14
|
-
'warning', 'error', 'info', 'success', 'light', 'dark',
|
|
15
|
-
'main', 'main-primary', 'main-secondary', 'main-tertiary',
|
|
16
|
-
'body', 'body-primary', 'body-secondary', 'body-tertiary',
|
|
17
|
-
'primary-foreground', 'accent-foreground',
|
|
18
|
-
'warning-foreground', 'error-foreground', 'info-foreground', 'success-foreground', 'light-foreground', 'dark-foreground',
|
|
19
|
-
'main-foreground', 'main-primary-foreground', 'main-secondary-foreground', 'main-tertiary-foreground',
|
|
20
|
-
'body-foreground', 'body-primary-foreground', 'body-secondary-foreground', 'body-tertiary-foreground'
|
|
21
|
-
],
|
|
22
|
-
fontFamily: ['primary', 'secondary'],
|
|
23
|
-
fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
|
|
24
|
-
ease: ['linear', 'in', 'out', 'in-out'],
|
|
25
|
-
zIndex: ['10', '20', '30', '40', '50', '60'],
|
|
26
|
-
fontSize: [
|
|
27
|
-
{
|
|
28
|
-
value: 'xs',
|
|
29
|
-
initial: '0.75rem'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
value: 'sm',
|
|
33
|
-
initial: '0.875rem'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: 'base',
|
|
37
|
-
initial: '1rem'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
value: 'lg',
|
|
41
|
-
initial: '1.125rem'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: 'xl',
|
|
45
|
-
initial: '1.25rem'
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
value: '2xl',
|
|
49
|
-
initial: '1.5rem'
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
value: '3xl',
|
|
53
|
-
initial: '1.875rem'
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
value: '4xl',
|
|
57
|
-
initial: '2.25rem'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
value: '5xl',
|
|
61
|
-
initial: '3rem'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
value: '6xl',
|
|
65
|
-
initial: '3.75rem'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
value: '7xl',
|
|
69
|
-
initial: '4.5rem'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
value: '8xl',
|
|
73
|
-
initial: '6rem'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
value: '9xl',
|
|
77
|
-
initial: '8rem'
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
spacing: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'],
|
|
81
|
-
borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
|
|
82
|
-
animations: ['ripple', 'spin', 'move-indeterminate'],
|
|
83
|
-
mask: ['check', 'radio', 'angle-up', 'angle-down'],
|
|
18
|
+
animations: ['ripple', 'spin', 'move-indeterminate', 'fade-in', 'fade-out'],
|
|
84
19
|
screens: {
|
|
85
|
-
xs: '22.5rem',
|
|
86
|
-
sm: '26rem',
|
|
87
|
-
md: '46.5rem',
|
|
88
|
-
lg: '60rem',
|
|
89
|
-
xl: '76rem',
|
|
20
|
+
'xs': '22.5rem',
|
|
21
|
+
'sm': '26rem',
|
|
22
|
+
'md': '46.5rem',
|
|
23
|
+
'lg': '60rem',
|
|
24
|
+
'xl': '76rem',
|
|
90
25
|
'2xl': '82rem',
|
|
91
26
|
'3xl': '88rem',
|
|
92
27
|
'4xl': '100rem',
|
|
93
|
-
xxl: '126rem',
|
|
28
|
+
'xxl': '126rem',
|
|
94
29
|
'2xxl': '158rem'
|
|
95
30
|
},
|
|
96
31
|
settings: {
|
|
@@ -128,7 +63,9 @@ export const createPlugin = (userConfig = {}) => {
|
|
|
128
63
|
{ values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
|
|
129
64
|
)
|
|
130
65
|
addComponents(tailwindAnimations(userConfig.animations))
|
|
131
|
-
addComponents(tailwindPropertyUtilities('mask',
|
|
66
|
+
addComponents(tailwindPropertyUtilities('mask', Object.keys(tailwindParseVariables('mask', '../../src/theme/config/mask.css', {
|
|
67
|
+
...tailwindVariables('mask', userConfig.mask ?? [])
|
|
68
|
+
}, userConfig.mask, false))))
|
|
132
69
|
addComponents(divideGap({ theme, e }))
|
|
133
70
|
}, {
|
|
134
71
|
corePlugins: {
|
|
@@ -144,19 +81,33 @@ export const createPlugin = (userConfig = {}) => {
|
|
|
144
81
|
transitionDuration: {
|
|
145
82
|
DEFAULT: 'var(--default-transition-duration)'
|
|
146
83
|
},
|
|
147
|
-
transitionTimingFunction:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
84
|
+
transitionTimingFunction: tailwindParseVariables('transition-timing-function', '../../src/theme/config/transition.css', {
|
|
85
|
+
...tailwindVariables('transition-timing-function', userConfig.ease ?? [])
|
|
86
|
+
}, userConfig.ease),
|
|
87
|
+
colors: tailwindColors(Object.keys(tailwindParseVariables('color', '../../src/theme/default.css', {
|
|
88
|
+
...tailwindVariables('color', userConfig.colors ?? [])
|
|
89
|
+
}, userConfig.colors)), settings.colorMix, settings.rgb),
|
|
90
|
+
fontSize: tailwindParseVariables('font-size', '../../src/theme/config/font.css', {
|
|
91
|
+
...tailwindVariables('font-weight', userConfig.fontSize ?? [])
|
|
92
|
+
}, userConfig.fontSize),
|
|
93
|
+
fontFamily: tailwindParseVariables('font-family', '../../src/theme/config/font.css', {
|
|
94
|
+
...tailwindVariables('font-weight', userConfig.fontFamily ?? [])
|
|
95
|
+
}, userConfig.fontFamily),
|
|
96
|
+
fontWeight: tailwindParseVariables('font-weight', '../../src/theme/config/font.css', {
|
|
97
|
+
...tailwindVariables('font-weight', userConfig.fontWeight ?? [])
|
|
98
|
+
}, userConfig.fontWeight),
|
|
99
|
+
zIndex: tailwindParseVariables('z-index', '../../src/theme/config/z.css', {
|
|
100
|
+
...tailwindVariables('z-index', userConfig.zIndex ?? []),
|
|
153
101
|
0: 0,
|
|
154
102
|
auto: 'auto'
|
|
155
|
-
}),
|
|
156
|
-
spacing:
|
|
157
|
-
|
|
103
|
+
}, userConfig.zIndex),
|
|
104
|
+
spacing: tailwindParseVariables('spacing', '../../src/theme/config/spacing.css', {
|
|
105
|
+
...tailwindVariables('spacing', userConfig.spacing ?? [])
|
|
106
|
+
}, userConfig.spacing),
|
|
107
|
+
borderRadius: tailwindParseVariables('radius', '../../src/theme/config/radius.css', {
|
|
108
|
+
...tailwindVariables('radius', userConfig.borderRadius ?? []),
|
|
158
109
|
DEFAULT: 'var(--radius)'
|
|
159
|
-
}),
|
|
110
|
+
}, userConfig.borderRadius),
|
|
160
111
|
screens: userConfig.screens
|
|
161
112
|
}
|
|
162
113
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { resolve, dirname } from 'node:path'
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* @param {[]} colors
|
|
3
7
|
* @param {boolean} colorMix
|
|
@@ -9,7 +13,7 @@ export const tailwindColors = (colors = [], colorMix = true, rgb = false) => {
|
|
|
9
13
|
current: 'color-mix(in var(--default-color-space), currentcolor calc(<alpha-value> * 100%), var(--default-color-mix, transparent))'
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
colors.forEach(name => {
|
|
16
|
+
colors.forEach((name) => {
|
|
13
17
|
if (rgb) {
|
|
14
18
|
result[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`
|
|
15
19
|
}
|
|
@@ -29,13 +33,49 @@ export const tailwindColors = (colors = [], colorMix = true, rgb = false) => {
|
|
|
29
33
|
* @returns {Object}
|
|
30
34
|
*/
|
|
31
35
|
export const tailwindVariables = (type, variables = [], values = {}) => {
|
|
32
|
-
|
|
33
|
-
values
|
|
36
|
+
if (!Array.isArray(variables)) {
|
|
37
|
+
return values
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
variables.forEach((name) => {
|
|
41
|
+
values[name] = `var(--${type}-${name.replace(/\./g, '_')})`
|
|
34
42
|
})
|
|
35
43
|
|
|
36
44
|
return values
|
|
37
45
|
}
|
|
38
46
|
|
|
47
|
+
export const tailwindParseVariables = (type, file, customValues = {}, customPath, initialValues = true) => {
|
|
48
|
+
const parseFile = (fileContent) => {
|
|
49
|
+
const regex = /(--[\w-]+):\s*([^;]+);/g
|
|
50
|
+
const matches = [...fileContent.matchAll(regex)]
|
|
51
|
+
const variables = matches.map(match => [match[1], match[2]])
|
|
52
|
+
const values = {}
|
|
53
|
+
|
|
54
|
+
variables.forEach((match, index) => {
|
|
55
|
+
if (!match[0].startsWith(`--${type}-`) || match[0].endsWith('--line-height')) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const name = match[0].replace(`--${type}-`, '')
|
|
60
|
+
|
|
61
|
+
values[name.replace(/_/g, '.')] = type === 'font-size' ? [`var(${match})`, `var(${variables[index + 1]})`] : `var(${initialValues ? match : match[0]})`
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return values
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const filename = fileURLToPath(import.meta.url)
|
|
68
|
+
const fileContent = readFileSync(resolve(dirname(filename), file)).toString()
|
|
69
|
+
const values = parseFile(fileContent)
|
|
70
|
+
|
|
71
|
+
if (customPath) {
|
|
72
|
+
const customFileContent = readFileSync(resolve(process.cwd(), customPath)).toString()
|
|
73
|
+
customValues = { ...customValues, ...parseFile(customFileContent) }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { ...values, ...customValues }
|
|
77
|
+
}
|
|
78
|
+
|
|
39
79
|
/**
|
|
40
80
|
* @param {string} type
|
|
41
81
|
* @param {string[]} variables
|
|
@@ -58,7 +98,7 @@ export const tailwindVariablesFont = (type, variables = [], values = {}) => {
|
|
|
58
98
|
export const tailwindPropertyUtilities = (type, variables = []) => {
|
|
59
99
|
const result = {}
|
|
60
100
|
|
|
61
|
-
variables.forEach(name => {
|
|
101
|
+
variables.forEach((name) => {
|
|
62
102
|
result[`.${type}-${name}`] = {
|
|
63
103
|
[type]: `var(--${type}-${name})`
|
|
64
104
|
}
|
|
@@ -74,7 +114,7 @@ export const tailwindPropertyUtilities = (type, variables = []) => {
|
|
|
74
114
|
export const tailwindAnimations = (values) => {
|
|
75
115
|
const result = {}
|
|
76
116
|
|
|
77
|
-
values.forEach(value => {
|
|
117
|
+
values.forEach((value) => {
|
|
78
118
|
result[`.animation-${value}`] = {
|
|
79
119
|
'animation-name': value
|
|
80
120
|
}
|
|
@@ -12,16 +12,29 @@
|
|
|
12
12
|
--font-weight-extralight: 200;
|
|
13
13
|
--font-weight-thin: 100;
|
|
14
14
|
--font-size-xs: 0.75rem;
|
|
15
|
+
--font-size-xs--line-height: 1rem;
|
|
15
16
|
--font-size-sm: 0.875rem;
|
|
17
|
+
--font-size-sm--line-height: 1.25rem;
|
|
16
18
|
--font-size-base: 1rem;
|
|
19
|
+
--font-size-base--line-height: 1.5rem;
|
|
17
20
|
--font-size-lg: 1.125rem;
|
|
21
|
+
--font-size-lg--line-height: 1.75rem;
|
|
18
22
|
--font-size-xl: 1.25rem;
|
|
23
|
+
--font-size-xl--line-height: 1.75rem;
|
|
19
24
|
--font-size-2xl: 1.5rem;
|
|
25
|
+
--font-size-2xl--line-height: 2rem;
|
|
20
26
|
--font-size-3xl: 1.875rem;
|
|
27
|
+
--font-size-3xl--line-height: 2.25rem;
|
|
21
28
|
--font-size-4xl: 2.25rem;
|
|
29
|
+
--font-size-4xl--line-height: 2.5rem;
|
|
22
30
|
--font-size-5xl: 3rem;
|
|
31
|
+
--font-size-5xl--line-height: 1;
|
|
23
32
|
--font-size-6xl: 3.75rem;
|
|
33
|
+
--font-size-6xl--line-height: 1;
|
|
24
34
|
--font-size-7xl: 4.5rem;
|
|
35
|
+
--font-size-7xl--line-height: 1;
|
|
25
36
|
--font-size-8xl: 6rem;
|
|
37
|
+
--font-size-8xl--line-height: 1;
|
|
26
38
|
--font-size-9xl: 8rem;
|
|
39
|
+
--font-size-9xl--line-height: 1;
|
|
27
40
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
:root, :host {
|
|
2
2
|
--default-transition-duration: 150ms;
|
|
3
|
-
--default-transition-property: color,
|
|
3
|
+
--default-transition-property: color, ackground-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, outline-color, outline-offset, visibility, display, overlay;
|
|
4
4
|
--transition-timing-function-linear: linear;
|
|
5
5
|
--transition-timing-function-in: cubic-bezier(0.4, 0, 1, 1);
|
|
6
6
|
--transition-timing-function-out: cubic-bezier(0, 0, 0.2, 1);
|