winduum 0.1.18 → 0.2.0-beta.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.
Files changed (94) hide show
  1. package/dist/main.css +1 -1
  2. package/dist/tailwind.css +1 -1
  3. package/package.json +15 -17
  4. package/src/base/config.css +0 -10
  5. package/src/base/default.css +23 -10
  6. package/src/base/icons.css +0 -3
  7. package/src/base/index.css +2 -0
  8. package/src/base/keyframes.css +0 -118
  9. package/src/base/reset.css +27 -15
  10. package/src/base/tailwind/utilities.css +3 -3
  11. package/src/base/theme/dark-rgb.css +5 -0
  12. package/src/base/theme/dark.css +5 -7
  13. package/src/base/theme/default-rgb.css +14 -0
  14. package/src/base/theme/default.css +19 -14
  15. package/src/components/dialog.css +2 -2
  16. package/src/components/field.css +3 -3
  17. package/src/libraries/dialog.css +2 -2
  18. package/src/libraries/dialog.js +7 -9
  19. package/src/libraries/ripple.css +2 -2
  20. package/src/libraries/ripple.js +1 -3
  21. package/src/main-rgb.css +1 -0
  22. package/src/main.css +1 -1
  23. package/src/main.js +1 -0
  24. package/src/ui/badge/bordered.css +8 -0
  25. package/src/ui/badge/circle.css +5 -0
  26. package/src/ui/badge/default.css +40 -0
  27. package/src/ui/badge/group.css +16 -0
  28. package/src/ui/badge/index.css +8 -0
  29. package/src/ui/badge/lg.css +3 -0
  30. package/src/ui/badge/muted.css +3 -0
  31. package/src/ui/badge/sm.css +4 -0
  32. package/src/ui/badge/square.css +4 -0
  33. package/src/ui/badge.css +1 -109
  34. package/src/ui/btn/bordered-rgb.css +3 -0
  35. package/src/ui/btn/bordered.css +8 -0
  36. package/src/ui/btn/circle.css +5 -0
  37. package/src/ui/btn/default-rgb.css +9 -0
  38. package/src/ui/btn/default.css +97 -0
  39. package/src/ui/btn/ghosted.css +4 -0
  40. package/src/ui/btn/gradient-bordered.css +27 -0
  41. package/src/ui/btn/gradient.css +10 -0
  42. package/src/ui/btn/group.css +18 -0
  43. package/src/ui/btn/hover-fill.css +8 -0
  44. package/src/ui/btn/index.css +15 -0
  45. package/src/ui/btn/lg.css +4 -0
  46. package/src/ui/btn/loading.css +24 -0
  47. package/src/ui/btn/muted.css +4 -0
  48. package/src/ui/btn/raised.css +8 -0
  49. package/src/ui/btn/sm.css +4 -0
  50. package/src/ui/btn/square.css +4 -0
  51. package/src/ui/btn/wide.css +4 -0
  52. package/src/ui/btn.css +1 -234
  53. package/src/ui/check.css +130 -0
  54. package/src/ui/control/default-rgb.css +18 -0
  55. package/src/ui/control/default.css +94 -0
  56. package/src/ui/control/floating-focus.css +8 -0
  57. package/src/ui/control/floating.css +31 -0
  58. package/src/ui/control/group.css +22 -0
  59. package/src/ui/control/icon.css +66 -0
  60. package/src/ui/control/index.css +6 -0
  61. package/src/ui/control/select.css +27 -0
  62. package/src/ui/heading/default.css +12 -0
  63. package/src/ui/heading/index.css +3 -0
  64. package/src/ui/heading/lg.css +3 -0
  65. package/src/ui/heading/sm.css +4 -0
  66. package/src/ui/heading.css +1 -21
  67. package/src/ui/image.css +4 -4
  68. package/src/ui/{+.css → index.css} +2 -4
  69. package/src/ui/info.css +1 -1
  70. package/src/ui/input.css +1 -226
  71. package/src/ui/label.css +1 -1
  72. package/src/ui/link/default.css +33 -0
  73. package/src/ui/link/index.css +2 -0
  74. package/src/ui/link/underlined.css +47 -0
  75. package/src/ui/link.css +1 -45
  76. package/src/ui/notice.css +9 -22
  77. package/src/ui/progress/default.css +39 -0
  78. package/src/ui/progress/index.css +3 -0
  79. package/src/ui/progress/lg.css +3 -0
  80. package/src/ui/progress/sm.css +3 -0
  81. package/src/ui/progress.css +1 -50
  82. package/src/ui/switch.css +23 -28
  83. package/src/ui/text.css +15 -15
  84. package/src/ui/title/default.css +12 -0
  85. package/src/ui/title/index.css +3 -0
  86. package/src/ui/title/lg.css +3 -0
  87. package/src/ui/title/sm.css +3 -0
  88. package/src/ui/title.css +1 -20
  89. package/tailwind.config.cjs +1 -1
  90. package/utils/tailwind.cjs +42 -27
  91. package/utils/tailwind.js +36 -23
  92. package/src/ui/checkbox.css +0 -106
  93. package/src/ui/radio.css +0 -4
  94. package/src/ui/select.css +0 -27
