@brightspot/ui 0.0.0-alpha.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.
- package/README.md +153 -0
- package/dist/lucide-static.d.ts +1 -0
- package/dist/tailwind-plugin-badge.js +68 -0
- package/dist/tailwind-plugin-badge.ts +103 -0
- package/dist/tailwind-plugin-button.js +223 -0
- package/dist/tailwind-plugin-button.ts +244 -0
- package/dist/tailwind-plugin-heading.js +51 -0
- package/dist/tailwind-plugin-heading.ts +54 -0
- package/dist/tailwind-plugin-icon.js +247 -0
- package/dist/tailwind-plugin-icon.ts +280 -0
- package/dist/tailwind-plugin-loader.js +31 -0
- package/dist/tailwind-plugin-loader.ts +34 -0
- package/dist/tailwind-plugin-scroll-shadow.js +77 -0
- package/dist/tailwind-plugin-scroll-shadow.ts +86 -0
- package/dist/tailwind-plugin-theme.js +48 -0
- package/dist/tailwind-plugin-theme.ts +73 -0
- package/dist/tailwind.config.js +567 -0
- package/dist/tailwind.config.ts +582 -0
- package/package.json +33 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin'
|
|
2
|
+
import { CSSRuleObject } from 'tailwindcss/types/config'
|
|
3
|
+
declare let module: any
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Buttons communicate actions that users can take such as submit a form, begin a new task,
|
|
7
|
+
* trigger a new UI element to appear or take a new or next step in some process.
|
|
8
|
+
*
|
|
9
|
+
* Class Names:
|
|
10
|
+
*
|
|
11
|
+
* btu-button - Establishes a default button container
|
|
12
|
+
* btu-button-[fill-none | container-none | outline | text-hidden] - Different types of buttons like solid,
|
|
13
|
+
* outline, icon buttons etc
|
|
14
|
+
* btu-button-[sm|md|lg|xl|2xl] - Size of buttons
|
|
15
|
+
* btu-button-[$theme-colors] - Color of buttons
|
|
16
|
+
* - required if using btu-button-outline to see outline
|
|
17
|
+
* btu-button-[pressed | disabled] - States of buttons (active or disabled)
|
|
18
|
+
*
|
|
19
|
+
* Example Usages:
|
|
20
|
+
*
|
|
21
|
+
* Publish button in content edit page -> btu-button btu-button-primary btu-button-sm
|
|
22
|
+
*
|
|
23
|
+
* Search toolbar icon button -> btu-button btu-button-text-hidden btu-button-fill-none
|
|
24
|
+
* btu-button-gray before:btu-icon before:btu-icon-search
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
module.exports = plugin(function ({ addComponents, addUtilities, theme }) {
|
|
28
|
+
const textSizes: Record<string, [string, string]> = theme('fontSize')
|
|
29
|
+
const colors: CSSRuleObject = theme('colors') || {}
|
|
30
|
+
const iconSizes: CSSRuleObject = theme('iconSize') || {}
|
|
31
|
+
const prefix = '.btu-button'
|
|
32
|
+
|
|
33
|
+
const disabledStyle: CSSRuleObject = {
|
|
34
|
+
'--button-bg-gradient': 'none',
|
|
35
|
+
'--button-disabled-color': `var(--button-disabled-color-fill-none, var(--button-disabled-color-fill, oklch(var(--btu-theme-gray-100))))`,
|
|
36
|
+
'--button-disabled-text-color': `var(--button-disabled-text-color-fill-none, var(--button-text-color, oklch(var(--btu-theme-gray-400))))`,
|
|
37
|
+
pointerEvents: 'none',
|
|
38
|
+
userSelect: 'none',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const activeStyle: CSSRuleObject = {
|
|
42
|
+
'--button-pressed': ' ',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const components: CSSRuleObject = {
|
|
46
|
+
'.btu-button': {
|
|
47
|
+
// default button
|
|
48
|
+
'--button-bg-gradient': 'none',
|
|
49
|
+
'--button-color': '',
|
|
50
|
+
'--button-text-color': '',
|
|
51
|
+
'--button-pressed': 'initial',
|
|
52
|
+
'--button-fill-none': 'initial',
|
|
53
|
+
'--button-padding-xs': '0.25rem 0.5rem',
|
|
54
|
+
'--button-padding-sm': '0.5rem 0.875rem',
|
|
55
|
+
'--button-padding-md': '0.625rem 1rem',
|
|
56
|
+
'--button-padding-lg': '0.625rem 1.125rem',
|
|
57
|
+
'--button-padding-xl': '0.75rem 1.25rem',
|
|
58
|
+
'--button-padding-2xl': '1rem 1.75rem',
|
|
59
|
+
'--button-font-size': textSizes['sm'][0],
|
|
60
|
+
'--button-line-height': textSizes['sm'][1],
|
|
61
|
+
display: 'inline-flex',
|
|
62
|
+
cursor: 'pointer',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
gap: '0.5rem',
|
|
66
|
+
background:
|
|
67
|
+
'var(--button-bg-gradient), var(--button-pressed-color, var(--button-disabled-color, var(--button-color)))',
|
|
68
|
+
borderRadius: 'var(--button-border-radius, 0.5rem)',
|
|
69
|
+
color:
|
|
70
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
71
|
+
padding: 'var(--button-padding-sm)',
|
|
72
|
+
fontSize: 'var(--button-font-size)',
|
|
73
|
+
lineHeight: 'var(--button-line-height)',
|
|
74
|
+
fontWeight: theme('fontWeight.semibold'),
|
|
75
|
+
position: 'relative',
|
|
76
|
+
height: 'var(--button-size-sm, auto)',
|
|
77
|
+
width: 'var(--button-size-sm, auto)',
|
|
78
|
+
'&[aria-pressed="true"]': activeStyle,
|
|
79
|
+
'&:disabled': disabledStyle,
|
|
80
|
+
'&[disabled]': disabledStyle,
|
|
81
|
+
textDecoration: 'none',
|
|
82
|
+
'&:focus': {
|
|
83
|
+
color:
|
|
84
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
85
|
+
},
|
|
86
|
+
'&:hover': {
|
|
87
|
+
color:
|
|
88
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
'.btu-button-text-hidden': {
|
|
92
|
+
'--button-padding-xs': '0.25rem',
|
|
93
|
+
'--button-padding-sm': '0.5rem',
|
|
94
|
+
'--button-padding-md': '0.625rem',
|
|
95
|
+
'--button-padding-lg': '0.75rem',
|
|
96
|
+
'--button-padding-xl': '0.875rem',
|
|
97
|
+
'--button-padding-2xl': '1rem',
|
|
98
|
+
'--button-icon-font-size': '0px',
|
|
99
|
+
'--button-icon-line-height': '1',
|
|
100
|
+
'--button-font-size': 'var(--button-icon-font-size)',
|
|
101
|
+
'--button-line-height': 'var(--button-icon-line-height)',
|
|
102
|
+
'--button-size-xs': '1.75rem',
|
|
103
|
+
'--button-size-sm': '2.25rem',
|
|
104
|
+
'--button-size-md': '2.5rem',
|
|
105
|
+
'--button-size-lg': '2.75rem',
|
|
106
|
+
'--button-size-xl': '3rem',
|
|
107
|
+
'--button-size-2xl': '3.5rem',
|
|
108
|
+
overflow: 'hidden',
|
|
109
|
+
gap: '0',
|
|
110
|
+
},
|
|
111
|
+
'.btu-button-outline': {
|
|
112
|
+
'--button-outline-offset-width': '1px',
|
|
113
|
+
'--button-outline-offset-color': 'var(--button-outline-color)',
|
|
114
|
+
outline: '1px solid var(--button-outline-color)',
|
|
115
|
+
'&:focus-visible': {
|
|
116
|
+
outline: 'none',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
'.btu-button-fill-none': {
|
|
120
|
+
'--button-fill-none': ' ',
|
|
121
|
+
backgroundColor:
|
|
122
|
+
'var(--button-pressed-color, var(--button-fill-none-color))',
|
|
123
|
+
color:
|
|
124
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
125
|
+
'&:focus': {
|
|
126
|
+
color:
|
|
127
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
128
|
+
},
|
|
129
|
+
'&:hover': {
|
|
130
|
+
color:
|
|
131
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
'.btu-button-disabled': disabledStyle,
|
|
135
|
+
'.btu-button-pressed': activeStyle,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// background & text colors for buttons in different states
|
|
139
|
+
for (const key in colors) {
|
|
140
|
+
if (
|
|
141
|
+
key === 'currentColor' ||
|
|
142
|
+
key === 'transparent' ||
|
|
143
|
+
key === 'white' ||
|
|
144
|
+
key === 'black'
|
|
145
|
+
)
|
|
146
|
+
continue
|
|
147
|
+
const focusStyle: CSSRuleObject = {
|
|
148
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'success' ? '700' : '600'}))`,
|
|
149
|
+
'--button-fill-none-color': `transparent`,
|
|
150
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '700' : '600'}))`,
|
|
151
|
+
'--tw-ring-opacity': '1',
|
|
152
|
+
'--tw-ring-color': `oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-100))`,
|
|
153
|
+
'--tw-ring-offset-width': '1px',
|
|
154
|
+
'--tw-ring-offset-color': `${key === 'gray' ? 'oklch(var(--btu-theme-primary-800))' : 'var(--button-outline-offset-color, var(--button-color))'}`,
|
|
155
|
+
}
|
|
156
|
+
components[prefix + '-' + key] = {
|
|
157
|
+
'--button-bg-gradient': `var(--button-fill-none, ${key === 'primary' ? theme('colors.primary.gradient') : 'none'})`,
|
|
158
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'success' ? '700' : '600'}))`,
|
|
159
|
+
'--button-text-color': `${key === 'gray' ? 'oklch(var(--btu-theme-gray-700))' : 'var(--btu-theme-white)'}`,
|
|
160
|
+
'--button-fill-none-color': 'transparent',
|
|
161
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '700' : '600'}))`,
|
|
162
|
+
'--button-outline-color': `oklch(var(--btu-theme-${key}-300))`,
|
|
163
|
+
'--button-disabled-color-fill': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'primary' ? '300' : '200'}))`,
|
|
164
|
+
'--button-disabled-color-fill-none': `var(--button-fill-none) oklch(var(--btu-theme-white))`,
|
|
165
|
+
'--button-disabled-text-color-fill-none': `var(--button-fill-none) oklch(var(--btu-theme-${key}-${key === 'gray' ? '400' : '300'}))`,
|
|
166
|
+
'--button-pressed-color': `var(--button-pressed) var(--button-disabled-color, oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-50)))`,
|
|
167
|
+
'--button-pressed-text-color': `var(--button-pressed) var(--button-disabled-text-color, oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-800)))`,
|
|
168
|
+
'&:hover': {
|
|
169
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '200' : key === 'success' ? '800' : '700'}))`,
|
|
170
|
+
'--button-fill-none-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '200' : '50'}))`,
|
|
171
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '900' : '800'}))`,
|
|
172
|
+
},
|
|
173
|
+
'&:focus': focusStyle,
|
|
174
|
+
'&.is-focused': focusStyle,
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const buttonSizes: CSSRuleObject = {
|
|
179
|
+
xs: {
|
|
180
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
181
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
182
|
+
padding: 'var(--button-padding-xs)',
|
|
183
|
+
width: 'var(--button-size-xs, auto)',
|
|
184
|
+
height: 'var(--button-size-xs, auto)',
|
|
185
|
+
},
|
|
186
|
+
sm: {
|
|
187
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
188
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
189
|
+
padding: 'var(--button-padding-sm)',
|
|
190
|
+
width: 'var(--button-size-sm, auto)',
|
|
191
|
+
height: 'var(--button-size-sm, auto)',
|
|
192
|
+
},
|
|
193
|
+
md: {
|
|
194
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
195
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
196
|
+
padding: 'var(--button-padding-md)',
|
|
197
|
+
width: 'var(--button-size-md, auto)',
|
|
198
|
+
height: 'var(--button-size-md, auto)',
|
|
199
|
+
},
|
|
200
|
+
lg: {
|
|
201
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['md'][0]})`,
|
|
202
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['md'][1]})`,
|
|
203
|
+
padding: 'var(--button-padding-lg)',
|
|
204
|
+
width: 'var(--button-size-lg, auto)',
|
|
205
|
+
height: 'var(--button-size-lg, auto)',
|
|
206
|
+
},
|
|
207
|
+
xl: {
|
|
208
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['md'][0]})`,
|
|
209
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['md'][1]})`,
|
|
210
|
+
padding: 'var(--button-padding-xl)',
|
|
211
|
+
width: 'var(--button-size-xl, auto)',
|
|
212
|
+
height: 'var(--button-size-xl, auto)',
|
|
213
|
+
},
|
|
214
|
+
'2xl': {
|
|
215
|
+
'--Icon-size': iconSizes['lg'],
|
|
216
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['lg'][0]})`,
|
|
217
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['lg'][1]})`,
|
|
218
|
+
padding: 'var(--button-padding-2xl)',
|
|
219
|
+
width: 'var(--button-size-2xl, auto)',
|
|
220
|
+
height: 'var(--button-size-2xl, auto)',
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
for (const key in buttonSizes) {
|
|
224
|
+
components[prefix + '-' + key] = buttonSizes[key]
|
|
225
|
+
}
|
|
226
|
+
addComponents(components)
|
|
227
|
+
|
|
228
|
+
/*
|
|
229
|
+
The style properties for buttons without a container should always
|
|
230
|
+
override the default button styles (eg: size, fill).
|
|
231
|
+
Since the classnames could be in any order in the markup or "@apply" directives,
|
|
232
|
+
we're utilizing the utility (layer) approach of tailwindcss to achieve this prioritization.
|
|
233
|
+
*/
|
|
234
|
+
const noContainerButton: CSSRuleObject = {
|
|
235
|
+
'.btu-button-container-none': {
|
|
236
|
+
padding: '0',
|
|
237
|
+
display: 'inline-flex',
|
|
238
|
+
backgroundColor: 'transparent',
|
|
239
|
+
color:
|
|
240
|
+
'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
addUtilities(noContainerButton)
|
|
244
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Headings are a combination of font-size, line-height and weight.
|
|
4
|
+
*
|
|
5
|
+
* Class Names:
|
|
6
|
+
*
|
|
7
|
+
* btu-heading-1
|
|
8
|
+
* btu-heading-2
|
|
9
|
+
* btu-heading-3
|
|
10
|
+
* btu-heading-4
|
|
11
|
+
* btu-heading-5
|
|
12
|
+
*
|
|
13
|
+
* Example Usage:
|
|
14
|
+
*
|
|
15
|
+
* Heading level 3 -> btu-heading-3
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
module.exports = plugin(function ({ addComponents, theme }) {
|
|
19
|
+
addComponents({
|
|
20
|
+
'.btu-heading-1': {
|
|
21
|
+
'font-size': '2.25rem',
|
|
22
|
+
'line-height': theme('lineHeight.9'),
|
|
23
|
+
'font-weight': '600',
|
|
24
|
+
},
|
|
25
|
+
'.btu-heading-2': {
|
|
26
|
+
'font-size': '1.875rem',
|
|
27
|
+
'line-height': theme('lineHeight.8'),
|
|
28
|
+
'font-weight': '600',
|
|
29
|
+
},
|
|
30
|
+
'.btu-heading-3': {
|
|
31
|
+
'font-size': '1.5rem',
|
|
32
|
+
'line-height': theme('lineHeight.7'),
|
|
33
|
+
'font-weight': '600',
|
|
34
|
+
},
|
|
35
|
+
'.btu-heading-4': {
|
|
36
|
+
'font-size': '1.125rem',
|
|
37
|
+
'line-height': theme('lineHeight.6'),
|
|
38
|
+
'font-weight': '600',
|
|
39
|
+
},
|
|
40
|
+
'.btu-heading-5': {
|
|
41
|
+
'font-size': '1rem',
|
|
42
|
+
'line-height': theme('lineHeight.5'),
|
|
43
|
+
'font-weight': '600',
|
|
44
|
+
},
|
|
45
|
+
'.btu-heading-6': {
|
|
46
|
+
'font-size': '.875rem',
|
|
47
|
+
'line-height': theme('lineHeight.4'),
|
|
48
|
+
'font-weight': '600',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin'
|
|
2
|
+
declare let module: any
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Headings are a combination of font-size, line-height and weight.
|
|
6
|
+
*
|
|
7
|
+
* Class Names:
|
|
8
|
+
*
|
|
9
|
+
* btu-heading-1
|
|
10
|
+
* btu-heading-2
|
|
11
|
+
* btu-heading-3
|
|
12
|
+
* btu-heading-4
|
|
13
|
+
* btu-heading-5
|
|
14
|
+
*
|
|
15
|
+
* Example Usage:
|
|
16
|
+
*
|
|
17
|
+
* Heading level 3 -> btu-heading-3
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
module.exports = plugin(function ({ addComponents, theme }) {
|
|
22
|
+
addComponents({
|
|
23
|
+
'.btu-heading-1': {
|
|
24
|
+
'font-size': '2.25rem',
|
|
25
|
+
'line-height': theme('lineHeight.9'),
|
|
26
|
+
'font-weight': '600',
|
|
27
|
+
},
|
|
28
|
+
'.btu-heading-2': {
|
|
29
|
+
'font-size': '1.875rem',
|
|
30
|
+
'line-height': theme('lineHeight.8'),
|
|
31
|
+
'font-weight': '600',
|
|
32
|
+
},
|
|
33
|
+
'.btu-heading-3': {
|
|
34
|
+
'font-size': '1.5rem',
|
|
35
|
+
'line-height': theme('lineHeight.7'),
|
|
36
|
+
'font-weight': '600',
|
|
37
|
+
},
|
|
38
|
+
'.btu-heading-4': {
|
|
39
|
+
'font-size': '1.125rem',
|
|
40
|
+
'line-height': theme('lineHeight.6'),
|
|
41
|
+
'font-weight': '600',
|
|
42
|
+
},
|
|
43
|
+
'.btu-heading-5': {
|
|
44
|
+
'font-size': '1rem',
|
|
45
|
+
'line-height': theme('lineHeight.5'),
|
|
46
|
+
'font-weight': '600',
|
|
47
|
+
},
|
|
48
|
+
'.btu-heading-6': {
|
|
49
|
+
'font-size': '.875rem',
|
|
50
|
+
'line-height': theme('lineHeight.4'),
|
|
51
|
+
'font-weight': '600',
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
})
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin';
|
|
2
|
+
import icons from 'lucide-static/font/info.json';
|
|
3
|
+
import * as LucideExports from 'lucide-static/dist/cjs/lucide-static';
|
|
4
|
+
/**
|
|
5
|
+
* Lucide Icons | https://lucide.dev/icons/
|
|
6
|
+
* Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability.
|
|
7
|
+
* Colors can also be changed via symbol overrides.
|
|
8
|
+
* All strokes in these icons have been converted to single vectors
|
|
9
|
+
* so color overrides are respected within variants.
|
|
10
|
+
*
|
|
11
|
+
* Class Names:
|
|
12
|
+
*
|
|
13
|
+
* btu-icon - Establishes the standard icon styles and font.
|
|
14
|
+
* btu-icon-{name-of-icon} - Sets the font glyph to the value of the icon you want.
|
|
15
|
+
* btu-icon-[xs|sm|md|lg|xl|{arbitary value}] - Size of the icon.
|
|
16
|
+
* btu-icon-gradient-[primary] - Gradient to use for the icon background.
|
|
17
|
+
* btu-icon-via-mask-{name of icon} - SVG mask to use given a specific icon name.
|
|
18
|
+
* - exposes a custom property `--Icon-svg` data URI to set the mask.
|
|
19
|
+
*
|
|
20
|
+
* Usages:
|
|
21
|
+
*
|
|
22
|
+
* A heart icon:
|
|
23
|
+
* > before:btu-icon before:btu-icon-heart
|
|
24
|
+
*
|
|
25
|
+
* A heart icon that is 2rem in size:
|
|
26
|
+
* > before:btu-icon before:btu-icon-heart before:[--Icon-size:2rem]
|
|
27
|
+
* - or -
|
|
28
|
+
* > before:btu-icon before:btu-icon-heart before:btu-icon-lg
|
|
29
|
+
*
|
|
30
|
+
* A heart icon with a gradient background:
|
|
31
|
+
* > before:btu-icon-gradient-primary before:btu-icon-via-mask-heart
|
|
32
|
+
*/
|
|
33
|
+
const svgs = {};
|
|
34
|
+
const symbols = /[\r\n%#()<>?[\\\]^`{|}]/g;
|
|
35
|
+
for (const [key, value] of Object.entries(LucideExports)) {
|
|
36
|
+
if (LucideExports.hasOwnProperty(key)) {
|
|
37
|
+
if (typeof value === 'string') {
|
|
38
|
+
svgs[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function addNameSpace(data) {
|
|
43
|
+
if (data.indexOf(`http://www.w3.org/2000/svg`) < 0) {
|
|
44
|
+
data = data.replace(/<svg/g, `<svg xmlns='http://www.w3.org/2000/svg'`);
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
function pascalToKebab(str) {
|
|
49
|
+
return str
|
|
50
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
51
|
+
.replace(/([A-Za-z])([0-9])/g, '$1-$2')
|
|
52
|
+
.toLowerCase();
|
|
53
|
+
}
|
|
54
|
+
function kebabToPascal(str) {
|
|
55
|
+
return str
|
|
56
|
+
.split('-')
|
|
57
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
58
|
+
.join('');
|
|
59
|
+
}
|
|
60
|
+
function encodeSVG(data) {
|
|
61
|
+
data = data.replace(/"/g, `'`);
|
|
62
|
+
data = data.replace(/>\s{1,}</g, `><`);
|
|
63
|
+
data = data.replace(/\s{2,}/g, ` `);
|
|
64
|
+
return data.replace(symbols, encodeURIComponent);
|
|
65
|
+
}
|
|
66
|
+
module.exports = plugin(function ({ addBase, addComponents, matchUtilities, theme }) {
|
|
67
|
+
const size = 'var(--Icon-size)';
|
|
68
|
+
const prefix = '.btu-icon-';
|
|
69
|
+
Object.entries(svgs).forEach(([key, svg]) => {
|
|
70
|
+
addComponents({
|
|
71
|
+
[`${prefix}via-mask`]: {
|
|
72
|
+
'--size': '20px',
|
|
73
|
+
mask: 'var(--Icon-svg, var(--compat-icon-via-mask)) center / contain no-repeat',
|
|
74
|
+
'aspect-ratio': '1',
|
|
75
|
+
'inline-size': 'var(--Icon-size, --size)',
|
|
76
|
+
},
|
|
77
|
+
[`${prefix}via-mask-${pascalToKebab(key)}`]: {
|
|
78
|
+
'--size': '20px',
|
|
79
|
+
'--Icon-svg': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svg))}")`,
|
|
80
|
+
mask: 'var(--Icon-svg) center / contain no-repeat',
|
|
81
|
+
'aspect-ratio': '1',
|
|
82
|
+
'inline-size': 'var(--Icon-size, --size)',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
addComponents({
|
|
87
|
+
'.btu-icon': {
|
|
88
|
+
'font-family': theme('fontFamily.lucide'),
|
|
89
|
+
direction: 'ltr',
|
|
90
|
+
display: 'inline-flex',
|
|
91
|
+
'font-feature-settings': '"liga" 0',
|
|
92
|
+
'-moz-osx-font-smoothing': 'grayscale',
|
|
93
|
+
'-webkit-font-smoothing': 'antialiased',
|
|
94
|
+
'font-size': size,
|
|
95
|
+
'font-style': 'normal',
|
|
96
|
+
'font-weight': 'normal',
|
|
97
|
+
'letter-spacing': 'normal',
|
|
98
|
+
'line-height': size,
|
|
99
|
+
'text-transform': 'none',
|
|
100
|
+
'white-space': 'nowrap',
|
|
101
|
+
'word-wrap': 'normal',
|
|
102
|
+
'vertical-align': 'top',
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
addComponents(Object.entries(icons).map((value) => {
|
|
106
|
+
return {
|
|
107
|
+
[prefix + value[0]]: {
|
|
108
|
+
'--tw-content': `'${value[1].encodedCode}'`,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}));
|
|
112
|
+
matchUtilities({
|
|
113
|
+
'btu-icon-gradient': (value) => ({
|
|
114
|
+
'background-image': value,
|
|
115
|
+
'background-repeat': 'no-repeat',
|
|
116
|
+
'background-position': 'center',
|
|
117
|
+
'background-size': 'var(--Icon-size) var(--Icon-size)',
|
|
118
|
+
}),
|
|
119
|
+
}, {
|
|
120
|
+
values: {
|
|
121
|
+
primary: 'linear-gradient(to top right, theme(colors.primary.500), theme(colors.primary.700), theme(colors.primary.900))',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
matchUtilities({
|
|
125
|
+
'btu-icon': (value) => ({
|
|
126
|
+
'--Icon-size': value,
|
|
127
|
+
}),
|
|
128
|
+
}, { values: theme('iconSize') });
|
|
129
|
+
// Compat v4 Icons:
|
|
130
|
+
// Icon names which are Google Material icons mapped to a lucide equivalent to support the legacy markup.
|
|
131
|
+
const compatNames = new Map();
|
|
132
|
+
compatNames.set('arrow_downward', 'arrow-down');
|
|
133
|
+
compatNames.set('arrow_upward', 'arrow-up');
|
|
134
|
+
compatNames.set('assessment', 'file-chart-pie');
|
|
135
|
+
compatNames.set('assignment', 'clipboard-check');
|
|
136
|
+
compatNames.set('attachment', 'file');
|
|
137
|
+
compatNames.set('auto_stories', 'book');
|
|
138
|
+
compatNames.set('ballot', 'shield-question');
|
|
139
|
+
compatNames.set('border_all', 'table-2');
|
|
140
|
+
compatNames.set('cancel', 'circle-x');
|
|
141
|
+
compatNames.set('chat_bubble', 'message-circle');
|
|
142
|
+
compatNames.set('check_circle', 'circle-check-big');
|
|
143
|
+
compatNames.set('chrome_reader_mode', 'table-properties');
|
|
144
|
+
compatNames.set('class', 'book-type');
|
|
145
|
+
compatNames.set('close', 'x');
|
|
146
|
+
compatNames.set('code', 'code');
|
|
147
|
+
compatNames.set('comment', 'message-circle-plus');
|
|
148
|
+
compatNames.set('comments_disabled', 'message-circle-x');
|
|
149
|
+
compatNames.set('create_new_folder', 'boxes');
|
|
150
|
+
compatNames.set('description', 'file-text');
|
|
151
|
+
compatNames.set('edit', 'pencil');
|
|
152
|
+
compatNames.set('error', 'circle-alert');
|
|
153
|
+
compatNames.set('expand_more', 'chevrons-up-down');
|
|
154
|
+
compatNames.set('expand_less', 'chevrons-down-up');
|
|
155
|
+
compatNames.set('feed', 'scroll-text');
|
|
156
|
+
compatNames.set('format_align_center', 'align-center');
|
|
157
|
+
compatNames.set('format_align_left', 'align-left');
|
|
158
|
+
compatNames.set('format_align_right', 'align-right');
|
|
159
|
+
compatNames.set('format_bold', 'bold');
|
|
160
|
+
compatNames.set('format_clear', 'remove-formatting');
|
|
161
|
+
compatNames.set('format_indent_increase', 'indent-increase');
|
|
162
|
+
compatNames.set('format_indent_decrease', 'indent-decrease');
|
|
163
|
+
compatNames.set('format_italic', 'italic');
|
|
164
|
+
compatNames.set('format_list_bulleted', 'list');
|
|
165
|
+
compatNames.set('format_list_numbered', 'badge-help');
|
|
166
|
+
compatNames.set('format_quote', 'quote');
|
|
167
|
+
compatNames.set('format_strikethrough', 'strikethrough');
|
|
168
|
+
compatNames.set('format_underlined', 'underline');
|
|
169
|
+
compatNames.set('fullscreen', 'maximize-2');
|
|
170
|
+
compatNames.set('grid_on', 'file-spreadsheet');
|
|
171
|
+
compatNames.set('handshake', 'handshake');
|
|
172
|
+
compatNames.set('help', 'circle-help');
|
|
173
|
+
compatNames.set('history', 'history');
|
|
174
|
+
compatNames.set('home', 'house');
|
|
175
|
+
compatNames.set('import_contacts', 'book');
|
|
176
|
+
compatNames.set('insert_photo', 'file-image');
|
|
177
|
+
compatNames.set('keyboard', 'keyboard');
|
|
178
|
+
compatNames.set('link', 'link-2');
|
|
179
|
+
compatNames.set('link_off', 'link-2-off');
|
|
180
|
+
compatNames.set('live_tv', 'tv-minimal-play');
|
|
181
|
+
compatNames.set('local_offer', 'tag');
|
|
182
|
+
compatNames.set('manage_search', 'text-search');
|
|
183
|
+
compatNames.set('menu_book', 'book-marked');
|
|
184
|
+
compatNames.set('more_horiz', 'ellipsis');
|
|
185
|
+
compatNames.set('music_note', 'music-2');
|
|
186
|
+
compatNames.set('notes', 'notebook-text');
|
|
187
|
+
compatNames.set('ondemand_video', 'video');
|
|
188
|
+
compatNames.set('open_with', 'move');
|
|
189
|
+
compatNames.set('person', 'user-pen');
|
|
190
|
+
compatNames.set('photo', 'file-image');
|
|
191
|
+
compatNames.set('photo_camera', 'camera');
|
|
192
|
+
compatNames.set('photo_library', 'images');
|
|
193
|
+
compatNames.set('picture', 'image-up');
|
|
194
|
+
compatNames.set('play', 'square-play');
|
|
195
|
+
compatNames.set('playlist_play', 'list-video');
|
|
196
|
+
compatNames.set('post_add', 'clipboard-plus');
|
|
197
|
+
compatNames.set('question_answer', 'pencil-line');
|
|
198
|
+
compatNames.set('rate_review', 'square-pen');
|
|
199
|
+
compatNames.set('redo', 'redo');
|
|
200
|
+
compatNames.set('remove', 'minus');
|
|
201
|
+
compatNames.set('school', 'badge-info');
|
|
202
|
+
compatNames.set('search', 'search');
|
|
203
|
+
compatNames.set('settings_ethernet', 'chevrons-left-right-ellipsis');
|
|
204
|
+
compatNames.set('short_text', 'text');
|
|
205
|
+
compatNames.set('slideshow', 'film');
|
|
206
|
+
compatNames.set('slow_motion_video', 'list-video');
|
|
207
|
+
compatNames.set('subject', 'letter-text');
|
|
208
|
+
compatNames.set('textsms', 'message-circle-more');
|
|
209
|
+
compatNames.set('theaters', 'clapperboard');
|
|
210
|
+
compatNames.set('toc', 'notebook-tabs');
|
|
211
|
+
compatNames.set('toggle_off', 'toggle-left');
|
|
212
|
+
compatNames.set('toggle_on', 'toggle-right');
|
|
213
|
+
compatNames.set('undo', 'undo');
|
|
214
|
+
compatNames.set('vertical_align_bottom', 'subscript');
|
|
215
|
+
compatNames.set('vertical_align_top', 'superscript');
|
|
216
|
+
compatNames.set('view_compact', 'layout-panel-top');
|
|
217
|
+
compatNames.set('volume_up', 'volume-2');
|
|
218
|
+
compatNames.set('warning', 'triangle-alert');
|
|
219
|
+
compatNames.set('wb_incandescent', 'lightbulb');
|
|
220
|
+
compatNames.set('widgets', 'blocks');
|
|
221
|
+
compatNames.set('zap', 'zap');
|
|
222
|
+
compatNames.forEach((value, key) => {
|
|
223
|
+
addBase({
|
|
224
|
+
/* this is the default icon when no mapped icon is found */
|
|
225
|
+
[`[data-icon],[data-icon-name],[data-icon-button-name]`]: {
|
|
226
|
+
'--compat-icon': `'${icons['circle-dashed'].encodedCode}'`,
|
|
227
|
+
'--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs['CircleDashed']))}")`,
|
|
228
|
+
},
|
|
229
|
+
[`html [data-icon="${key}"],html [data-icon-name="${key}"],html [data-icon-button-name="${key}"]`]: {
|
|
230
|
+
// tslint:disable-next-line
|
|
231
|
+
'--compat-icon': `'${icons[value].encodedCode}'`,
|
|
232
|
+
'--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs[kebabToPascal(value)]))}")`,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}, {
|
|
237
|
+
theme: {
|
|
238
|
+
iconSize: {
|
|
239
|
+
DEFAULT: '1.25rem',
|
|
240
|
+
xs: '0.75rem',
|
|
241
|
+
sm: '1rem',
|
|
242
|
+
md: '1.25rem',
|
|
243
|
+
lg: '1.5rem',
|
|
244
|
+
xl: '1.75rem',
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
});
|