@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
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<a id="readme-top"></a>
|
|
2
|
+
<div>
|
|
3
|
+
<h2 align="center">brightspot-ui</h2>
|
|
4
|
+
<p align="center">
|
|
5
|
+
A UI library for building Brightspot CMS components.
|
|
6
|
+
<br/>
|
|
7
|
+
</p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<!-- TOC -->
|
|
11
|
+
<details>
|
|
12
|
+
<summary>Table of Contents</summary>
|
|
13
|
+
<ol>
|
|
14
|
+
<li>
|
|
15
|
+
<a href="#about">About</a>
|
|
16
|
+
</li>
|
|
17
|
+
<li>
|
|
18
|
+
<a href="#getting-started">Getting Started</a>
|
|
19
|
+
</li>
|
|
20
|
+
<li><a href="#prerequisites">Prerequisites</a></li>
|
|
21
|
+
<li><a href="#installation">Installation</a></li>
|
|
22
|
+
<li>
|
|
23
|
+
<a href="#using-plugins">Using Plugins</a>
|
|
24
|
+
</li>
|
|
25
|
+
<li>
|
|
26
|
+
<a href="#development">Development</a>
|
|
27
|
+
</li>
|
|
28
|
+
<li>
|
|
29
|
+
<a href="#frequently-asked-questions">FAQ</a>
|
|
30
|
+
</li>
|
|
31
|
+
</ol>
|
|
32
|
+
</br>
|
|
33
|
+
</details>
|
|
34
|
+
|
|
35
|
+
## About
|
|
36
|
+
|
|
37
|
+
Brightspot UI is a package of custom web components and styles to provide a basis for building new CMS components. It uses [TailwindCSS](https://v3.tailwindcss.com/) for styling and [LitElement](https://lit.dev/) for web components.
|
|
38
|
+
|
|
39
|
+
If you're developing a Brightspot CMS plugin or creating custom CMS UI for your project, then you've come to the right place!
|
|
40
|
+
|
|
41
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
_Note:_ To get the best developer experience we recommend using VSCode editor. The marketplace of extensions that are available provide code formatting and intellisense for all the TailwindCSS classnames and our plugins, etc. The VSCode setup is documented [here](https://github.com/perfectsense/brightspot/tree/release/5.0/cms/tool-ui#visual-studio-code).
|
|
46
|
+
|
|
47
|
+
### Prerequisites
|
|
48
|
+
|
|
49
|
+
Your codebase needs to be compatible with
|
|
50
|
+
* TailwindCSS **v3**
|
|
51
|
+
|
|
52
|
+
### Installation
|
|
53
|
+
|
|
54
|
+
1. Install the Brightspot ui node module as a devDependency
|
|
55
|
+
```sh
|
|
56
|
+
yarn add -D @brightspot/ui
|
|
57
|
+
```
|
|
58
|
+
2. Create a `tailwind.config` file and add Brightspot ui as a preset. More on TWCSS presets [here](https://v3.tailwindcss.com/docs/presets#presets).
|
|
59
|
+
```ts
|
|
60
|
+
// (Typescript example) contents of tailwind.config.ts
|
|
61
|
+
export default {
|
|
62
|
+
...
|
|
63
|
+
presets: [require('@brightspot/ui')],
|
|
64
|
+
...
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
```js
|
|
68
|
+
// (Javascript example) contents of tailwind.config.js
|
|
69
|
+
export default {
|
|
70
|
+
...
|
|
71
|
+
presets: [require('@brightspot/ui/dist/tailwind.config.js')],
|
|
72
|
+
...
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
3. Build your frontend
|
|
76
|
+
|
|
77
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
78
|
+
|
|
79
|
+
## Using Plugins
|
|
80
|
+
|
|
81
|
+
Brightspot UI comes with a variety of TailwindCSS plugins to make styling simpler and declarative.
|
|
82
|
+
|
|
83
|
+
To use our plugins, include them in your TailwindCSS config as usual. Plugin files are provided in both Typescript and Javascript variants and are available under the `dist` path in the brightspot-ui module.
|
|
84
|
+
|
|
85
|
+
An example of including all the plugins:
|
|
86
|
+
```ts
|
|
87
|
+
// your tailwind.config.ts
|
|
88
|
+
...
|
|
89
|
+
plugins: [
|
|
90
|
+
require('@brightspot/ui/dist/tailwind-plugin-theme.ts'),
|
|
91
|
+
require('@brightspot/ui/dist/tailwind-plugin-badge.ts'),
|
|
92
|
+
require('@brightspot/ui/dist/tailwind-plugin-button.ts'),
|
|
93
|
+
require('@brightspot/ui/dist/tailwind-plugin-heading.ts'),
|
|
94
|
+
require('@brightspot/ui/dist/tailwind-plugin-icon.ts'),
|
|
95
|
+
require('@brightspot/ui/dist/tailwind-plugin-loader.ts'),
|
|
96
|
+
require('@brightspot/ui/dist/tailwind-plugin-scroll-shadow.ts')
|
|
97
|
+
...
|
|
98
|
+
```
|
|
99
|
+
### Available plugins:
|
|
100
|
+
|
|
101
|
+
1. Badge
|
|
102
|
+
```ts
|
|
103
|
+
require('@brightspot/ui/dist/tailwind-plugin-badge.ts')
|
|
104
|
+
```
|
|
105
|
+
2. Button
|
|
106
|
+
```ts
|
|
107
|
+
require('@brightspot/ui/dist/tailwind-plugin-button.ts')
|
|
108
|
+
```
|
|
109
|
+
4. Heading
|
|
110
|
+
```ts
|
|
111
|
+
require('@brightspot/ui/dist/tailwind-plugin-heading.ts')
|
|
112
|
+
```
|
|
113
|
+
5. Icon
|
|
114
|
+
```ts
|
|
115
|
+
require('@brightspot/ui/dist/tailwind-plugin-icon.ts')
|
|
116
|
+
```
|
|
117
|
+
6. Loader
|
|
118
|
+
```ts
|
|
119
|
+
require('@brightspot/ui/dist/tailwind-plugin-loader.ts')
|
|
120
|
+
```
|
|
121
|
+
7. ScrollShadow
|
|
122
|
+
```ts
|
|
123
|
+
require('@brightspot/ui/dist/tailwind-plugin-scroll-shadow.ts')
|
|
124
|
+
```
|
|
125
|
+
8. Theme
|
|
126
|
+
```ts
|
|
127
|
+
require('@brightspot/ui/dist/tailwind-plugin-theme.ts')
|
|
128
|
+
```
|
|
129
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
* To build, run `yarn build` from the package root to create the `dist` folder
|
|
134
|
+
* To use this package locally, run `yarn pack` to create a distribution package. Then install the node module in your project using `yarn add {/PATH/TO/TARBALL}/brightspot-ui-v{VERSION}.tgz`. __Note:__ You could also use `yarn link` for this or [local paths](https://classic.yarnpkg.com/lang/en/docs/cli/add/).
|
|
135
|
+
* To publish a release, run `npm publish` and follow the prompts. **Make sure to update the version number in the package.json first!**
|
|
136
|
+
|
|
137
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
138
|
+
|
|
139
|
+
## Frequently Asked Questions
|
|
140
|
+
|
|
141
|
+
Q: How do I know that I set it up correctly?
|
|
142
|
+
|
|
143
|
+
A: TODO
|
|
144
|
+
|
|
145
|
+
Q: How can I see examples of the components and theme?
|
|
146
|
+
|
|
147
|
+
A: TODO
|
|
148
|
+
|
|
149
|
+
Q: Can I choose which Brightspot UI plugins my project uses?
|
|
150
|
+
|
|
151
|
+
A: You have full control over which plugins you include in the tailwind.config file. See the ["using plugins"](#using-plugins) section above.
|
|
152
|
+
|
|
153
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'lucide-static/dist/cjs/lucide-static'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin';
|
|
2
|
+
const className = '.btu-badge';
|
|
3
|
+
module.exports = plugin(function ({ addComponents, theme, e }) {
|
|
4
|
+
const sizes = theme('badgeSize');
|
|
5
|
+
const colors = theme('colors');
|
|
6
|
+
const fontSizes = theme('fontSize');
|
|
7
|
+
const iconSizes = theme('iconSize') || {};
|
|
8
|
+
if (colors) {
|
|
9
|
+
const badgeColors = [];
|
|
10
|
+
for (const key in colors) {
|
|
11
|
+
badgeColors.push({
|
|
12
|
+
[`${className}-${e(key)}`]: {
|
|
13
|
+
'--Icon-size': iconSizes['xs'],
|
|
14
|
+
backgroundColor: `oklch(var(--btu-theme-${key}-50))`,
|
|
15
|
+
color: `oklch(var(--btu-theme-${key}-700))`,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
addComponents(badgeColors);
|
|
20
|
+
}
|
|
21
|
+
if (sizes && fontSizes) {
|
|
22
|
+
const badgeSizes = [];
|
|
23
|
+
const fontSizeStyles = {
|
|
24
|
+
display: 'inline-block',
|
|
25
|
+
borderRadius: '1rem',
|
|
26
|
+
};
|
|
27
|
+
for (const key in sizes) {
|
|
28
|
+
const size = sizes[key];
|
|
29
|
+
const fontSize = fontSizes[size.fontSize];
|
|
30
|
+
if (fontSize) {
|
|
31
|
+
badgeSizes.push({
|
|
32
|
+
[`${className}-${e(key)}`]: {
|
|
33
|
+
gap: '0.38rem',
|
|
34
|
+
...fontSizeStyles,
|
|
35
|
+
fontSize: fontSize[0],
|
|
36
|
+
lineHeight: fontSize[1],
|
|
37
|
+
padding: `${size.paddingTop} ${size.paddingRight}`,
|
|
38
|
+
minWidth: size.minWidth,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
addComponents(badgeSizes);
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
theme: {
|
|
47
|
+
badgeSize: {
|
|
48
|
+
sm: {
|
|
49
|
+
fontSize: 'xs',
|
|
50
|
+
paddingTop: '.13rem',
|
|
51
|
+
paddingRight: '.5rem',
|
|
52
|
+
minWidth: '1.375rem',
|
|
53
|
+
},
|
|
54
|
+
md: {
|
|
55
|
+
fontSize: 'sm',
|
|
56
|
+
paddingTop: '.13rem',
|
|
57
|
+
paddingRight: '.63rem',
|
|
58
|
+
minWidth: '1.813rem',
|
|
59
|
+
},
|
|
60
|
+
lg: {
|
|
61
|
+
fontSize: 'sm',
|
|
62
|
+
paddingTop: '.25rem',
|
|
63
|
+
paddingRight: '.75rem',
|
|
64
|
+
minWidth: '1.813rem',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin'
|
|
2
|
+
import { CSSRuleObject } from 'tailwindcss/types/config'
|
|
3
|
+
declare let module: any
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Badges help highlight important information, such as notifications or new and
|
|
7
|
+
* unread messages. They’re primarily used for communicating secondary or additional
|
|
8
|
+
* information to text.
|
|
9
|
+
*
|
|
10
|
+
* Class Names:
|
|
11
|
+
*
|
|
12
|
+
* btu-badge-[sm|md|lg] - Size of the Badge.
|
|
13
|
+
* btu-badge-[$theme-colors] - Color of the Badge.
|
|
14
|
+
*
|
|
15
|
+
* Example Usages:
|
|
16
|
+
*
|
|
17
|
+
* Base -> btu-badge-lg btu-badge-purple
|
|
18
|
+
* Dot -> btu-badge-lg btu-badge-primary before:size-2 before:rounded-lg before:bg-[currentColor] before:[content:'']
|
|
19
|
+
* Close -> btu-badge-lg btu-badge-error after:btu-icon after:btu-icon-x
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type Size = {
|
|
23
|
+
fontSize: 'xs' | 'sm'
|
|
24
|
+
paddingTop: string
|
|
25
|
+
paddingRight: string
|
|
26
|
+
minWidth: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const className = '.btu-badge'
|
|
30
|
+
|
|
31
|
+
module.exports = plugin(
|
|
32
|
+
function ({ addComponents, theme, e }) {
|
|
33
|
+
const sizes = theme('badgeSize')
|
|
34
|
+
const colors: [CSSRuleObject] = theme('colors')
|
|
35
|
+
const fontSizes: Record<string, CSSRuleObject> = theme('fontSize')
|
|
36
|
+
const iconSizes: CSSRuleObject = theme('iconSize') || {}
|
|
37
|
+
|
|
38
|
+
if (colors) {
|
|
39
|
+
const badgeColors: CSSRuleObject[] = []
|
|
40
|
+
for (const key in colors) {
|
|
41
|
+
badgeColors.push({
|
|
42
|
+
[`${className}-${e(key)}`]: {
|
|
43
|
+
'--Icon-size': iconSizes['xs'],
|
|
44
|
+
backgroundColor: `oklch(var(--btu-theme-${key}-50))`,
|
|
45
|
+
color: `oklch(var(--btu-theme-${key}-700))`,
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
addComponents(badgeColors)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (sizes && fontSizes) {
|
|
53
|
+
const badgeSizes: CSSRuleObject[] = []
|
|
54
|
+
const fontSizeStyles = {
|
|
55
|
+
display: 'inline-block',
|
|
56
|
+
borderRadius: '1rem',
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const key in sizes) {
|
|
60
|
+
const size: Size = sizes[key]
|
|
61
|
+
const fontSize = fontSizes[size.fontSize]
|
|
62
|
+
|
|
63
|
+
if (fontSize) {
|
|
64
|
+
badgeSizes.push({
|
|
65
|
+
[`${className}-${e(key)}`]: {
|
|
66
|
+
gap: '0.38rem',
|
|
67
|
+
...fontSizeStyles,
|
|
68
|
+
fontSize: fontSize[0],
|
|
69
|
+
lineHeight: fontSize[1],
|
|
70
|
+
padding: `${size.paddingTop} ${size.paddingRight}`,
|
|
71
|
+
minWidth: size.minWidth,
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
addComponents(badgeSizes)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
theme: {
|
|
81
|
+
badgeSize: {
|
|
82
|
+
sm: {
|
|
83
|
+
fontSize: 'xs',
|
|
84
|
+
paddingTop: '.13rem',
|
|
85
|
+
paddingRight: '.5rem',
|
|
86
|
+
minWidth: '1.375rem',
|
|
87
|
+
},
|
|
88
|
+
md: {
|
|
89
|
+
fontSize: 'sm',
|
|
90
|
+
paddingTop: '.13rem',
|
|
91
|
+
paddingRight: '.63rem',
|
|
92
|
+
minWidth: '1.813rem',
|
|
93
|
+
},
|
|
94
|
+
lg: {
|
|
95
|
+
fontSize: 'sm',
|
|
96
|
+
paddingTop: '.25rem',
|
|
97
|
+
paddingRight: '.75rem',
|
|
98
|
+
minWidth: '1.813rem',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
)
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Buttons communicate actions that users can take such as submit a form, begin a new task,
|
|
4
|
+
* trigger a new UI element to appear or take a new or next step in some process.
|
|
5
|
+
*
|
|
6
|
+
* Class Names:
|
|
7
|
+
*
|
|
8
|
+
* btu-button - Establishes a default button container
|
|
9
|
+
* btu-button-[fill-none | container-none | outline | text-hidden] - Different types of buttons like solid,
|
|
10
|
+
* outline, icon buttons etc
|
|
11
|
+
* btu-button-[sm|md|lg|xl|2xl] - Size of buttons
|
|
12
|
+
* btu-button-[$theme-colors] - Color of buttons
|
|
13
|
+
* - required if using btu-button-outline to see outline
|
|
14
|
+
* btu-button-[pressed | disabled] - States of buttons (active or disabled)
|
|
15
|
+
*
|
|
16
|
+
* Example Usages:
|
|
17
|
+
*
|
|
18
|
+
* Publish button in content edit page -> btu-button btu-button-primary btu-button-sm
|
|
19
|
+
*
|
|
20
|
+
* Search toolbar icon button -> btu-button btu-button-text-hidden btu-button-fill-none
|
|
21
|
+
* btu-button-gray before:btu-icon before:btu-icon-search
|
|
22
|
+
*/
|
|
23
|
+
module.exports = plugin(function ({ addComponents, addUtilities, theme }) {
|
|
24
|
+
const textSizes = theme('fontSize');
|
|
25
|
+
const colors = theme('colors') || {};
|
|
26
|
+
const iconSizes = theme('iconSize') || {};
|
|
27
|
+
const prefix = '.btu-button';
|
|
28
|
+
const disabledStyle = {
|
|
29
|
+
'--button-bg-gradient': 'none',
|
|
30
|
+
'--button-disabled-color': `var(--button-disabled-color-fill-none, var(--button-disabled-color-fill, oklch(var(--btu-theme-gray-100))))`,
|
|
31
|
+
'--button-disabled-text-color': `var(--button-disabled-text-color-fill-none, var(--button-text-color, oklch(var(--btu-theme-gray-400))))`,
|
|
32
|
+
pointerEvents: 'none',
|
|
33
|
+
userSelect: 'none',
|
|
34
|
+
};
|
|
35
|
+
const activeStyle = {
|
|
36
|
+
'--button-pressed': ' ',
|
|
37
|
+
};
|
|
38
|
+
const components = {
|
|
39
|
+
'.btu-button': {
|
|
40
|
+
// default button
|
|
41
|
+
'--button-bg-gradient': 'none',
|
|
42
|
+
'--button-color': '',
|
|
43
|
+
'--button-text-color': '',
|
|
44
|
+
'--button-pressed': 'initial',
|
|
45
|
+
'--button-fill-none': 'initial',
|
|
46
|
+
'--button-padding-xs': '0.25rem 0.5rem',
|
|
47
|
+
'--button-padding-sm': '0.5rem 0.875rem',
|
|
48
|
+
'--button-padding-md': '0.625rem 1rem',
|
|
49
|
+
'--button-padding-lg': '0.625rem 1.125rem',
|
|
50
|
+
'--button-padding-xl': '0.75rem 1.25rem',
|
|
51
|
+
'--button-padding-2xl': '1rem 1.75rem',
|
|
52
|
+
'--button-font-size': textSizes['sm'][0],
|
|
53
|
+
'--button-line-height': textSizes['sm'][1],
|
|
54
|
+
display: 'inline-flex',
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
gap: '0.5rem',
|
|
59
|
+
background: 'var(--button-bg-gradient), var(--button-pressed-color, var(--button-disabled-color, var(--button-color)))',
|
|
60
|
+
borderRadius: 'var(--button-border-radius, 0.5rem)',
|
|
61
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
62
|
+
padding: 'var(--button-padding-sm)',
|
|
63
|
+
fontSize: 'var(--button-font-size)',
|
|
64
|
+
lineHeight: 'var(--button-line-height)',
|
|
65
|
+
fontWeight: theme('fontWeight.semibold'),
|
|
66
|
+
position: 'relative',
|
|
67
|
+
height: 'var(--button-size-sm, auto)',
|
|
68
|
+
width: 'var(--button-size-sm, auto)',
|
|
69
|
+
'&[aria-pressed="true"]': activeStyle,
|
|
70
|
+
'&:disabled': disabledStyle,
|
|
71
|
+
'&[disabled]': disabledStyle,
|
|
72
|
+
textDecoration: 'none',
|
|
73
|
+
'&:focus': {
|
|
74
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
75
|
+
},
|
|
76
|
+
'&:hover': {
|
|
77
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-text-color)))',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
'.btu-button-text-hidden': {
|
|
81
|
+
'--button-padding-xs': '0.25rem',
|
|
82
|
+
'--button-padding-sm': '0.5rem',
|
|
83
|
+
'--button-padding-md': '0.625rem',
|
|
84
|
+
'--button-padding-lg': '0.75rem',
|
|
85
|
+
'--button-padding-xl': '0.875rem',
|
|
86
|
+
'--button-padding-2xl': '1rem',
|
|
87
|
+
'--button-icon-font-size': '0px',
|
|
88
|
+
'--button-icon-line-height': '1',
|
|
89
|
+
'--button-font-size': 'var(--button-icon-font-size)',
|
|
90
|
+
'--button-line-height': 'var(--button-icon-line-height)',
|
|
91
|
+
'--button-size-xs': '1.75rem',
|
|
92
|
+
'--button-size-sm': '2.25rem',
|
|
93
|
+
'--button-size-md': '2.5rem',
|
|
94
|
+
'--button-size-lg': '2.75rem',
|
|
95
|
+
'--button-size-xl': '3rem',
|
|
96
|
+
'--button-size-2xl': '3.5rem',
|
|
97
|
+
overflow: 'hidden',
|
|
98
|
+
gap: '0',
|
|
99
|
+
},
|
|
100
|
+
'.btu-button-outline': {
|
|
101
|
+
'--button-outline-offset-width': '1px',
|
|
102
|
+
'--button-outline-offset-color': 'var(--button-outline-color)',
|
|
103
|
+
outline: '1px solid var(--button-outline-color)',
|
|
104
|
+
'&:focus-visible': {
|
|
105
|
+
outline: 'none',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
'.btu-button-fill-none': {
|
|
109
|
+
'--button-fill-none': ' ',
|
|
110
|
+
backgroundColor: 'var(--button-pressed-color, var(--button-fill-none-color))',
|
|
111
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
112
|
+
'&:focus': {
|
|
113
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
114
|
+
},
|
|
115
|
+
'&:hover': {
|
|
116
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
'.btu-button-disabled': disabledStyle,
|
|
120
|
+
'.btu-button-pressed': activeStyle,
|
|
121
|
+
};
|
|
122
|
+
// background & text colors for buttons in different states
|
|
123
|
+
for (const key in colors) {
|
|
124
|
+
if (key === 'currentColor' ||
|
|
125
|
+
key === 'transparent' ||
|
|
126
|
+
key === 'white' ||
|
|
127
|
+
key === 'black')
|
|
128
|
+
continue;
|
|
129
|
+
const focusStyle = {
|
|
130
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'success' ? '700' : '600'}))`,
|
|
131
|
+
'--button-fill-none-color': `transparent`,
|
|
132
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '700' : '600'}))`,
|
|
133
|
+
'--tw-ring-opacity': '1',
|
|
134
|
+
'--tw-ring-color': `oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-100))`,
|
|
135
|
+
'--tw-ring-offset-width': '1px',
|
|
136
|
+
'--tw-ring-offset-color': `${key === 'gray' ? 'oklch(var(--btu-theme-primary-800))' : 'var(--button-outline-offset-color, var(--button-color))'}`,
|
|
137
|
+
};
|
|
138
|
+
components[prefix + '-' + key] = {
|
|
139
|
+
'--button-bg-gradient': `var(--button-fill-none, ${key === 'primary' ? theme('colors.primary.gradient') : 'none'})`,
|
|
140
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'success' ? '700' : '600'}))`,
|
|
141
|
+
'--button-text-color': `${key === 'gray' ? 'oklch(var(--btu-theme-gray-700))' : 'var(--btu-theme-white)'}`,
|
|
142
|
+
'--button-fill-none-color': 'transparent',
|
|
143
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '700' : '600'}))`,
|
|
144
|
+
'--button-outline-color': `oklch(var(--btu-theme-${key}-300))`,
|
|
145
|
+
'--button-disabled-color-fill': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '100' : key === 'primary' ? '300' : '200'}))`,
|
|
146
|
+
'--button-disabled-color-fill-none': `var(--button-fill-none) oklch(var(--btu-theme-white))`,
|
|
147
|
+
'--button-disabled-text-color-fill-none': `var(--button-fill-none) oklch(var(--btu-theme-${key}-${key === 'gray' ? '400' : '300'}))`,
|
|
148
|
+
'--button-pressed-color': `var(--button-pressed) var(--button-disabled-color, oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-50)))`,
|
|
149
|
+
'--button-pressed-text-color': `var(--button-pressed) var(--button-disabled-text-color, oklch(var(--btu-theme-${key === 'gray' ? 'primary' : key}-800)))`,
|
|
150
|
+
'&:hover': {
|
|
151
|
+
'--button-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '200' : key === 'success' ? '800' : '700'}))`,
|
|
152
|
+
'--button-fill-none-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '200' : '50'}))`,
|
|
153
|
+
'--button-fill-none-text-color': `oklch(var(--btu-theme-${key}-${key === 'gray' ? '900' : '800'}))`,
|
|
154
|
+
},
|
|
155
|
+
'&:focus': focusStyle,
|
|
156
|
+
'&.is-focused': focusStyle,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const buttonSizes = {
|
|
160
|
+
xs: {
|
|
161
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
162
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
163
|
+
padding: 'var(--button-padding-xs)',
|
|
164
|
+
width: 'var(--button-size-xs, auto)',
|
|
165
|
+
height: 'var(--button-size-xs, auto)',
|
|
166
|
+
},
|
|
167
|
+
sm: {
|
|
168
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
169
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
170
|
+
padding: 'var(--button-padding-sm)',
|
|
171
|
+
width: 'var(--button-size-sm, auto)',
|
|
172
|
+
height: 'var(--button-size-sm, auto)',
|
|
173
|
+
},
|
|
174
|
+
md: {
|
|
175
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['sm'][0]})`,
|
|
176
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['sm'][1]})`,
|
|
177
|
+
padding: 'var(--button-padding-md)',
|
|
178
|
+
width: 'var(--button-size-md, auto)',
|
|
179
|
+
height: 'var(--button-size-md, auto)',
|
|
180
|
+
},
|
|
181
|
+
lg: {
|
|
182
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['md'][0]})`,
|
|
183
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['md'][1]})`,
|
|
184
|
+
padding: 'var(--button-padding-lg)',
|
|
185
|
+
width: 'var(--button-size-lg, auto)',
|
|
186
|
+
height: 'var(--button-size-lg, auto)',
|
|
187
|
+
},
|
|
188
|
+
xl: {
|
|
189
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['md'][0]})`,
|
|
190
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['md'][1]})`,
|
|
191
|
+
padding: 'var(--button-padding-xl)',
|
|
192
|
+
width: 'var(--button-size-xl, auto)',
|
|
193
|
+
height: 'var(--button-size-xl, auto)',
|
|
194
|
+
},
|
|
195
|
+
'2xl': {
|
|
196
|
+
'--Icon-size': iconSizes['lg'],
|
|
197
|
+
fontSize: `var(--button-icon-font-size, ${textSizes['lg'][0]})`,
|
|
198
|
+
lineHeight: `var(--button-icon-line-height, ${textSizes['lg'][1]})`,
|
|
199
|
+
padding: 'var(--button-padding-2xl)',
|
|
200
|
+
width: 'var(--button-size-2xl, auto)',
|
|
201
|
+
height: 'var(--button-size-2xl, auto)',
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
for (const key in buttonSizes) {
|
|
205
|
+
components[prefix + '-' + key] = buttonSizes[key];
|
|
206
|
+
}
|
|
207
|
+
addComponents(components);
|
|
208
|
+
/*
|
|
209
|
+
The style properties for buttons without a container should always
|
|
210
|
+
override the default button styles (eg: size, fill).
|
|
211
|
+
Since the classnames could be in any order in the markup or "@apply" directives,
|
|
212
|
+
we're utilizing the utility (layer) approach of tailwindcss to achieve this prioritization.
|
|
213
|
+
*/
|
|
214
|
+
const noContainerButton = {
|
|
215
|
+
'.btu-button-container-none': {
|
|
216
|
+
padding: '0',
|
|
217
|
+
display: 'inline-flex',
|
|
218
|
+
backgroundColor: 'transparent',
|
|
219
|
+
color: 'var(--button-pressed-text-color, var(--button-disabled-text-color, var(--button-fill-none-text-color)))',
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
addUtilities(noContainerButton);
|
|
223
|
+
});
|