package/src/ui/switch.css CHANGED
@@ -1,15 +1,15 @@
1
- :where(.ui-switch) {
1
+ .ui-switch {
2
2
  --ui-switch-width: 3rem;
3
3
  --ui-switch-height: 1.5rem;
4
4
  --ui-switch-padding: 0.375rem;
5
- --ui-switch-bg-raw: var(--color-dark);
6
- --ui-switch-radius: 999px;
7
- --ui-switch-validity-font-size: 0.875rem;
8
- --ui-switch-validity-offset: 0.375rem;
9
- --ui-switch-box-shadow: none;
5
+ --ui-switch-bg: var(--color-dark);
6
+ --ui-switch-radius: var(--rounded-full);
7
+ --ui-switch-outline-width: 3px;
8
+ --ui-switch-outline-offset: 0;
9
+ --ui-switch-outline-opacity: 20%;
10
10
 
11
- .dark & {
12
- --ui-switch-bg-raw: var(--color-background-300);
11
+ :where(.dark) & {
12
+ --ui-switch-bg: var(--color-body-tertiary);
13
13
  }
14
14
 
15
15
  display: flex;
@@ -17,12 +17,12 @@
17
17
  flex-wrap: wrap;
18
18
  width: max-content;
19
19
 
20
- &:where(.is-sm) {
20
+ &:where(.sm) {
21
21
  --ui-switch-width: 2.5rem;
22
22
  --ui-switch-height: 1.25rem;
23
23
  }
24
24
 
25
- &:where(.is-lg) {
25
+ &:where(.lg) {
26
26
  --ui-switch-width: 4rem;
27
27
  --ui-switch-height: 2rem;
28
28
  }
@@ -33,18 +33,21 @@
33
33
  display: block;
34
34
  position: relative;
35
35
  border-radius: var(--ui-switch-radius);
36
- background-color: rgb(var(--ui-switch-bg-raw));
37
- transition: var(--transition-background), var(--transition-shadow);
36
+ background-color: var(--ui-switch-bg);
37
+ transition:
38
+ var(--transition-background),
39
+ outline-color var(--transition-duration),
40
+ outline-offset var(--transition-duration);
38
41
  cursor: pointer;
39
42
  appearance: none;
40
- outline: none;
43
+ outline: var(--ui-switch-outline-width) solid transparent;
44
+ outline-offset: 0;
41
45
  color: inherit;
42
- box-shadow: var(--ui-switch-box-shadow);
43
46
 
44
47
  &::before {
45
48
  width: calc(var(--ui-switch-height) - var(--ui-switch-padding));
46
49
  height: calc(var(--ui-switch-height) - var(--ui-switch-padding));
47
- background-color: rgb(var(--color-light));
50
+ background-color: var(--color-light);
48
51
  border-radius: var(--ui-switch-radius);
49
52
  position: absolute;
50
53
  left: var(--ui-switch-height);
@@ -62,24 +65,16 @@
62
65
  }
63
66
 
64
67
  &:focus {
65
- --ui-switch-box-shadow:
66
- 0 0 0 0 rgb(var(--color-current)),
67
- 0 0 0 3px rgb(var(--color-current) / 0.2),
68
- 0 1px 2px 0 rgb(var(--color-current) / 0.05);
68
+ outline-color: color-mix(in sRGB, var(--color-current) var(--ui-switch-outline-opacity), transparent);
69
+ outline-offset: var(--ui-switch-outline-offset);
69
70
  }
70
71
 
71
72
  &:checked {
72
- background-color: rgb(var(--color-accent));
73
-
74
- &:focus {
75
- --ui-switch-box-shadow:
76
- 0 0 0 0 rgb(var(--color-current)),
77
- 0 0 0 3px rgb(var(--color-accent) / 0.2),
78
- 0 1px 2px 0 rgb(var(--color-current) / 0.05);
79
- }
73
+ --color-current: var(--color-accent);
74
+ --ui-switch-bg: var(--color-accent);
80
75
 
81
76
  &::before {
82
- background-color: rgb(var(--color-light));
77
+ background-color: var(--color-light);
83
78
  left: 100%;
84
79
  }
85
80
  }
package/src/ui/text.css CHANGED
@@ -1,4 +1,4 @@
1
- :where(.ui-text) {
1
+ .ui-text {
2
2
  --ui-text-size: 0.875rem;
3
3
  --ui-text-size-line: 0.75rem;
4
4
  --ui-text-weight: var(--font-normal);
@@ -11,23 +11,23 @@
11
11
  font-size: var(--ui-text-size);
12
12
  line-height: calc(var(--ui-text-size) + var(--ui-text-size-line));
13
13
 
14
- &:where(.is-lg) {
14
+ &:where(.lg) {
15
15
  --ui-text-size: 1.125rem;
16
16
  }
17
17
 
18
18
  & :where(a) {
19
19
  text-decoration: underline;
20
20
  transition: var(--transition-color);
21
- color: rgb(var(--color-accent));
21
+ color: var(--color-accent);
22
22
 
23
23
  &:hover {
24
24
  @media (hover: hover) and (pointer: fine) {
25
- color: rgb(var(--color-accent) / 0.7);
25
+ color: color-mix(in sRGB, var(--color-accent) 70%, transparent);
26
26
  }
27
27
  }
28
28
 
29
29
  &:focus-visible {
30
- color: rgb(var(--color-accent) / 0.7);
30
+ color: color-mix(in sRGB, var(--color-accent) 70%, transparent);
31
31
  }
32
32
  }
33
33
 
@@ -117,12 +117,12 @@
117
117
 
118
118
  & :where(thead) {
119
119
  font-weight: var(--ui-text-weight-bold);
120
- border-bottom: 1px solid rgb(var(--color-current) / 0.075);
120
+ border-bottom: 1px solid color-mix(in sRGB, var(--color-current) 0.75%, transparent);
121
121
  }
122
122
 
123
123
  & :where(tbody tr) {
124
124
  &:nth-of-type(even) {
125
- background-color: rgb(var(--color-current) / 0.05);
125
+ background-color: color-mix(in sRGB, var(--color-current) 0.5%, transparent);
126
126
  }
127
127
  }
128
128
  }
@@ -137,7 +137,7 @@
137
137
  }
138
138
 
139
139
  & :where(blockquote) {
140
- border-left: 0.3125rem solid rgb(var(--color-accent) / 1);
140
+ border-left: 0.3125rem solid var(--color-accent);
141
141
  padding: 0.5rem 1.25rem;
142
142
  margin: 1rem 0;
143
143
  font-size: inherit;
@@ -148,12 +148,12 @@
148
148
  border-radius: var(--rounded-xs);
149
149
  padding: 0.25rem 0.375rem;
150
150
  font-size: 0.85em;
151
- color: rgb(var(--color-accent));
151
+ color: var(--color-accent);
152
152
  font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
153
- background-color: rgb(27 31 35 / 0.05);
153
+ background-color: rgb(27 31 35 / 5%);
154
154
 
155
- .dark & {
156
- background-color: rgb(var(--color-background-200));
155
+ :where(.dark) & {
156
+ background-color: var(--color-body-secondary);
157
157
  }
158
158
  }
159
159
 
@@ -173,7 +173,7 @@
173
173
  }
174
174
 
175
175
  &::marker {
176
- color: rgb(var(--color-accent));
176
+ color: var(--color-accent);
177
177
  font-weight: var(--ui-text-weight-bold);
178
178
  }
179
179
  }
@@ -198,8 +198,8 @@
198
198
  height: 0.375rem;
199
199
  position: absolute;
200
200
  content: "";
201
- border: 1px solid rgb(var(--color-accent));
202
- background-color: rgb(var(--color-accent));
201
+ border: 1px solid var(--color-accent);
202
+ background-color: var(--color-accent);
203
203
  left: 0;
204
204
  top: 0.6875rem;
205
205
  text-indent: 0;
@@ -0,0 +1,12 @@
1
+ .ui-title {
2
+ --ui-title-font-family: var(--font-secondary);
3
+ --ui-title-font-weight: var(--font-semibold);
4
+ --ui-title-font-size: 0.875rem;
5
+ --ui-title-line-height: calc(var(--ui-heading-font-size) + var(--ui-heading-line-height-ratio));
6
+ --ui-title-line-height-ratio: 0.375rem;
7
+
8
+ font-family: var(--ui-title-font-family);
9
+ font-size: var(--ui-title-font-size);
10
+ line-height: var(--ui-title-line-height);
11
+ font-weight: var(--ui-title-font-weight);
12
+ }
@@ -0,0 +1,3 @@
1
+ @import "default.css";
2
+ @import "sm.css";
3
+ @import "lg.css";
@@ -0,0 +1,3 @@
1
+ .ui-title:where(.lg) {
2
+ --ui-title-font-size: 1.125rem;
3
+ }
@@ -0,0 +1,3 @@
1
+ .ui-title:where(.sm) {
2
+ --ui-title-font-size: 0.75rem;
3
+ }
package/src/ui/title.css CHANGED
@@ -1,20 +1 @@
1
- :where(.ui-title) {
2
- --ui-title-font-family: var(--font-secondary);
3
- --ui-title-font-weight: var(--font-semibold);
4
- --ui-title-font-size: 0.875rem;
5
- --ui-title-line-height: calc(var(--ui-heading-font-size) + var(--ui-heading-line-height-ratio));
6
- --ui-title-line-height-ratio: 0.375rem;
7
-
8
- font-family: var(--ui-title-font-family);
9
- font-size: var(--ui-title-font-size);
10
- line-height: var(--ui-title-line-height);
11
- font-weight: var(--ui-title-font-weight);
12
-
13
- &:where(.is-sm) {
14
- --ui-title-font-size: 0.75rem;
15
- }
16
-
17
- &:where(.is-lg) {
18
- --ui-title-font-size: 1.125rem;
19
- }
20
- }
1
+ @import "title/index.css";
@@ -5,6 +5,6 @@ module.exports = {
5
5
  './playground/**/*.{js,html,vue}'
6
6
  ],
7
7
  plugins: [
8
- require('winduum')()
8
+ require('./utils/tailwind.cjs')()
9
9
  ],
10
10
  }
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
3
4
 
4
5
  var plugin = require('tailwindcss/plugin');
5
6
  var twColors = require('tailwindcss/colors');
@@ -7,30 +8,31 @@ var lodash = require('lodash');
7
8
 
8
9
  const defaultConfig = {
9
10
  colors: [
10
- 'background', 'default', 'light', 'dark', 'primary', 'secondary',
11
- 'warning', 'error', 'info', 'success', 'accent', `current`
11
+ 'light', 'dark', 'primary', 'secondary',
12
+ 'warning', 'error', 'info', 'success', 'accent', 'current',
13
+ 'base', 'body', 'body-primary', 'body-secondary', 'body-tertiary'
12
14
  ],
13
15
  fontFamily: ['primary', 'secondary'],
14
16
  fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
15
17
  zIndex: [10, 20, 30, 40, 50, 60],
16
18
  spacing: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'section'],
17
19
  borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'full'],
18
- animations: ['fade-in', 'fade-out', 'ripple'],
20
+ animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
19
21
  screens: {
20
- 'xs': '22.5em',
21
- 'sm': '26em',
22
- 'md': '48em',
23
- 'lg': '60em',
24
- 'xl': '76em',
22
+ xs: '22.5em',
23
+ sm: '26em',
24
+ md: '48em',
25
+ lg: '60em',
26
+ xl: '76em',
25
27
  '2xl': '82em',
26
28
  '3xl': '88em',
27
29
  '4xl': '100em',
28
- 'xxl': '126em',
30
+ xxl: '126em',
29
31
  '2xxl': '158em'
30
32
  }
31
33
  };
32
34
 
33
- 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)
35
+ 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)
34
36
  .substring(1).match(/.{2}/g)
