winduum 0.2.0-beta.9 → 0.2.2-next.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 (43) hide show
  1. package/dist/main-rgb.css +1 -1
  2. package/dist/main.css +1 -1
  3. package/dist/tailwind.css +1 -1
  4. package/package.json +11 -5
  5. package/src/base/config.css +37 -17
  6. package/src/base/default.css +8 -2
  7. package/src/base/theme/dark-rgb.css +1 -1
  8. package/src/base/theme/dark.css +1 -6
  9. package/src/base/theme/default-rgb.css +10 -5
  10. package/src/base/theme/default.css +16 -15
  11. package/src/components/dialog.css +1 -1
  12. package/src/ui/badge/default-rgb.css +3 -3
  13. package/src/ui/badge/default.css +4 -4
  14. package/src/ui/badge/index.css +0 -1
  15. package/src/ui/btn/default-rgb.css +3 -3
  16. package/src/ui/btn/default.css +6 -6
  17. package/src/ui/btn/gradient-bordered-rgb.css +1 -1
  18. package/src/ui/btn/gradient-bordered.css +1 -1
  19. package/src/ui/btn/index.css +0 -1
  20. package/src/ui/btn/loading.css +1 -1
  21. package/src/ui/btn/raised.css +1 -1
  22. package/src/ui/check-rgb.css +2 -3
  23. package/src/ui/check.css +3 -4
  24. package/src/ui/control/default-rgb.css +2 -2
  25. package/src/ui/control/default.css +3 -3
  26. package/src/ui/control/floating-focus.css +2 -0
  27. package/src/ui/control/floating.css +0 -1
  28. package/src/ui/control/index.css +0 -1
  29. package/src/ui/{control/group.css → group.css} +14 -7
  30. package/src/ui/image.css +1 -1
  31. package/src/ui/index.css +1 -0
  32. package/src/ui/link/default.css +2 -2
  33. package/src/ui/link/underlined.css +2 -1
  34. package/src/ui/notice.css +1 -2
  35. package/src/ui/switch-rgb.css +1 -1
  36. package/src/ui/switch.css +2 -2
  37. package/src/ui/text-rgb.css +2 -2
  38. package/src/ui/text.css +8 -8
  39. package/tailwind.config.cjs +1 -1
  40. package/utils/tailwind.cjs +109 -42
  41. package/utils/tailwind.js +107 -40
  42. package/src/ui/badge/group.css +0 -16
  43. package/src/ui/btn/group.css +0 -18
