winduum 0.2.2 → 0.2.3-next.2

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.
@@ -7,7 +7,7 @@
7
7
  --ui-control-px: 0.875rem;
8
8
  --ui-control-pl: var(--ui-control-px);
9
9
  --ui-control-pr: var(--ui-control-px);
10
- --ui-control-bg: var(--color-body);
10
+ --ui-control-bg: transparent;
11
11
  --ui-control-color: currentColor;
12
12
  --ui-control-placeholder-color: currentColor;
13
13
  --ui-control-placeholder-opacity: 0.5;
@@ -59,7 +59,7 @@
59
59
 
60
60
  &:disabled {
61
61
  cursor: not-allowed;
62
- background-color: color-mix(in sRGB, var(--color-base) var(--ui-control-disabled-opacity), var(--ui-control-bg));
62
+ background-color: color-mix(in sRGB, var(--color-current) var(--ui-control-disabled-opacity), var(--ui-control-bg));
63
63
  }
64
64
 
65
65
  &:required ~ label {
@@ -1,4 +1,6 @@
1
1
  .ui-control:where(.floating) {
2
+ --ui-control-placeholder-color: transparent;
3
+
2
4
  & :where(input, textarea, select) {
3
5
  &:is(:focus, :not(:placeholder-shown)) ~ label {
4
6
  transform: var(--ui-control-floating-label-focus-transform);
@@ -4,7 +4,6 @@
4
4
  --ui-control-floating-label-focus-transform: translateY(-0.6875rem) scale(0.8);
5
5
  --ui-control-floating-label-focus-opacity: 50%;
6
6
  --ui-control-floating-label-transition-duration: 0.4s;
7
- --ui-control-placeholder-color: transparent;
8
7
 
9
8
  & :where(label) {
10
9
  grid-area: input;
package/src/ui/image.css CHANGED
@@ -6,7 +6,7 @@
6
6
  background-color: var(--ui-image-bg);
7
7
  border-radius: inherit;
8
8
 
9
- & > * {
9
+ & > *:not(source) {
10
10
  display: block;
11
11
  width: 100%;
12
12
  height: 100%;
@@ -5,7 +5,7 @@
5
5
  --ui-link-letter-spacing: 0;
6
6
  --ui-link-hover-color: var(--color-accent);
7
7
  --ui-link-hover-opacity: 0.75;
8
- --ui-link-active-opacity: 0.75;
8
+ --ui-link-active-opacity: 1;
9
9
  --ui-link-gap: 0.5rem;
10
10
 
11
11
  font-size: var(--ui-link-font-size);
@@ -27,6 +27,7 @@
27
27
 
28
28
  &:focus-visible {
29
29
  color: var(--ui-link-hover-color);
30
+ opacity: var(--ui-link-hover-opacity);
30
31
  }
31
32
 
32
33
  &:active {
@@ -1,5 +1,6 @@
1
1
  .ui-link:where([class*="underlined"]) {
2
2
  --ui-link-hover-opacity: 1;
3
+ --ui-link-active-opacity: 0.75;
3
4
  --ui-link-underline-color: currentColor;
4
5
  --ui-link-underline-width: 1px;
5
6
  --ui-link-underline-opacity: 0;
@@ -10,7 +11,7 @@
10
11
  --ui-link-underline-transform: none;
11
12
  --ui-link-underline-color: var(--color-accent);
12
13
  --ui-link-hover-opacity: 0.75;
13
- --ui-link-active-opacity: 0.75;
14
+ --ui-link-active-opacity: 1;
14
15
  }
15
16
 
16
17
  &::after, & span::after {
package/src/ui/notice.css CHANGED
@@ -1,5 +1,4 @@
1
1
  .ui-notice {
2
- --color-current: var(--color-accent);
3
2
  --ui-notice-bg: var(--color-accent);
4
3
  --ui-notice-py: 1.25rem;
5
4
  --ui-notice-px: 1.5rem;
@@ -19,7 +18,7 @@
19
18
  background-color: color-mix(in sRGB, var(--ui-notice-bg) 10%, transparent);
20
19
  outline: var(--ui-notice-outline-width) solid color-mix(in sRGB, var(--ui-notice-bg) var(--ui-notice-outline-opacity), transparent);
21
20
  outline-offset: var(--ui-notice-outline-offset);
22
- color: var(--color-current);
21
+ color: var(--color-accent);
23
22
  gap: var(--ui-notice-gap);
24
23
 
25
24
  & :where(hr) {
package/src/ui/text.css CHANGED
@@ -3,8 +3,7 @@
3
3
  --ui-text-size-line: 0.75rem;
4
4
  --ui-text-weight: var(--font-normal);
5
5
  --ui-text-weight-bold: var(--font-semibold);
6
- --ui-text-content-my: 1.5rem;
7
- --ui-text-content-my-sm: 1rem;
6
+ --ui-text-content-my: 1rem;
8
7
  --ui-text-content-my-lg: 2rem;
9
8
 
10
9
  font-weight: var(--ui-text-weight);
@@ -13,6 +12,7 @@
13
12
 
14
13
  &:where(.lg) {
15
14
  --ui-text-size: 1.125rem;
15
+ --ui-text-size-line: 1rem;
16
16
  }
17
17
 
18
18
  & :where(a) {
@@ -59,7 +59,7 @@
59
59
  line-height: inherit;
60
60
 
61
61
  &:not(:only-child) {
62
- margin: var(--ui-text-content-my-sm) 0;
62
+ margin: var(--ui-text-content-my) 0;
63
63
  }
64
64
 
65
65
  &:last-child {
@@ -67,7 +67,7 @@
67
67
  }
68
68
 
69
69
  &:empty {
70
- line-height: var(--ui-text-content-my-sm);
70
+ line-height: var(--ui-text-content-my);
71
71
  margin: 0;
72
72
  }
73
73
 
@@ -87,7 +87,7 @@
87
87
  font-family: var(--font-secondary);
88
88
  font-size: var(--ui-text-heading-size, 1rem);
89
89
  line-height: calc(var(--ui-text-heading-size) + 0.5rem);
90
- margin: var(--ui-text-content-my) 0 var(--ui-text-content-my-sm);
90
+ margin: var(--ui-text-content-my-lg) 0 var(--ui-text-content-my);
91
91
 
92
92
  &:first-child {
93
93
  margin-top: 0;
@@ -145,7 +145,7 @@
145
145
 
146
146
  & :where(code) {
147
147
  margin: 0 0.25rem;
148
- border-radius: var(--rounded-xs);
148
+ border-radius: var(--rounded-sm);
149
149
  padding: 0.25rem 0.375rem;
150
150
  font-size: 0.85em;
151
151
  color: var(--color-accent);
@@ -6,5 +6,5 @@ module.exports = {
6
6
  ],
7
7
  plugins: [
8
8
  require('./utils/tailwind.cjs')()
9
- ],
9
+ ]
10
10
  }
@@ -3,21 +3,56 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var plugin = require('tailwindcss/plugin');
6
- var twColors = require('tailwindcss/colors');
6
+ var flattenColorPalette = require('tailwindcss/src/util/flattenColorPalette');
7
+ var toColorValue = require('tailwindcss/src/util/toColorValue');
8
+ var color = require('tailwindcss/src/util/color');
7
9
  var lodash = require('lodash');
8
10
 
11
+ function withAlphaVariable ({ color: color$1, property, variable }) {
12
+ const properties = [].concat(property);
13
+ if (typeof color$1 === 'function') {
14
+ return {
15
+ ...Object.fromEntries(
16
+ properties.map((p) => {
17
+ return [p, color$1({ opacityVariable: variable, opacityValue: `var(${variable}, 1)` })]
18
+ })
19
+ )
20
+ }
21
+ }
22
+
23
+ const parsed = color.parseColor(color$1);
24
+
25
+ if (parsed === null) {
26
+ return Object.fromEntries(properties.map((p) => [p, color$1]))
27
+ }
28
+
29
+ if (parsed.alpha !== undefined) {
30
+ // Has an alpha value, return color as-is
31
+ return Object.fromEntries(properties.map((p) => [p, color$1]))
32
+ }
33
+
34
+ return {
35
+ ...Object.fromEntries(
36
+ properties.map((p) => {
37
+ return [p, color.formatColor({ ...parsed, alpha: `var(${variable}, 1)` })]
38
+ })
39
+ )
40
+ }
41
+ }
42
+
9
43
  const defaultConfig = {
10
44
  colors: [
11
- 'light', 'dark', 'primary',
12
- 'warning', 'error', 'info', 'success', 'accent', 'current',
13
- 'base', 'base-primary', 'base-secondary', 'base-tertiary',
45
+ 'primary', 'accent', 'current',
46
+ 'warning', 'error', 'info', 'success', 'light', 'dark',
47
+ 'main', 'main-primary', 'main-secondary', 'main-tertiary',
14
48
  'body', 'body-primary', 'body-secondary', 'body-tertiary'
15
49
  ],
16
50
  fontFamily: ['primary', 'secondary'],
17
51
  fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
18
52
  zIndex: [10, 20, 30, 40, 50, 60],
19
- spacing: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'section'],
20
- borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'full'],
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', 'section'],
55
+ borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
21
56
  animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
22
57
  screens: {
23
58
  xs: '22.5em',
@@ -30,101 +65,35 @@ const defaultConfig = {
30
65
  '4xl': '100em',
31
66
  xxl: '126em',
32
67
  '2xxl': '158em'
68
+ },
69
+ settings: {
70
+ rgb: true
33
71
  }
34
72
  };
35
73
 
36
- const hexToRgb = hex => hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
37
- .substring(1).match(/.{2}/g)
38
- .map(x => parseInt(x, 16));
39
-
40
- const getTailwindColors = (twColors) => {
41
- const accentColors = [];
42
-
43
- Object.keys(twColors).forEach(color => {
44
- if (color.match(/(lightBlue|warmGray|trueGray|coolGray|blueGray)/)) {
45
- return
46
- }
47
-
48
- if (typeof twColors[color] === 'object') {
49
- Object.keys(twColors[color]).forEach(variant => {
50
- accentColors.push([`${color.replace(/[A-Z]/g, m => '-' + m.toLowerCase())}-${variant}`, twColors[color][variant]]);
51
- });
52
- } else {
53
- accentColors.push([color, twColors[color]]);
54
- }
55
- });
56
-
57
- return accentColors
58
- };
59
-
60
74
  const tailwindColors = (colors = []) => {
61
75
  colors.forEach(name => {
62
- colors[name + '-rgb'] = ({ opacityValue }) => {
63
- if (opacityValue === undefined) {
64
- return `rgb(var(--color-${name}-rgb))`
65
- }
66
- return `rgb(var(--color-${name}-rgb) / ${opacityValue})`
67
- };
68
-
69
- colors[name] = ({ opacityValue }) => {
70
- if (opacityValue === undefined) {
71
- return `var(--color-${name})`
72
- }
76
+ if (defaultConfig.settings.rgb) {
77
+ colors[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`;
78
+ }
73
79
 
74
- return `color-mix(in sRGB, var(--color-${name}) calc(${opacityValue} * 100%), transparent)`
75
- };
80
+ colors[name] = `color-mix(in sRGB, var(--color-${name}) calc(<alpha-value> * 100%), transparent)`;
76
81
  });
77
82
 
78
83
  return colors
79
84
  };
80
85
 
81
- const tailwindColorsAccent = (colors = []) => {
82
- const result = {};
83
-
84
- colors.forEach(color => {
85
- if (Array.isArray(color)) {
86
- const rgb = hexToRgb(color[1]);
87
-
88
- result[`.accent-${color[0]}`] = {
89
- '--color-accent-rgb': `${rgb[0]} ${rgb[1]} ${rgb[2]}`,
90
- '--color-accent': `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`,
91
- '--color-accent-current': `var(--color-${color}-current, var(--color-light))`
92
- };
93
- } else {
94
- result[`.accent-${color}`] = {
95
- '--color-accent-rgb': `var(--color-${color}-rgb)`,
96
- '--color-accent': `var(--color-${color})`,
97
- '--color-accent-current': `var(--color-${color}-current, var(--color-light))`
98
- };
99
- }
100
- });
101
-
102
- return result
103
- };
104
-
105
- const tailwindColorsCurrent = (colors = []) => {
106
- const result = {};
107
-
108
- colors.forEach(color => {
109
- if (Array.isArray(color)) {
110
- const rgb = hexToRgb(color[1]);
111
-
112
- result[`.text-${color[0]}`] = {
113
- '--color-current': `${rgb[0]} ${rgb[1]} ${rgb[2]}`
114
- };
115
- } else {
116
- result[`.text-${color}`] = {
117
- '--color-current': `var(--color-${color})`
118
- };
119
- }
86
+ const tailwindVariables = (type, variables = [], values = {}) => {
87
+ variables.forEach(name => {
88
+ values[name] = `var(--${type}-${name})`;
120
89
  });
121
90
 
122
- return result
91
+ return values
123
92
  };
124
93
 
125
- const tailwindVariables = (type, variables = [], values = {}) => {
94
+ const tailwindVariablesFont = (type, variables = [], values = {}) => {
126
95
  variables.forEach(name => {
127
- values[name] = `var(--${type}-${name})`;
96
+ values[name] = [`var(--${type}-${name})`, `calc(var(--${type}-${name}) + 0.5rem)`];
128
97
  });
129
98
 
130
99
  return values
@@ -145,9 +114,104 @@ const tailwindAnimations = (values) => {
145
114
  const createPlugin = (userConfig = {}) => {
146
115
  userConfig = lodash.merge(defaultConfig, userConfig);
147
116
 
148
- return plugin(({ addUtilities, theme, variants, e }) => {
149
- addUtilities(Object.assign(tailwindColorsAccent(getTailwindColors(twColors)), tailwindColorsAccent(userConfig.colors)));
150
- addUtilities(Object.assign(tailwindColorsCurrent(getTailwindColors(twColors)), tailwindColorsCurrent(userConfig.colors)));
117
+ return plugin(({ addUtilities, matchUtilities, theme, variants, e, corePlugins }) => {
118
+ matchUtilities(
119
+ {
120
+ accent: (value) => {
121
+ const matchValue = toColorValue(value).match(/var\((.*?)\)/);
122
+ const fallbackRgb = matchValue && matchValue[0].includes('-rgb');
123
+
124
+ const colorProperties = {};
125
+
126
+ if (fallbackRgb) {
127
+ colorProperties['--color-accent-rgb'] = matchValue[0];
128
+ }
129
+
130
+ if ((matchValue && matchValue[0] === 'var(--color-accent)') || (matchValue && matchValue[0] === 'var(--color-accent-rgb)')) {
131
+ return {
132
+ 'accent-color': matchValue && toColorValue(value).includes('calc(1 * 100%)') ? matchValue[0] : toColorValue(value)
133
+ }
134
+ }
135
+
136
+ if (matchValue) {
137
+ if (fallbackRgb) {
138
+ colorProperties['--color-accent-fg-rgb'] = `var(${matchValue[1].replace('-rgb', '-fg-rgb')})`;
139
+ }
140
+
141
+ if (toColorValue(value).includes('calc(1 * 100%)') || toColorValue(value).includes(' / 1')) {
142
+ return {
143
+ ...colorProperties,
144
+ '--color-accent': fallbackRgb ? toColorValue(value) : matchValue[0],
145
+ '--color-accent-fg': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-fg-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-fg, var(--color-light))`,
146
+ 'accent-color': 'var(--color-accent)'
147
+ }
148
+ } else {
149
+ return {
150
+ ...colorProperties,
151
+ '--color-accent': toColorValue(value),
152
+ '--color-accent-fg': fallbackRgb ? `rgb(var(${matchValue[1].replace('-rgb', '-fg-rgb')}, var(--color-light-rgb)))` : `var(${matchValue[1]}-fg, var(--color-light))`,
153
+ 'accent-color': 'var(--color-accent)'
154
+ }
155
+ }
156
+ }
157
+
158
+ return {
159
+ '--color-accent': toColorValue(value),
160
+ 'accent-color': toColorValue(value)
161
+ }
162
+ }
163
+ },
164
+ { values: flattenColorPalette(theme('accentColor')), type: ['color', 'any'] }
165
+ );
166
+ matchUtilities(
167
+ {
168
+ text: (value) => {
169
+ const matchValue = toColorValue(value).match(/var\((.*?)\)/);
170
+ const fallbackRgb = matchValue && matchValue[0].includes('-rgb');
171
+
172
+ const colorProperties = {};
173
+
174
+ if (fallbackRgb) {
175
+ colorProperties['--color-current-rgb'] = matchValue[0];
176
+ }
177
+
178
+ if ((matchValue && matchValue[0] === 'var(--color-current)') || (matchValue && matchValue[0] === 'var(--color-current-rgb)')) {
179
+ return {
180
+ color: toColorValue(value)
181
+ }
182
+ }
183
+
184
+ const color = matchValue
185
+ ? { color: 'var(--color-current)' }
186
+ : {
187
+ ...withAlphaVariable({
188
+ color: value,
189
+ property: 'color',
190
+ variable: '--tw-text-opacity'
191
+ })
192
+ };
193
+
194
+ if (!corePlugins('textOpacity')) {
195
+ return {
196
+ ...colorProperties,
197
+ '--color-current': toColorValue(value),
198
+ ...color
199
+ }
200
+ }
201
+
202
+ return {
203
+ ...colorProperties,
204
+ ...withAlphaVariable({
205
+ color: value,
206
+ property: '--color-current',
207
+ variable: '--tw-text-opacity'
208
+ }),
209
+ ...color
210
+ }
211
+ }
212
+ },
213
+ { values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
214
+ );
151
215
  addUtilities(tailwindAnimations(userConfig.animations));
152
216
  addUtilities([
153
217
  Object.entries(theme('spacing')).map(([key, value]) => {
@@ -162,11 +226,15 @@ const createPlugin = (userConfig = {}) => {
162
226
  }, {
163
227
  corePlugins: {
164
228
  preflight: false,
165
- container: false
229
+ container: false,
230
+ textColor: false,
231
+ accentColor: false
166
232
  },
167
233
  theme: {
234
+ accentOpacity: ({ theme }) => theme('opacity'),
168
235
  extend: {
169
236
  colors: tailwindColors(userConfig.colors),
237
+ fontSize: tailwindVariablesFont('text', userConfig.fontSize),
170
238
  fontFamily: tailwindVariables('font', userConfig.fontFamily),
171
239
  fontWeight: tailwindVariables('font', userConfig.fontWeight),
172
240
  zIndex: tailwindVariables('z', userConfig.zIndex, {
@@ -186,10 +254,7 @@ const createPlugin = (userConfig = {}) => {
186
254
  exports.createPlugin = createPlugin;
187
255
  exports.default = createPlugin;
188
256
  exports.defaultConfig = defaultConfig;
189
- exports.getTailwindColors = getTailwindColors;
190
- exports.hexToRgb = hexToRgb;
191
257
  exports.tailwindAnimations = tailwindAnimations;
192
258
  exports.tailwindColors = tailwindColors;
193
- exports.tailwindColorsAccent = tailwindColorsAccent;
194
- exports.tailwindColorsCurrent = tailwindColorsCurrent;
195
259
  exports.tailwindVariables = tailwindVariables;
260
+ exports.tailwindVariablesFont = tailwindVariablesFont;