35
37
  .map(x => parseInt(x, 16));
36
38
 
@@ -42,9 +44,9 @@ const getTailwindColors = (twColors) => {
42
44
  return
43
45
  }
44
46
 
45
- if (typeof twColors[color] === "object") {
47
+ if (typeof twColors[color] === 'object') {
46
48
  Object.keys(twColors[color]).forEach(variant => {
47
- accentColors.push([`${color.replace(/[A-Z]/g, m => "-" + m.toLowerCase())}-${variant}`, twColors[color][variant]]);
49
+ accentColors.push([`${color.replace(/[A-Z]/g, m => '-' + m.toLowerCase())}-${variant}`, twColors[color][variant]]);
48
50
  });
49
51
  } else {
50
52
  accentColors.push([color, twColors[color]]);
@@ -58,9 +60,9 @@ const tailwindColors = (colors = []) => {
58
60
  colors.forEach(name => {
59
61
  colors[name] = ({ opacityValue }) => {
60
62
  if (opacityValue === undefined) {
61
- return `rgb(var(--color-${name}))`
63
+ return `rgb(var(--color-${name}-rgb))`
62
64
  }
63
- return `rgb(var(--color-${name}) / ${opacityValue})`
65
+ return `rgb(var(--color-${name}-rgb) / ${opacityValue})`
64
66
  };
65
67
  });
66
68
 
@@ -75,10 +77,12 @@ const tailwindColorsAccent = (colors = []) => {
75
77
  const rgb = hexToRgb(color[1]);
76
78
 
77
79
  result[`.accent-${color[0]}`] = {
78
- '--color-accent': `${rgb[0]} ${rgb[1]} ${rgb[2]}`
80
+ '--color-accent-rgb': `${rgb[0]} ${rgb[1]} ${rgb[2]}`,
81
+ '--color-accent': `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`
79
82
  };
80
83
  } else {
81
84
  result[`.accent-${color}`] = {
85
+ '--color-accent-rgb': `var(--color-${color}-rgb)`,
82
86
  '--color-accent': `var(--color-${color})`
83
87
  };
84
88
  }
@@ -130,10 +134,21 @@ const tailwindAnimations = (values) => {
130
134
  const createPlugin = (userConfig = {}) => {
131
135
  userConfig = lodash.merge(defaultConfig, userConfig);
132
136
 
133
- return plugin(({addUtilities}) => {
137
+ return plugin(({ addUtilities, theme, variants, e }) => {
134
138
  addUtilities(Object.assign(tailwindColorsAccent(getTailwindColors(twColors)), tailwindColorsAccent(userConfig.colors)));
135
139
  addUtilities(Object.assign(tailwindColorsCurrent(getTailwindColors(twColors)), tailwindColorsCurrent(userConfig.colors)));
136
140
  addUtilities(tailwindAnimations(userConfig.animations));
141
+ addUtilities([
142
+ Object.entries(theme('spacing')).map(([key, value]) => {
143
+ return {
144
+ [`.${e(`sq-${key}`)}`]: {
145
+ '--sq': `${value}`,
146
+ width: 'var(--sq)',
147
+ height: 'var(--sq)'
148
+ }
149
+ }
150
+ })
151
+ ], variants('sq'));
137
152
  }, {
138
153
  corePlugins: {
139
154
  preflight: false,
@@ -153,18 +168,18 @@ const createPlugin = (userConfig = {}) => {
153
168
  DEFAULT: 'var(--rounded)'
154
169
  }),
155
170
  screens: userConfig.screens
156
- },
171
+ }
157
172
  }
158
173
  })
159
174
  };
160
175
 
161
- module.exports.createPlugin = createPlugin;
162
- module.exports = createPlugin;
163
- module.exports.defaultConfig = defaultConfig;
164
- module.exports.getTailwindColors = getTailwindColors;
165
- module.exports.hexToRgb = hexToRgb;
166
- module.exports.tailwindAnimations = tailwindAnimations;
167
- module.exports.tailwindColors = tailwindColors;
168
- module.exports.tailwindColorsAccent = tailwindColorsAccent;
169
- module.exports.tailwindColorsCurrent = tailwindColorsCurrent;
170
- module.exports.tailwindVariables = tailwindVariables;
176
+ exports.createPlugin = createPlugin;
177
+ exports.default = createPlugin;
178
+ exports.defaultConfig = defaultConfig;
179
+ exports.getTailwindColors = getTailwindColors;
180
+ exports.hexToRgb = hexToRgb;
181
+ exports.tailwindAnimations = tailwindAnimations;
182
+ exports.tailwindColors = tailwindColors;
183
+ exports.tailwindColorsAccent = tailwindColorsAccent;
184
+ exports.tailwindColorsCurrent = tailwindColorsCurrent;
185
+ exports.tailwindVariables = tailwindVariables;
package/utils/tailwind.js CHANGED
@@ -1,34 +1,34 @@
1
1
  import plugin from 'tailwindcss/plugin'
2
- import twColors from "tailwindcss/colors"
2
+ import twColors from 'tailwindcss/colors'
3
3
  import lodash from 'lodash'
4
4
 
5
5
  export const defaultConfig = {
6
6
  colors: [
7
- 'default', 'light', 'dark', 'primary', 'secondary',
8
- 'warning', 'error', 'info', 'success', 'accent', `current`,
9
- 'background', 'background-lighter', 'background-darker'
7
+ 'light', 'dark', 'primary', 'secondary',
8
+ 'warning', 'error', 'info', 'success', 'accent', 'current',
9
+ 'base', 'body', 'body-primary', 'body-secondary', 'body-tertiary'
10
10
  ],
11
11
  fontFamily: ['primary', 'secondary'],
12
12
  fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
13
13
  zIndex: [10, 20, 30, 40, 50, 60],
14
14
  spacing: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'section'],
15
15
  borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', 'full'],
16
- animations: ['fade-in', 'fade-out', 'ripple'],
16
+ animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
17
17
  screens: {
18
- 'xs': '22.5em',
19
- 'sm': '26em',
20
- 'md': '48em',
21
- 'lg': '60em',
22
- 'xl': '76em',
18
+ xs: '22.5em',
19
+ sm: '26em',
20
+ md: '48em',
21
+ lg: '60em',
22
+ xl: '76em',
23
23
  '2xl': '82em',
24
24
  '3xl': '88em',
25
25
  '4xl': '100em',
26
- 'xxl': '126em',
26
+ xxl: '126em',
27
27
  '2xxl': '158em'
28
28
  }
29
29
  }
30
30
 
31
- export 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)
31
+ export 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)
32
32
  .substring(1).match(/.{2}/g)