@@ -1,5 +1,5 @@
1
1
  :is(.ui-btn.gradient-bordered) {
2
- --color-current-rgb: var(--color-base-rgb);
2
+ --color-body-current-rgb: var(--color-body-current-rgb);
3
3
 
4
4
  &::before {
5
5
  background-color: rgb(var(--color-body-rgb) / calc(100% - var(--ui-btn-bg-opacity)));
@@ -6,7 +6,7 @@
6
6
  --ui-btn-active-bg-opacity: 20%;
7
7
  --ui-btn-focus-outline-offset: 0;
8
8
  --ui-btn-bg-opacity: 0%;
9
- --color-current: var(--color-base);
9
+ --color-body-current: var(--color-main);
10
10
 
11
11
  &::before {
12
12
  content: "";
@@ -11,4 +11,3 @@
11
11
  @import "raised.css";
12
12
  @import "square.css";
13
13
  @import "circle.css";
14
- @import "group.css";
@@ -14,7 +14,7 @@
14
14
  width: var(--ui-btn-loading-width);
15
15
  height: var(--ui-btn-loading-width);
16
16
  content: "";
17
- border: var(--ui-btn-loading-border-width) solid var(--color-current);
17
+ border: var(--ui-btn-loading-border-width) solid var(--color-body-current);
18
18
  border-right-color: transparent;
19
19
  border-radius: 50%;
20
20
  animation: spin 0.45s infinite linear;
@@ -2,7 +2,7 @@
2
2
  --ui-btn-border-width: 2px;
3
3
  --ui-btn-border-opacity: calc(var(--tw-border-opacity, 0.85) * 100%);
4
4
 
5
- border: var(--ui-btn-border-width) solid color-mix(in sRGB, var(--color-accent) var(--ui-btn-border-opacity), var(--color-current));
5
+ border: var(--ui-btn-border-width) solid color-mix(in sRGB, var(--color-accent) var(--ui-btn-border-opacity), var(--color-body-current));
6
6
  padding-left: calc(var(--ui-btn-px) - var(--ui-btn-border-width));
7
7
  padding-right: calc(var(--ui-btn-px) - var(--ui-btn-border-width));
8
8
  }
@@ -1,6 +1,6 @@
1
1
  .ui-check {
2
2
  --ui-check-bg: var(--color-body-rgb);
3
- --ui-check-border-color: var(--color-current-rgb);
3
+ --ui-check-border-color: var(--color-body-current-rgb);
4
4
  --ui-check-checked-bg: var(--color-accent-rgb);
5
5
 
6
6
  & :where(input) {
@@ -14,7 +14,7 @@
14
14
  }
15
15
 
16
16
  &:disabled {
17
- --ui-check-bg: var(--color-current-rgb);
17
+ --ui-check-bg: var(--color-body-current-rgb);
18
18
  }
19
19
 
20
20
  &:checked {
@@ -23,7 +23,6 @@
23
23
  }
24
24
 
25
25
  &.invalid, .validated & :where(input):invalid {
26
- --color-current-rgb: var(--color-error-rgb);
27
26
  --ui-check-bg: var(--color-error-rgb);
28
27
  --ui-check-border-color: var(--color-error-rgb);
29
28
  --ui-check-checked-bg: var(--color-error-rgb);
package/src/ui/check.css CHANGED
@@ -2,10 +2,10 @@
2
2
  --ui-check-width: 1.375rem;
3
3
  --ui-check-font-size: 0.875rem;
4
4
  --ui-check-gap: 0.625rem;
5
- --ui-check-bg: var(--color-body);
5
+ --ui-check-bg: transparent;
6
6
  --ui-check-bg-mix: transparent;
7
7
  --ui-check-bg-opacity: calc(var(--tw-bg-opacity, 0.1) * 100%);
8
- --ui-check-border-color: var(--color-current);
8
+ --ui-check-border-color: var(--color-body-current);
9
9
  --ui-check-border-mix: transparent;
10
10
  --ui-check-border-opacity: calc(var(--tw-border-opacity, 0.2) * 100%);
11
11
  --ui-check-border-width: 1px;
@@ -102,7 +102,7 @@
102
102
 
103
103
  &:disabled {
104
104
  --ui-check-bg-opacity: 15%;
105
- --ui-check-bg: var(--color-current);
105
+ --ui-check-bg: var(--color-body-current);
106
106
 
107
107
  cursor: not-allowed;
108
108
  opacity: var(--ui-check-disabled-opacity);
@@ -121,7 +121,6 @@
121
121
  }
122
122
 
123
123
  &.invalid, .validated & :where(input):invalid {
124
- --color-current: var(--color-error);
125
124
  --ui-check-bg: var(--color-error);
126
125
  --ui-check-border-color: var(--color-error);
127
126
  --ui-check-checked-bg: var(--color-error);
@@ -1,5 +1,5 @@
1
1
  .ui-control {
2
- --ui-control-border-color: var(--color-current-rgb);
2
+ --ui-control-border-color: var(--color-body-current-rgb);
3
3
 
4
4
  & :where(input, textarea, select) {
5
5
  border: var(--ui-control-border-width) solid rgb(var(--ui-control-border-color) / var(--ui-control-border-opacity));
@@ -11,7 +11,7 @@
11
11
  }
12
12
 
13
13
  &:disabled {
14
- background-color: rgb(var(--color-base-rgb) / var(--ui-control-disabled-opacity));
14
+ background-color: rgb(var(--color-main-rgb) / var(--ui-control-disabled-opacity));
15
15
  }
16
16
  }
17
17
 
@@ -7,14 +7,14 @@
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;
14
14
  --ui-control-font-size: 0.875rem;
15
15
  --ui-control-font-weight: var(--font-medium);
16
16
  --ui-control-border-width: 1px;
17
- --ui-control-border-color: var(--color-current);
17
+ --ui-control-border-color: var(--color-body-current);
18
18
  --ui-control-border-mix: transparent;
19
19
  --ui-control-border-opacity: 15%;
20
20
  --ui-control-border-radius: var(--rounded);
@@ -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-body-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;
@@ -3,4 +3,3 @@
3
3
  @import "icon.css";
4
4
  @import "floating.css";
5
5
  @import "floating-focus.css";
6
- @import "group.css";
@@ -1,12 +1,19 @@
1
- .ui-control-group {
1
+ .ui-group {
2
2
  display: flex;
3
3
  flex-wrap: wrap;
4
4
 
5
- & :where(.ui-btn) {
6
- --ui-btn-border-width: 1px;
7
- --ui-btn-height: 3rem;
8
- --ui-btn-outline-offset: 0;
9
- --ui-btn-border-opacity: 15%;
5
+ &:has(.ui-control) {
6
+ :where(.ui-btn) {
7
+ --ui-btn-border-width: 1px;
8
+ --ui-btn-border-opacity: 15%;
9
+ --ui-btn-height: auto;
10
+
11
+ min-width: 3rem;
12
+ }
13
+ }
14
+
15
+ :where(.ui-btn) {
16
+ --ui-btn-focus-outline-offset: 0;
10
17
  }
11
18
 
12
19
  & > * {
@@ -14,7 +21,7 @@
14
21
  border-top-left-radius: 0;
15
22
  border-bottom-left-radius: 0;
16
23
 
17
- &, :where(input, select) {
24
+ &, & :where(input, select) {
18
25
  border-left: 0;
19
26
  }
20
27
  }
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%;
package/src/ui/index.css CHANGED
@@ -2,6 +2,7 @@
2
2
  @import "btn/index.css";
3
3
  @import "check.css";
4
4
  @import "control.css";
5
+ @import "group.css";
5
6
  @import "heading.css";
6
7
  @import "image.css";
7
8
  @import "info.css";
@@ -1,11 +1,10 @@
1
1
  .ui-link {
2
- --color-accent: var(--color-current);
3
2
  --ui-link-font-size: 0.875rem;
4
3
  --ui-link-font-weight: var(--font-medium);
5
4
  --ui-link-letter-spacing: 0;
6
5
  --ui-link-hover-color: var(--color-accent);
7
6
  --ui-link-hover-opacity: 0.75;
8
- --ui-link-active-opacity: 0.75;
7
+ --ui-link-active-opacity: 1;
9
8
  --ui-link-gap: 0.5rem;
10
9
 
11
10
  font-size: var(--ui-link-font-size);
@@ -27,6 +26,7 @@
27
26
 
28
27
  &:focus-visible {
29
28
  color: var(--ui-link-hover-color);
29
+ opacity: var(--ui-link-hover-opacity);
30
30
  }
31
31
 
32
32
  &: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) {
@@ -5,7 +5,7 @@
5
5
  }
6
6
 
7
7
  &:checked {
8
- --color-current-rgb: var(--color-accent-rgb);
8
+ --color-body-current-rgb: var(--color-accent-rgb);
9
9
  }
10
10
  }
11
11
  }
package/src/ui/switch.css CHANGED
@@ -65,12 +65,12 @@
65
65
  }
66
66
 
67
67
  &:focus {
68
- outline-color: color-mix(in sRGB, var(--color-current) var(--ui-switch-outline-opacity), transparent);
68
+ outline-color: color-mix(in sRGB, var(--color-body-current) var(--ui-switch-outline-opacity), transparent);
69
69
  outline-offset: var(--ui-switch-outline-offset);
70
70
  }
71
71
 
72
72
  &:checked {
73
- --color-current: var(--color-accent);
73
+ --color-body-current: var(--color-accent);
74
74
  --ui-switch-bg: var(--color-accent);
75
75
 
76
76
  &::before {
@@ -1,12 +1,12 @@
1
1
  .ui-text {
2
2
  & :where(table) {
3
3
  & :where(thead) {
4
- border-bottom: 1px solid rgb(var(--color-current-rgb) / 7.5%);
4
+ border-bottom: 1px solid rgb(var(--color-body-current-rgb) / 7.5%);
5
5
  }
6
6
 
7
7
  & :where(tbody tr) {
8
8
  &:nth-of-type(even) {
9
- background-color: rgb(var(--color-current-rgb) / 5%);
9
+ background-color: rgb(var(--color-body-current-rgb) / 5%);
10
10
  }
11
11
  }
12
12
  }
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;
@@ -117,12 +117,12 @@
117
117
 
118
118
  & :where(thead) {
119
119
  font-weight: var(--ui-text-weight-bold);
120
- border-bottom: 1px solid color-mix(in sRGB, var(--color-current) 7.5%, transparent);
120
+ border-bottom: 1px solid color-mix(in sRGB, var(--color-body-current) 7.5%, transparent);
121
121
  }
122
122
 
123
123
  & :where(tbody tr) {
124
124
  &:nth-of-type(even) {
125
- background-color: color-mix(in sRGB, var(--color-current) 5%, transparent);
125
+ background-color: color-mix(in sRGB, var(--color-body-current) 5%, transparent);
126
126
  }
127
127
  }
128
128
  }
@@ -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,57 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
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');
6
9
  var twColors = require('tailwindcss/colors');
7
10
  var lodash = require('lodash');
8
11
 
12
+ function withAlphaVariable ({ color: color$1, property, variable }) {
13
+ const properties = [].concat(property);
14
+ if (typeof color$1 === 'function') {
15
+ return {
16
+ ...Object.fromEntries(
17
+ properties.map((p) => {
18
+ return [p, color$1({ opacityVariable: variable, opacityValue: `var(${variable}, 1)` })]
19
+ })
20
+ )
21
+ }
22
+ }
23
+
24
+ const parsed = color.parseColor(color$1);
25
+
26
+ if (parsed === null) {
27
+ return Object.fromEntries(properties.map((p) => [p, color$1]))
28
+ }
29
+
30
+ if (parsed.alpha !== undefined) {
31
+ // Has an alpha value, return color as-is
32
+ return Object.fromEntries(properties.map((p) => [p, color$1]))
33
+ }
34
+
35
+ return {
36
+ ...Object.fromEntries(
37
+ properties.map((p) => {
38
+ return [p, color.formatColor({ ...parsed, alpha: `var(${variable}, 1)` })]
39
+ })
40
+ )
41
+ }
42
+ }
43
+
9
44
  const defaultConfig = {
10
45
  colors: [
11
- 'light', 'dark', 'primary',
12
- 'warning', 'error', 'info', 'success', 'accent', 'current',
13
- 'base', 'base-primary', 'base-secondary', 'base-tertiary',
46
+ 'primary', 'accent',
47
+ 'warning', 'error', 'info', 'success', 'light', 'dark',
48
+ 'main', 'main-primary', 'main-secondary', 'main-tertiary',
14
49
  'body', 'body-primary', 'body-secondary', 'body-tertiary'
15
50
  ],
16
51
  fontFamily: ['primary', 'secondary'],
17
52
  fontWeight: ['light', 'normal', 'medium', 'semibold', 'bold', 'extrabold'],
18
53
  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'],
54
+ fontSize: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '3xl', '4xl', '5xl', '6xl', '7xl', '7xl', '8xl', '9xl'],
55
+ spacing: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'section'],
56
+ borderRadius: ['xs', 'sm', 'base', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', 'full'],
21
57
  animations: ['fade-in', 'fade-out', 'fade-in-down', 'fade-out-up', 'ripple', 'spin', 'move-indeterminate'],
22
58
  screens: {
23
59
  xs: '22.5em',
@@ -30,6 +66,9 @@ const defaultConfig = {
30
66
  '4xl': '100em',
31
67
  xxl: '126em',
32
68
  '2xxl': '158em'
69
+ },
70
+ settings: {
71
+ rgbFallback: true
33
72
  }
34
73
  };
35
74
 
@@ -59,12 +98,11 @@ const getTailwindColors = (twColors) => {
59
98
 
60
99
  const tailwindColors = (colors = []) => {
61
100
  colors.forEach(name => {
62
- colors[name] = ({ opacityValue }) => {
63
- if (opacityValue === undefined) {
64
- return `rgb(var(--color-${name}-rgb))`
65
- }
66
- return `rgb(var(--color-${name}-rgb) / ${opacityValue})`
67
- };
101
+ if (defaultConfig.settings.rgbFallback) {
102
+ colors[name + '-rgb'] = `rgb(var(--color-${name}-rgb) / <alpha-value>)`;
103
+ }
104
+
105
+ colors[name] = `color-mix(in sRGB, var(--color-${name}) calc(<alpha-value> * 100%), transparent)`;
68
106
  });
69
107
 
70
108
  return colors
@@ -77,46 +115,42 @@ const tailwindColorsAccent = (colors = []) => {
77
115
  if (Array.isArray(color)) {
78
116
  const rgb = hexToRgb(color[1]);
79
117
 
80
- result[`.accent-${color[0]}`] = {
81
- '--color-accent-rgb': `${rgb[0]} ${rgb[1]} ${rgb[2]}`,
118
+ result[`.accent-${color[0]}`] = Object.assign(defaultConfig.settings.rgbFallback
119
+ ? {
120
+ '--color-accent-rgb': `${rgb[0]} ${rgb[1]} ${rgb[2]}`,
121
+ '--color-accent-current-rgb': `var(--color-${color}-current-rgb, var(--color-light-rgb))`
122
+ }
123
+ : {}, {
82
124
  '--color-accent': `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`,
83
125
  '--color-accent-current': `var(--color-${color}-current, var(--color-light))`
84
- };
126
+ });
85
127
  } else {
86
- result[`.accent-${color}`] = {
87
- '--color-accent-rgb': `var(--color-${color}-rgb)`,
128
+ result[`.accent-${color}`] = Object.assign(defaultConfig.settings.rgbFallback
129
+ ? {
130
+ '--color-accent-rgb': `var(--color-${color}-rgb)`,
131
+ '--color-accent-current-rgb': `var(--color-${color}-current-rgb, var(--color-light-rgb))`
132
+ }
133
+ : {}, {
88
134
  '--color-accent': `var(--color-${color})`,
89
135
  '--color-accent-current': `var(--color-${color}-current, var(--color-light))`
90
- };
136
+ });
91
137
  }
92
138
  });
93
139
 
94
140
  return result
95
141
  };
96
142
 
97
- const tailwindColorsCurrent = (colors = []) => {
98
- const result = {};
99
-
100
- colors.forEach(color => {
101
- if (Array.isArray(color)) {
102
- const rgb = hexToRgb(color[1]);
103
-
104
- result[`.text-${color[0]}`] = {
105
- '--color-current': `${rgb[0]} ${rgb[1]} ${rgb[2]}`
106
- };
107
- } else {
108
- result[`.text-${color}`] = {
109
- '--color-current': `var(--color-${color})`
110
- };
111
- }
143
+ const tailwindVariables = (type, variables = [], values = {}) => {
144
+ variables.forEach(name => {
145
+ values[name] = `var(--${type}-${name})`;
112
146
  });
113
147
 
114
- return result
148
+ return values
115
149
  };
116
150
 
117
- const tailwindVariables = (type, variables = [], values = {}) => {
151
+ const tailwindVariablesFont = (type, variables = [], values = {}) => {
118
152
  variables.forEach(name => {
119
- values[name] = `var(--${type}-${name})`;
153
+ values[name] = [`var(--${type}-${name})`, `calc(var(--${type}-${name}) + 0.5rem)`];
120
154
  });
121
155
 
122
156
  return values
@@ -137,17 +171,48 @@ const tailwindAnimations = (values) => {
137
171
  const createPlugin = (userConfig = {}) => {
138
172
  userConfig = lodash.merge(defaultConfig, userConfig);
139
173
 
140
- return plugin(({ addUtilities, theme, variants, e }) => {
174
+ return plugin(({ addUtilities, matchUtilities, theme, variants, e, corePlugins }) => {
141
175
  addUtilities(Object.assign(tailwindColorsAccent(getTailwindColors(twColors)), tailwindColorsAccent(userConfig.colors)));
142
- addUtilities(Object.assign(tailwindColorsCurrent(getTailwindColors(twColors)), tailwindColorsCurrent(userConfig.colors)));
176
+ matchUtilities(
177
+ {
178
+ text: (value, extra) => {
179
+ const matchValue = toColorValue(value).match(/var\((.*?)\)/);
180
+ const fallbackRgb = matchValue && matchValue[0].includes('-rgb');
181
+
182
+ const colorProperties = {};
183
+
184
+ if (fallbackRgb) {
185
+ colorProperties['--color-body-current-rgb'] = matchValue[0];
186
+ }
187
+
188
+ if (!corePlugins('textOpacity')) {
189
+ return {
190
+ ...colorProperties,
191
+ '--color-body-current': toColorValue(value),
192
+ color: toColorValue(value)
193
+ }
194
+ }
195
+
196
+ return {
197
+ ...colorProperties,
198
+ '--color-body-current': toColorValue(value),
199
+ ...withAlphaVariable({
200
+ color: value,
201
+ property: 'color',
202
+ variable: '--tw-text-opacity'
203
+ })
204
+ }
205
+ }
206
+ },
207
+ { values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
208
+ );
143
209
  addUtilities(tailwindAnimations(userConfig.animations));
144
210
  addUtilities([
145
211
  Object.entries(theme('spacing')).map(([key, value]) => {
146
212
  return {
147
213
  [`.${e(`sq-${key}`)}`]: {
148
- '--sq': `${value}`,
149
- width: 'var(--sq)',
150
- height: 'var(--sq)'
214
+ width: value,
215
+ height: value
151
216
  }
152
217
  }
153
218
  })
@@ -155,11 +220,13 @@ const createPlugin = (userConfig = {}) => {
155
220
  }, {
156
221
  corePlugins: {
157
222
  preflight: false,
158
- container: false
223
+ container: false,
224
+ textColor: false
159
225
  },
160
226
  theme: {
161
227
  extend: {
162
228
  colors: tailwindColors(userConfig.colors),
229
+ fontSize: tailwindVariablesFont('text', userConfig.fontSize),
163
230
  fontFamily: tailwindVariables('font', userConfig.fontFamily),
164
231
  fontWeight: tailwindVariables('font', userConfig.fontWeight),
165
232
  zIndex: tailwindVariables('z', userConfig.zIndex, {
@@ -184,5 +251,5 @@ exports.hexToRgb = hexToRgb;
184
251
  exports.tailwindAnimations = tailwindAnimations;
185
252
  exports.tailwindColors = tailwindColors;
186
253
  exports.tailwindColorsAccent = tailwindColorsAccent;
187
- exports.tailwindColorsCurrent = tailwindColorsCurrent;
188
254
  exports.tailwindVariables = tailwindVariables;
255
+ exports.tailwindVariablesFont = tailwindVariablesFont;