winduum 0.6.0-next.6 → 0.6.0-next.8
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 +6 -6
- package/plugin/tailwind.cjs +317 -0
- package/plugin/tailwind.js +306 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "winduum",
|
|
3
|
-
"version": "0.6.0-next.
|
|
3
|
+
"version": "0.6.0-next.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "utils/tailwind.cjs",
|
|
6
6
|
"module": "utils/tailwind.js",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"tailwind.config.js",
|
|
42
42
|
"dist",
|
|
43
43
|
"src",
|
|
44
|
-
"
|
|
44
|
+
"plugin"
|
|
45
45
|
],
|
|
46
46
|
"exports": {
|
|
47
47
|
".": {
|
|
48
|
-
"default": "./
|
|
49
|
-
"require": "./
|
|
50
|
-
"import": "./
|
|
48
|
+
"default": "./plugin/tailwind.js",
|
|
49
|
+
"require": "./plugin/tailwind.cjs",
|
|
50
|
+
"import": "./plugin/tailwind.js"
|
|
51
51
|
},
|
|
52
52
|
"./main.css": "./dist/main.css",
|
|
53
53
|
"./main-rgb.css": "./dist/main-rgb.css",
|
|
54
54
|
"./tailwind.css": "./dist/tailwind.css",
|
|
55
55
|
"./src/*": "./src/*",
|
|
56
|
-
"./
|
|
56
|
+
"./plugin/*": "./plugin/*",
|
|
57
57
|
"./base/*": "./src/base/*",
|
|
58
58
|
"./components/*": "./src/components/*",
|
|
59
59
|
"./libraries/*": "./src/libraries/*",
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var plugin = require('tailwindcss/plugin');
|
|
6
|
+
var flattenColorPalette = require('tailwindcss/src/util/flattenColorPalette');
|
|
7
|
+
var toColorValue = require('tailwindcss/src/util/toColorValue');
|
|
8
|
+
var color = require('tailwindcss/src/util/color');
|
|
9
|
+
|
|
10
|
+
function withAlphaVariable ({ color: color$1, property, variable }) {
|
|
11
|
+
const properties = [].concat(property);
|
|
12
|
+
if (typeof color$1 === 'function') {
|
|
13
|
+
return {
|
|
14
|
+
...Object.fromEntries(
|
|
15
|
+
properties.map((p) => {
|
|
16
|
+
return [p, color$1({ opacityVariable: variable, opacityValue: `var(${variable}, 1)` })]
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const parsed = color.parseColor(color$1);
|
|
23
|
+
|
|
24
|
+
if (parsed === null) {
|
|
25
|
+
return Object.fromEntries(properties.map((p) => [p, color$1]))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (parsed.alpha !== undefined) {
|
|
29
|
+
// Has an alpha value, return color as-is
|
|
30
|
+
return Object.fromEntries(properties.map((p) => [p, color$1]))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
...Object.fromEntries(
|
|
35
|
+
properties.map((p) => {
|
|
36
|
+
return [p, color.formatColor({ ...parsed, alpha: `var(${variable}, 1)` })]
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
colors: [
|
|
44
|
+
'primary', 'accent', 'current',
|
|
45
|
+
'warning', 'error', 'info', 'success', 'light', 'dark',
|
|
46
|
+
'main', 'main-primary', 'main-secondary', 'main-tertiary',
|
|
47
|
+
'body', 'body-primary', 'body-secondary', 'body-tertiary',
|
|
48
|
+
'primary-foreground', 'accent-foreground', 'current-foreground',
|
|
49
|
+
'warning-foreground', 'error-foreground', 'info-foreground', 'success-foreground', 'light-foreground', 'dark-foreground',
|
|
50
|
+
'main-foreground', 'main-primary-foreground', 'main-secondary-foreground', 'main-tertiary-foreground',
|
|
51
|
+
'body-foreground', 'body-primary-foreground', 'body-secondary-foreground', 'body-tertiary-foreground'
|
|
52
|
+
],
|
|
53
|
+
fontFamily: ['primary', 'secondary'],
|
|
54
|
+
fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
|
|
55
|
+
ease: ['linear', 'in', 'out', 'in-out'],
|
|
56
|
+
zIndex: [10, 20, 30, 40, 50, 60],
|
|
57
|
+
fontSize: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '3xl', '4xl', '5xl', '6xl', '7xl', '7xl', '8xl', '9xl'],
|
|
58
|
+
spacing: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'],
|
|
59
|
+
borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
|
|
60
|
+
animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
|
|
61
|
+
mask: ['check', 'radio', 'angle-up', 'angle-down'],
|
|
62
|
+
screens: {
|
|
63
|
+
xs: '22.5em',
|
|
64
|
+
sm: '26em',
|
|
65
|
+
md: '48em',
|
|
66
|
+
lg: '60em',
|
|
67
|
+
xl: '76em',
|
|
68
|
+
'2xl': '82em',
|
|
69
|
+
'3xl': '88em',
|
|
70
|
+
'4xl': '100em',
|
|
71
|
+
xxl: '126em',
|
|
72
|
+
'2xxl': '158em'
|
|
73
|
+
},
|
|
74
|
+
settings: {
|
|
75
|
+
rgb: false,
|
|
76
|
+
colorMix: true
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const tailwindColors = (colors = []) => {
|
|
81
|
+
colors.forEach(name => {
|
|
82
|
+
if (defaultConfig.settings.rgb) {
|
|
83
|
+
colors[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
colors[name] = defaultConfig.settings.colorMix
|
|
87
|
+
? `color-mix(in var(--space), var(--color-${name}) calc(<alpha-value> * 100%), transparent)`
|
|
88
|
+
: `rgb(var(--color-${name}) / <alpha-value>)`;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return colors
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const tailwindVariables = (type, variables = [], values = {}) => {
|
|
95
|
+
variables.forEach(name => {
|
|
96
|
+
values[name] = `var(--${type}-${name})`;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return values
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const tailwindVariablesFont = (type, variables = [], values = {}) => {
|
|
103
|
+
variables.forEach(name => {
|
|
104
|
+
values[name] = [`var(--${type}-${name})`, `calc(var(--${type}-${name}) + 0.5rem)`];
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return values
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const tailwindPropertyUtilities = (type, variables = []) => {
|
|
111
|
+
const result = {};
|
|
112
|
+
|
|
113
|
+
variables.forEach(name => {
|
|
114
|
+
result[`.${type}-${name}`] = {
|
|
115
|
+
[type]: `var(--${type}-${name})`
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return result
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const tailwindAnimations = (values) => {
|
|
123
|
+
const result = {};
|
|
124
|
+
|
|
125
|
+
values.forEach(value => {
|
|
126
|
+
result[`.animation-${value}`] = {
|
|
127
|
+
'animation-name': value
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return result
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const createPlugin = (userConfig = {}) => {
|
|
135
|
+
userConfig = {
|
|
136
|
+
...defaultConfig,
|
|
137
|
+
...userConfig
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return plugin(({ addUtilities, addComponents, matchUtilities, theme, e, corePlugins }) => {
|
|
141
|
+
matchUtilities(
|
|
142
|
+
{
|
|
143
|
+
accent: (value) => {
|
|
144
|
+
const matchValue = toColorValue(value).match(/var\((--color-.*?)\)/);
|
|
145
|
+
const fallbackRgb = matchValue && matchValue[0].includes('-rgb');
|
|
146
|
+
|
|
147
|
+
const colorProperties = {};
|
|
148
|
+
|
|
149
|
+
if (fallbackRgb) {
|
|
150
|
+
colorProperties['--color-accent-rgb'] = matchValue[0];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if ((matchValue && matchValue[0] === 'var(--color-accent)') || (matchValue && matchValue[0] === 'var(--color-accent-rgb)')) {
|
|
154
|
+
return {
|
|
155
|
+
'accent-color': matchValue && toColorValue(value).includes('calc(1 * 100%)') ? matchValue[0] : toColorValue(value)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (matchValue) {
|
|
160
|
+
if (fallbackRgb) {
|
|
161
|
+
colorProperties['--color-accent-foreground-rgb'] = `var(${matchValue[1].replace('-rgb', '-foreground-rgb')})`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (toColorValue(value).includes('calc(1 * 100%)') || toColorValue(value).includes(' / 1')) {
|
|
165
|
+
return {
|
|
166
|
+
...colorProperties,
|
|
167
|
+
'--color-accent': fallbackRgb ? toColorValue(value) : matchValue[0],
|
|
168
|
+
'--color-accent-foreground': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-foreground-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-foreground, var(--color-light))`,
|
|
169
|
+
'accent-color': defaultConfig.settings.colorMix ? 'var(--color-accent)' : 'rgb(var(--color-accent))'
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
return {
|
|
173
|
+
...colorProperties,
|
|
174
|
+
'--color-accent': toColorValue(value),
|
|
175
|
+
'--color-accent-foreground': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-foreground-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-foreground, var(--color-light))`,
|
|
176
|
+
'accent-color': defaultConfig.settings.colorMix ? 'var(--color-accent)' : 'rgb(var(--color-accent))'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
'--color-accent': toColorValue(value),
|
|
183
|
+
'accent-color': 'var(--color-accent)'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{ values: flattenColorPalette(theme('accentColor')), type: ['color', 'any'] }
|
|
188
|
+
);
|
|
189
|
+
matchUtilities(
|
|
190
|
+
{
|
|
191
|
+
text: (value) => {
|
|
192
|
+
const matchValue = toColorValue(value).match(/var\((.*?)\)/);
|
|
193
|
+
const fallbackRgb = matchValue && matchValue[0].includes('-rgb');
|
|
194
|
+
|
|
195
|
+
const colorProperties = {};
|
|
196
|
+
|
|
197
|
+
if (fallbackRgb) {
|
|
198
|
+
colorProperties['--color-current-rgb'] = matchValue[0];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if ((matchValue && matchValue[0] === 'var(--color-current)') || (matchValue && matchValue[0] === 'var(--color-current-rgb)')) {
|
|
202
|
+
return {
|
|
203
|
+
color: toColorValue(value)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const color = {
|
|
208
|
+
...withAlphaVariable({
|
|
209
|
+
color: value,
|
|
210
|
+
property: 'color',
|
|
211
|
+
variable: '--tw-text-opacity'
|
|
212
|
+
})
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
if (!corePlugins('textOpacity')) {
|
|
216
|
+
return {
|
|
217
|
+
...colorProperties,
|
|
218
|
+
'--color-current': toColorValue(value),
|
|
219
|
+
...color
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
...colorProperties,
|
|
225
|
+
...withAlphaVariable({
|
|
226
|
+
color: value,
|
|
227
|
+
property: '--color-current',
|
|
228
|
+
variable: '--tw-text-opacity'
|
|
229
|
+
}),
|
|
230
|
+
...color
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{ values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
|
|
235
|
+
);
|
|
236
|
+
addComponents(tailwindAnimations(userConfig.animations));
|
|
237
|
+
addComponents(tailwindPropertyUtilities('mask', userConfig.mask));
|
|
238
|
+
addComponents([
|
|
239
|
+
Object.entries(theme('spacing')).map(([key, value]) => {
|
|
240
|
+
return {
|
|
241
|
+
[`.${e(`divide-gap-x-${key}`)}`]: {
|
|
242
|
+
'& > :where(*:not(:first-child))': {
|
|
243
|
+
paddingLeft: value,
|
|
244
|
+
marginLeft: value
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
[`.${e(`divide-gap-y-${key}`)}`]: {
|
|
248
|
+
'& > :where(*:not(:first-child))': {
|
|
249
|
+
paddingTop: value,
|
|
250
|
+
marginTop: value
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
]);
|
|
256
|
+
addComponents({
|
|
257
|
+
'.flex-center': {
|
|
258
|
+
display: 'flex',
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
gap: 'var(--spacing-sm)'
|
|
261
|
+
},
|
|
262
|
+
'.flex-between': {
|
|
263
|
+
display: 'flex',
|
|
264
|
+
justifyContent: 'space-between',
|
|
265
|
+
gap: 'var(--spacing-sm)'
|
|
266
|
+
},
|
|
267
|
+
'.dot': {
|
|
268
|
+
'--tw-bg-opacity': '1',
|
|
269
|
+
display: 'inline-flex',
|
|
270
|
+
width: '0.625rem',
|
|
271
|
+
height: '0.625rem',
|
|
272
|
+
borderRadius: 'var(--rounded-full)',
|
|
273
|
+
backgroundColor: 'color-mix(in srgb, var(--color-accent) calc(var(--tw-bg-opacity) * 100%), transparent)',
|
|
274
|
+
flexShrink: '0'
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}, {
|
|
278
|
+
corePlugins: {
|
|
279
|
+
preflight: false,
|
|
280
|
+
textColor: false,
|
|
281
|
+
accentColor: false
|
|
282
|
+
},
|
|
283
|
+
theme: {
|
|
284
|
+
extend: {
|
|
285
|
+
transitionProperty: {
|
|
286
|
+
DEFAULT: 'var(--transition)'
|
|
287
|
+
},
|
|
288
|
+
transitionDuration: {
|
|
289
|
+
DEFAULT: 'var(--duration)'
|
|
290
|
+
},
|
|
291
|
+
transitionTimingFunction: tailwindVariables('ease', userConfig.ease),
|
|
292
|
+
colors: tailwindColors(userConfig.colors),
|
|
293
|
+
fontSize: tailwindVariablesFont('text', userConfig.fontSize),
|
|
294
|
+
fontFamily: tailwindVariables('font', userConfig.fontFamily),
|
|
295
|
+
fontWeight: tailwindVariables('font', userConfig.fontWeight),
|
|
296
|
+
zIndex: tailwindVariables('z', userConfig.zIndex, {
|
|
297
|
+
0: 0,
|
|
298
|
+
auto: 'auto'
|
|
299
|
+
}),
|
|
300
|
+
spacing: tailwindVariables('spacing', userConfig.spacing),
|
|
301
|
+
borderRadius: tailwindVariables('rounded', userConfig.borderRadius, {
|
|
302
|
+
DEFAULT: 'var(--rounded)'
|
|
303
|
+
}),
|
|
304
|
+
screens: userConfig.screens
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
exports.createPlugin = createPlugin;
|
|
311
|
+
exports.default = createPlugin;
|
|
312
|
+
exports.defaultConfig = defaultConfig;
|
|
313
|
+
exports.tailwindAnimations = tailwindAnimations;
|
|
314
|
+
exports.tailwindColors = tailwindColors;
|
|
315
|
+
exports.tailwindPropertyUtilities = tailwindPropertyUtilities;
|
|
316
|
+
exports.tailwindVariables = tailwindVariables;
|
|
317
|
+
exports.tailwindVariablesFont = tailwindVariablesFont;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin'
|
|
2
|
+
import flattenColorPalette from 'tailwindcss/src/util/flattenColorPalette'
|
|
3
|
+
import toColorValue from 'tailwindcss/src/util/toColorValue'
|
|
4
|
+
import { parseColor, formatColor } from 'tailwindcss/src/util/color'
|
|
5
|
+
|
|
6
|
+
function withAlphaVariable ({ color, property, variable }) {
|
|
7
|
+
const properties = [].concat(property)
|
|
8
|
+
if (typeof color === 'function') {
|
|
9
|
+
return {
|
|
10
|
+
...Object.fromEntries(
|
|
11
|
+
properties.map((p) => {
|
|
12
|
+
return [p, color({ opacityVariable: variable, opacityValue: `var(${variable}, 1)` })]
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const parsed = parseColor(color)
|
|
19
|
+
|
|
20
|
+
if (parsed === null) {
|
|
21
|
+
return Object.fromEntries(properties.map((p) => [p, color]))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (parsed.alpha !== undefined) {
|
|
25
|
+
// Has an alpha value, return color as-is
|
|
26
|
+
return Object.fromEntries(properties.map((p) => [p, color]))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
...Object.fromEntries(
|
|
31
|
+
properties.map((p) => {
|
|
32
|
+
return [p, formatColor({ ...parsed, alpha: `var(${variable}, 1)` })]
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const defaultConfig = {
|
|
39
|
+
colors: [
|
|
40
|
+
'primary', 'accent', 'current',
|
|
41
|
+
'warning', 'error', 'info', 'success', 'light', 'dark',
|
|
42
|
+
'main', 'main-primary', 'main-secondary', 'main-tertiary',
|
|
43
|
+
'body', 'body-primary', 'body-secondary', 'body-tertiary',
|
|
44
|
+
'primary-foreground', 'accent-foreground', 'current-foreground',
|
|
45
|
+
'warning-foreground', 'error-foreground', 'info-foreground', 'success-foreground', 'light-foreground', 'dark-foreground',
|
|
46
|
+
'main-foreground', 'main-primary-foreground', 'main-secondary-foreground', 'main-tertiary-foreground',
|
|
47
|
+
'body-foreground', 'body-primary-foreground', 'body-secondary-foreground', 'body-tertiary-foreground'
|
|
48
|
+
],
|
|
49
|
+
fontFamily: ['primary', 'secondary'],
|
|
50
|
+
fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
|
|
51
|
+
ease: ['linear', 'in', 'out', 'in-out'],
|
|
52
|
+
zIndex: [10, 20, 30, 40, 50, 60],
|
|
53
|
+
fontSize: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '3xl', '4xl', '5xl', '6xl', '7xl', '7xl', '8xl', '9xl'],
|
|
54
|
+
spacing: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'],
|
|
55
|
+
borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
|
|
56
|
+
animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
|
|
57
|
+
mask: ['check', 'radio', 'angle-up', 'angle-down'],
|
|
58
|
+
screens: {
|
|
59
|
+
xs: '22.5em',
|
|
60
|
+
sm: '26em',
|
|
61
|
+
md: '48em',
|
|
62
|
+
lg: '60em',
|
|
63
|
+
xl: '76em',
|
|
64
|
+
'2xl': '82em',
|
|
65
|
+
'3xl': '88em',
|
|
66
|
+
'4xl': '100em',
|
|
67
|
+
xxl: '126em',
|
|
68
|
+
'2xxl': '158em'
|
|
69
|
+
},
|
|
70
|
+
settings: {
|
|
71
|
+
rgb: false,
|
|
72
|
+
colorMix: true
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const tailwindColors = (colors = []) => {
|
|
77
|
+
colors.forEach(name => {
|
|
78
|
+
if (defaultConfig.settings.rgb) {
|
|
79
|
+
colors[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
colors[name] = defaultConfig.settings.colorMix
|
|
83
|
+
? `color-mix(in var(--space), var(--color-${name}) calc(<alpha-value> * 100%), transparent)`
|
|
84
|
+
: `rgb(var(--color-${name}) / <alpha-value>)`
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return colors
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const tailwindVariables = (type, variables = [], values = {}) => {
|
|
91
|
+
variables.forEach(name => {
|
|
92
|
+
values[name] = `var(--${type}-${name})`
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return values
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const tailwindVariablesFont = (type, variables = [], values = {}) => {
|
|
99
|
+
variables.forEach(name => {
|
|
100
|
+
values[name] = [`var(--${type}-${name})`, `calc(var(--${type}-${name}) + 0.5rem)`]
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
return values
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const tailwindPropertyUtilities = (type, variables = []) => {
|
|
107
|
+
const result = {}
|
|
108
|
+
|
|
109
|
+
variables.forEach(name => {
|
|
110
|
+
result[`.${type}-${name}`] = {
|
|
111
|
+
[type]: `var(--${type}-${name})`
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
return result
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const tailwindAnimations = (values) => {
|
|
119
|
+
const result = {}
|
|
120
|
+
|
|
121
|
+
values.forEach(value => {
|
|
122
|
+
result[`.animation-${value}`] = {
|
|
123
|
+
'animation-name': value
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
return result
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const createPlugin = (userConfig = {}) => {
|
|
131
|
+
userConfig = {
|
|
132
|
+
...defaultConfig,
|
|
133
|
+
...userConfig
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return plugin(({ addUtilities, addComponents, matchUtilities, theme, e, corePlugins }) => {
|
|
137
|
+
matchUtilities(
|
|
138
|
+
{
|
|
139
|
+
accent: (value) => {
|
|
140
|
+
const matchValue = toColorValue(value).match(/var\((--color-.*?)\)/)
|
|
141
|
+
const fallbackRgb = matchValue && matchValue[0].includes('-rgb')
|
|
142
|
+
|
|
143
|
+
const colorProperties = {}
|
|
144
|
+
|
|
145
|
+
if (fallbackRgb) {
|
|
146
|
+
colorProperties['--color-accent-rgb'] = matchValue[0]
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if ((matchValue && matchValue[0] === 'var(--color-accent)') || (matchValue && matchValue[0] === 'var(--color-accent-rgb)')) {
|
|
150
|
+
return {
|
|
151
|
+
'accent-color': matchValue && toColorValue(value).includes('calc(1 * 100%)') ? matchValue[0] : toColorValue(value)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (matchValue) {
|
|
156
|
+
if (fallbackRgb) {
|
|
157
|
+
colorProperties['--color-accent-foreground-rgb'] = `var(${matchValue[1].replace('-rgb', '-foreground-rgb')})`
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (toColorValue(value).includes('calc(1 * 100%)') || toColorValue(value).includes(' / 1')) {
|
|
161
|
+
return {
|
|
162
|
+
...colorProperties,
|
|
163
|
+
'--color-accent': fallbackRgb ? toColorValue(value) : matchValue[0],
|
|
164
|
+
'--color-accent-foreground': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-foreground-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-foreground, var(--color-light))`,
|
|
165
|
+
'accent-color': defaultConfig.settings.colorMix ? 'var(--color-accent)' : 'rgb(var(--color-accent))'
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
return {
|
|
169
|
+
...colorProperties,
|
|
170
|
+
'--color-accent': toColorValue(value),
|
|
171
|
+
'--color-accent-foreground': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-foreground-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-foreground, var(--color-light))`,
|
|
172
|
+
'accent-color': defaultConfig.settings.colorMix ? 'var(--color-accent)' : 'rgb(var(--color-accent))'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
'--color-accent': toColorValue(value),
|
|
179
|
+
'accent-color': 'var(--color-accent)'
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{ values: flattenColorPalette(theme('accentColor')), type: ['color', 'any'] }
|
|
184
|
+
)
|
|
185
|
+
matchUtilities(
|
|
186
|
+
{
|
|
187
|
+
text: (value) => {
|
|
188
|
+
const matchValue = toColorValue(value).match(/var\((.*?)\)/)
|
|
189
|
+
const fallbackRgb = matchValue && matchValue[0].includes('-rgb')
|
|
190
|
+
|
|
191
|
+
const colorProperties = {}
|
|
192
|
+
|
|
193
|
+
if (fallbackRgb) {
|
|
194
|
+
colorProperties['--color-current-rgb'] = matchValue[0]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if ((matchValue && matchValue[0] === 'var(--color-current)') || (matchValue && matchValue[0] === 'var(--color-current-rgb)')) {
|
|
198
|
+
return {
|
|
199
|
+
color: toColorValue(value)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const color = {
|
|
204
|
+
...withAlphaVariable({
|
|
205
|
+
color: value,
|
|
206
|
+
property: 'color',
|
|
207
|
+
variable: '--tw-text-opacity'
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!corePlugins('textOpacity')) {
|
|
212
|
+
return {
|
|
213
|
+
...colorProperties,
|
|
214
|
+
'--color-current': toColorValue(value),
|
|
215
|
+
...color
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
...colorProperties,
|
|
221
|
+
...withAlphaVariable({
|
|
222
|
+
color: value,
|
|
223
|
+
property: '--color-current',
|
|
224
|
+
variable: '--tw-text-opacity'
|
|
225
|
+
}),
|
|
226
|
+
...color
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{ values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
|
|
231
|
+
)
|
|
232
|
+
addComponents(tailwindAnimations(userConfig.animations))
|
|
233
|
+
addComponents(tailwindPropertyUtilities('mask', userConfig.mask))
|
|
234
|
+
addComponents([
|
|
235
|
+
Object.entries(theme('spacing')).map(([key, value]) => {
|
|
236
|
+
return {
|
|
237
|
+
[`.${e(`divide-gap-x-${key}`)}`]: {
|
|
238
|
+
'& > :where(*:not(:first-child))': {
|
|
239
|
+
paddingLeft: value,
|
|
240
|
+
marginLeft: value
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
[`.${e(`divide-gap-y-${key}`)}`]: {
|
|
244
|
+
'& > :where(*:not(:first-child))': {
|
|
245
|
+
paddingTop: value,
|
|
246
|
+
marginTop: value
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
])
|
|
252
|
+
addComponents({
|
|
253
|
+
'.flex-center': {
|
|
254
|
+
display: 'flex',
|
|
255
|
+
alignItems: 'center',
|
|
256
|
+
gap: 'var(--spacing-sm)'
|
|
257
|
+
},
|
|
258
|
+
'.flex-between': {
|
|
259
|
+
display: 'flex',
|
|
260
|
+
justifyContent: 'space-between',
|
|
261
|
+
gap: 'var(--spacing-sm)'
|
|
262
|
+
},
|
|
263
|
+
'.dot': {
|
|
264
|
+
'--tw-bg-opacity': '1',
|
|
265
|
+
display: 'inline-flex',
|
|
266
|
+
width: '0.625rem',
|
|
267
|
+
height: '0.625rem',
|
|
268
|
+
borderRadius: 'var(--rounded-full)',
|
|
269
|
+
backgroundColor: 'color-mix(in srgb, var(--color-accent) calc(var(--tw-bg-opacity) * 100%), transparent)',
|
|
270
|
+
flexShrink: '0'
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
}, {
|
|
274
|
+
corePlugins: {
|
|
275
|
+
preflight: false,
|
|
276
|
+
textColor: false,
|
|
277
|
+
accentColor: false
|
|
278
|
+
},
|
|
279
|
+
theme: {
|
|
280
|
+
extend: {
|
|
281
|
+
transitionProperty: {
|
|
282
|
+
DEFAULT: 'var(--transition)'
|
|
283
|
+
},
|
|
284
|
+
transitionDuration: {
|
|
285
|
+
DEFAULT: 'var(--duration)'
|
|
286
|
+
},
|
|
287
|
+
transitionTimingFunction: tailwindVariables('ease', userConfig.ease),
|
|
288
|
+
colors: tailwindColors(userConfig.colors),
|
|
289
|
+
fontSize: tailwindVariablesFont('text', userConfig.fontSize),
|
|
290
|
+
fontFamily: tailwindVariables('font', userConfig.fontFamily),
|
|
291
|
+
fontWeight: tailwindVariables('font', userConfig.fontWeight),
|
|
292
|
+
zIndex: tailwindVariables('z', userConfig.zIndex, {
|
|
293
|
+
0: 0,
|
|
294
|
+
auto: 'auto'
|
|
295
|
+
}),
|
|
296
|
+
spacing: tailwindVariables('spacing', userConfig.spacing),
|
|
297
|
+
borderRadius: tailwindVariables('rounded', userConfig.borderRadius, {
|
|
298
|
+
DEFAULT: 'var(--rounded)'
|
|
299
|
+
}),
|
|
300
|
+
screens: userConfig.screens
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export default createPlugin
|