33
33
  .map(x => parseInt(x, 16))
34
34
 
@@ -40,9 +40,9 @@ export const getTailwindColors = (twColors) => {
40
40
  return
41
41
  }
42
42
 
43
- if (typeof twColors[color] === "object") {
43
+ if (typeof twColors[color] === 'object') {
44
44
  Object.keys(twColors[color]).forEach(variant => {
45
- accentColors.push([`${color.replace(/[A-Z]/g, m => "-" + m.toLowerCase())}-${variant}`, twColors[color][variant]])
45
+ accentColors.push([`${color.replace(/[A-Z]/g, m => '-' + m.toLowerCase())}-${variant}`, twColors[color][variant]])
46
46
  })
47
47
  } else {
48
48
  accentColors.push([color, twColors[color]])
@@ -56,9 +56,9 @@ export const tailwindColors = (colors = []) => {
56
56
  colors.forEach(name => {
57
57
  colors[name] = ({ opacityValue }) => {
58
58
  if (opacityValue === undefined) {
59
- return `rgb(var(--color-${name}))`
59
+ return `rgb(var(--color-${name}-rgb))`
60
60
  }
61
- return `rgb(var(--color-${name}) / ${opacityValue})`
61
+ return `rgb(var(--color-${name}-rgb) / ${opacityValue})`
62
62
  }
63
63
  })
64
64
 
@@ -66,27 +66,29 @@ export const tailwindColors = (colors = []) => {
66
66
  }
67
67
 
68
68
  export const tailwindColorsAccent = (colors = []) => {
69
- const result = {};
69
+ const result = {}
70
70
 
71
71
  colors.forEach(color => {
72
72
  if (Array.isArray(color)) {
73
73
  const rgb = hexToRgb(color[1])
74
74
 
75
75
  result[`.accent-${color[0]}`] = {
76
- '--color-accent': `${rgb[0]} ${rgb[1]} ${rgb[2]}`
76
+ '--color-accent-rgb': `${rgb[0]} ${rgb[1]} ${rgb[2]}`,
77
+ '--color-accent': `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`
77
78
  }
78
79
  } else {
79
80
  result[`.accent-${color}`] = {
81
+ '--color-accent-rgb': `var(--color-${color}-rgb)`,
80
82
  '--color-accent': `var(--color-${color})`
81
83
  }
82
84
  }
83
85
  })
84
86
 
85
87
  return result
86
- };
88
+ }
87
89
 
88
90
  export const tailwindColorsCurrent = (colors = []) => {
89
- const result = {};
91
+ const result = {}
90
92
 
91
93
  colors.forEach(color => {
92
94
  if (Array.isArray(color)) {
@@ -103,7 +105,7 @@ export const tailwindColorsCurrent = (colors = []) => {
103
105
  })
104
106
 
105
107
  return result
106
- };
108
+ }
107
109
 
108
110
  export const tailwindVariables = (type, variables = [], values = {}) => {
109
111
  variables.forEach(name => {
@@ -128,10 +130,21 @@ export const tailwindAnimations = (values) => {
128
130
  export const createPlugin = (userConfig = {}) => {
129
131
  userConfig = lodash.merge(defaultConfig, userConfig)
130
132
 
131
- return plugin(({addUtilities}) => {
133
+ return plugin(({ addUtilities, theme, variants, e }) => {
132
134
  addUtilities(Object.assign(tailwindColorsAccent(getTailwindColors(twColors)), tailwindColorsAccent(userConfig.colors)))
133
135
  addUtilities(Object.assign(tailwindColorsCurrent(getTailwindColors(twColors)), tailwindColorsCurrent(userConfig.colors)))
134
136
  addUtilities(tailwindAnimations(userConfig.animations))
137
+ addUtilities([
138
+ Object.entries(theme('spacing')).map(([key, value]) => {
139
+ return {
140
+ [`.${e(`sq-${key}`)}`]: {
141
+ '--sq': `${value}`,
142
+ width: 'var(--sq)',
143
+ height: 'var(--sq)'
144
+ }
145
+ }
146
+ })
147
+ ], variants('sq'))
135
148
  }, {
136
149
  corePlugins: {
137
150
  preflight: false,
@@ -151,7 +164,7 @@ export const createPlugin = (userConfig = {}) => {
151
164
  DEFAULT: 'var(--rounded)'
152
165
  }),
153
166
  screens: userConfig.screens
154
- },
167
+ }
155
168
  }
156
169
  })
157
170
  }
@@ -1,106 +0,0 @@
1
- :where(.ui-checkbox, .ui-radio) {
2
- --ui-checkbox-width: 1.375rem;
3
- --ui-checkbox-font-size: 0.875rem;
4
- --ui-checkbox-gap: 0.625rem;
5
- --ui-checkbox-bg-raw: var(--color-background);
6
- --ui-checkbox-bg-opacity: 0.1;
7
- --ui-checkbox-border-color-raw: var(--color-current);
8
- --ui-checkbox-border-color-opacity: 0.2;
9
- --ui-checkbox-checked-bg-raw: var(--color-accent);
10
- --ui-checkbox-radius: 0.5rem;
11
- --ui-checkbox-icon: var(--icon-check);
12
- --ui-checkbox-icon-font-size: 1.125rem;
13
- --ui-checkbox-validity-font-size: 0.875rem;
14
- --ui-checkbox-validity-offset: 0.375rem;
15
- --ui-checkbox-box-shadow: none;
16
-
17
- display: flex;
18
- align-items: center;
19
- gap: 0 var(--ui-checkbox-gap);
20
- flex-wrap: wrap;
21
- width: max-content;
22
- font-size: var(--ui-checkbox-font-size);
23
-
24
- & :where(label[for], input) {
25
- cursor: pointer;
26
- }
27
-
28
- & a {
29
- color: rgb(var(--color-accent));
30
- text-decoration: underline;
31
- }
32
-
33
- & input {
34
- --color-current: var(--color-light);
35
-
36
- display: flex;
37
- width: var(--ui-checkbox-width);
38
- height: var(--ui-checkbox-width);
39
- background-color: rgb(var(--ui-checkbox-bg-raw) / var(--tw-bg-opacity, var(--ui-checkbox-bg-opacity)));
40
- border: 1px solid rgb(var(--ui-checkbox-border-color-raw) / var(--tw-border-opacity, var(--ui-checkbox-border-color-opacity)));
41
- border-radius: var(--ui-checkbox-radius);
42
- user-select: none;
43
- outline: none;
44
- justify-content: center;
45
- align-items: center;
46
- transition: var(--transition-border), var(--transition-background), var(--transition-shadow);
47
- box-shadow: var(--ui-checkbox-box-shadow);
48
- font-size: var(--ui-checkbox-icon-font-size);
49
-
50
- &::before {
51
- line-height: var(--ui-checkbox-icon-font-size);
52
- text-indent: 0;
53
- display: block;
54
- transition: var(--transition-color), var(--transition-opacity), var(--transition-transform);
55
- color: rgb(var(--color-current));
56
- content: "";
57
- background-color: currentColor;
58
- mask: var(--ui-checkbox-icon);
59
- opacity: 0;
60
- transform: scale(0);
61
- will-change: transform;
62
- width: 1em;
63
- height: 1em;
64
- }
65
-
66
- &:where(:required) {
67
- & + *::after {
68
- color: rgb(var(--color-error));
69
- content: " *";
70
- }
71
- }
72
-
73
- &:is(:hover, :focus-visible) {
74
- --ui-checkbox-bg-raw: var(--ui-checkbox-checked-bg-raw);
75
- --ui-checkbox-border-color-raw: var(--ui-checkbox-checked-bg-raw);
76
- --tw-border-opacity: 0.75;
77
- --tw-bg-opacity: 0.1;
78
- }
79
-
80
- &:focus {
81
- --ui-checkbox-box-shadow:
82
- 0 0 0 0 rgb(var(--color-current)),
83
- 0 0 0 3px rgb(var(--ui-checkbox-checked-bg-raw) / 0.2),
84
- 0 1px 2px 0 rgb(var(--color-current) / 0.05);
85
- }
86
-
87
- &:checked {
88
- --tw-border-opacity: 0;
89
-
90
- background-color: rgb(var(--ui-checkbox-checked-bg-raw));
91
-
92
- &::before {
93
- opacity: 1;
94
- transform: scale(1);
95
- }
96
- }
97
- }
98
-
99
- &.is-invalid, .is-validated & :where(input):invalid {
100
- --ui-checkbox-bg-raw: var(--color-error);
101
- --ui-checkbox-border-color-raw: var(--color-error);
102
- --ui-checkbox-checked-bg-raw: var(--color-error);
103
- --color-current: var(--color-error);
104
- --tw-border-opacity: 1;
105
- }
106
- }
package/src/ui/radio.css DELETED
@@ -1,4 +0,0 @@
1
- :where(.ui-radio) {
2
- --ui-checkbox-icon: var(--icon-radio);
3
- --ui-checkbox-radius: 50%;
4
- }
package/src/ui/select.css DELETED
@@ -1,27 +0,0 @@
1
- :where(.ui-select) {
2
- --ui-input-icon-select-icon-font-size: 1.5rem;
3
- --ui-input-icon-count-r: 2;
4
- --ui-input-pr: var(--ui-input-icon-offset-r);
5
-
6
- & :where([class^="icon-"]) {
7
- margin-right: calc(var(--ui-input-icon-font-size) + var(--ui-input-icon-gap));
8
- }
9
-
10
- &::after {
11
- width: 1em;
12
- height: 1em;
13
- background-color: currentColor;
14
- content: "";
15
- position: absolute;
16
- z-index: 1;
17
- font-size: var(--ui-input-icon-select-icon-font-size);
18
- right: calc(var(--ui-input-height) / 4);
19
- top: calc(var(--ui-input-height) / 2);
20
- margin-top: calc(var(--ui-input-icon-select-icon-font-size) / 2 * -1);
21
- will-change: transform;
22
- transition: transform 200ms;
23
- mask: var(--icon-angle-down);
24
- pointer-events: none;
25
- grid-area: input;
26
- }
27
- }