vira 30.6.0 → 31.0.0

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.
@@ -77,7 +77,7 @@ export const ViraPopUpTrigger = defineViraElement()({
77
77
  box-sizing: border-box;
78
78
 
79
79
  ${createFocusStyles({
80
- elementBorderSize: 1,
80
+ elementBorderSize: '1px',
81
81
  })}
82
82
  }
83
83
 
@@ -1,18 +1,6 @@
1
1
  import { type PartialWithUndefined } from '@augment-vir/common';
2
2
  import { type ViraIconSvg } from '../icons/index.js';
3
- /**
4
- * Button styles available for {@link ViraButton}.
5
- *
6
- * @category Button
7
- */
8
- export declare enum ViraButtonStyle {
9
- Default = "vira-button-default",
10
- Outline = "vira-button-outline",
11
- Danger = "vira-button-danger",
12
- DangerOutline = "vira-button-danger-outline",
13
- Ghost = "vira-button-ghost",
14
- Plain = "vira-button-plain"
15
- }
3
+ import { ViraColorVariant, ViraEmphasis, ViraSize } from '../styles/index.js';
16
4
  /**
17
5
  * A custom button with default styling.
18
6
  *
@@ -22,20 +10,33 @@ export declare enum ViraButtonStyle {
22
10
  */
23
11
  export declare const ViraButton: import("element-vir").DeclarativeElementDefinition<"vira-button", PartialWithUndefined<{
24
12
  text: string;
25
- icon: Pick<ViraIconSvg, "svgTemplate">;
26
- disabled: boolean;
27
- buttonStyle: ViraButtonStyle;
13
+ icon: Readonly<ViraIconSvg>;
14
+ /** @default false */
15
+ isDisabled: boolean;
28
16
  /**
29
- * When set to `true`, the given icon (if any) will take up its full dimensions, potentially
30
- * increasing the button's size.
17
+ * Set a predefined emphasis variant. Set to `ViraEmphasis.None` for maximum customization.
31
18
  *
32
- * @default false
19
+ * @default ViraEmphasis.Standard
20
+ */
21
+ buttonEmphasis: ViraEmphasis;
22
+ /**
23
+ * Set a predefined size variant. Set to `ViraSize.None` for maximum customization. In that
24
+ * case, you will need to set a `height`.
25
+ *
26
+ * @default ViraSize.Medium
27
+ */
28
+ buttonSize: ViraSize;
29
+ /**
30
+ * Set a predefined color variant. Set to `ViraColorVariant.None` for maximum customization.
31
+ * In that case, you will need to use this element's CSS vars to customize the colors.
32
+ *
33
+ * @default ViraColorVariant.Accent,
33
34
  */
34
- expandToFitIcon: boolean;
35
+ colorVariant: ViraColorVariant;
35
36
  /**
36
- * If `true`, a menu trigger caret (like in ViraDropdown or ViraSelect) is rendered.
37
+ * Set to `true`
37
38
  *
38
39
  * @default false
39
40
  */
40
41
  showMenuCaret: boolean;
41
- }>, {}, {}, "vira-button-outline-style" | "vira-button-danger-style" | "vira-button-ghost-style" | "vira-button-disabled" | "vira-button-expand-to-fit-icon" | "vira-button-icon-only" | "vira-button-plain-style" | "vira-button-default-style" | "vira-button-with-menu-caret", "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color" | "vira-button-border-color", readonly [], readonly []>;
42
+ }>, {}, {}, "vira-button-with-menu-caret" | "vira-button-size-large" | "vira-button-size-medium" | "vira-button-size-small" | "vira-button-emphasis-standard" | "vira-button-emphasis-subtle" | "vira-button-color-accent" | "vira-button-color-plain" | "vira-button-color-neutral" | "vira-button-color-danger" | "vira-button-color-warning" | "vira-button-color-positive" | "vira-button-disabled" | "vira-button-icon-only", "vira-button-text-color" | "vira-button-background-color" | "vira-button-border-color" | "vira-button-hover-text-color" | "vira-button-hover-background-color" | "vira-button-hover-border-color" | "vira-button-active-text-color" | "vira-button-active-background-color" | "vira-button-active-border-color" | "vira-button-disabled-text-color" | "vira-button-disabled-background-color" | "vira-button-disabled-border-color" | "vira-button-border-width" | "vira-button-border-radius", readonly [], readonly []>;
@@ -1,27 +1,234 @@
1
- import { css, html, nothing } from 'element-vir';
1
+ import { css, html, nothing, unsafeCSS } from 'element-vir';
2
+ import { themeDefaultKey } from 'theme-vir/dist/color-theme/color-theme.js';
2
3
  import { ChevronDown16Icon } from '../icons/index.js';
3
- import { viraDisabledStyles } from '../styles/disabled.js';
4
- import { viraAnimationDurations } from '../styles/durations.js';
5
4
  import { createFocusStyles } from '../styles/focus.js';
6
5
  import { viraFormCssVars } from '../styles/form-styles.js';
7
- import { noUserSelect } from '../styles/index.js';
6
+ import { viraColorVariants, viraEmphasisVariants, viraSizeHeights, viraSizeVariants, } from '../styles/form-variants.js';
7
+ import { noUserSelect, ViraColorVariant, ViraEmphasis, ViraSize, viraTheme, } from '../styles/index.js';
8
8
  import { noNativeFormStyles } from '../styles/native-styles.js';
9
9
  import { defineViraElement } from '../util/define-vira-element.js';
10
10
  import { ViraIcon } from './vira-icon.element.js';
11
- /**
12
- * Button styles available for {@link ViraButton}.
13
- *
14
- * @category Button
15
- */
16
- export var ViraButtonStyle;
17
- (function (ViraButtonStyle) {
18
- ViraButtonStyle["Default"] = "vira-button-default";
19
- ViraButtonStyle["Outline"] = "vira-button-outline";
20
- ViraButtonStyle["Danger"] = "vira-button-danger";
21
- ViraButtonStyle["DangerOutline"] = "vira-button-danger-outline";
22
- ViraButtonStyle["Ghost"] = "vira-button-ghost";
23
- ViraButtonStyle["Plain"] = "vira-button-plain";
24
- })(ViraButtonStyle || (ViraButtonStyle = {}));
11
+ const transparentColor = {
12
+ value: css `transparent`,
13
+ };
14
+ const colorVariantColors = {
15
+ [ViraColorVariant.Plain]: {
16
+ [ViraEmphasis.Standard]: {
17
+ idle: {
18
+ backgroundColor: viraTheme.inverse[themeDefaultKey].background,
19
+ textColor: viraTheme.inverse[themeDefaultKey].foreground,
20
+ borderColor: viraTheme.inverse[themeDefaultKey].background,
21
+ },
22
+ hover: {
23
+ backgroundColor: viraTheme.colors['vira-grey-behind-bg-non-body'].background,
24
+ textColor: viraTheme.colors['vira-grey-behind-bg-non-body'].foreground,
25
+ borderColor: viraTheme.inverse[themeDefaultKey].background,
26
+ },
27
+ active: {
28
+ backgroundColor: viraTheme.colors['vira-grey-behind-bg-body'].background,
29
+ textColor: viraTheme.colors['vira-grey-behind-bg-body'].foreground,
30
+ borderColor: viraTheme.inverse[themeDefaultKey].background,
31
+ },
32
+ },
33
+ [ViraEmphasis.Subtle]: {
34
+ idle: {
35
+ backgroundColor: transparentColor,
36
+ textColor: viraTheme.colors[themeDefaultKey].foreground,
37
+ borderColor: transparentColor,
38
+ },
39
+ hover: {
40
+ backgroundColor: viraTheme.colors['vira-grey-on-self-body'].background,
41
+ textColor: viraTheme.colors['vira-grey-on-self-body'].foreground,
42
+ borderColor: viraTheme.colors['vira-grey-on-self-body'].foreground,
43
+ },
44
+ active: {
45
+ backgroundColor: viraTheme.colors['vira-grey-on-self-non-body'].background,
46
+ textColor: viraTheme.colors['vira-grey-on-self-non-body'].foreground,
47
+ borderColor: viraTheme.colors['vira-grey-on-self-non-body'].foreground,
48
+ },
49
+ },
50
+ },
51
+ [ViraColorVariant.Accent]: {
52
+ [ViraEmphasis.Standard]: {
53
+ idle: {
54
+ backgroundColor: viraTheme.colors['vira-accent-behind-bg-non-body'].background,
55
+ textColor: viraTheme.colors['vira-accent-behind-bg-non-body'].foreground,
56
+ borderColor: viraTheme.colors['vira-accent-behind-bg-body'].background,
57
+ },
58
+ hover: {
59
+ backgroundColor: viraTheme.colors['vira-accent-behind-bg-header'].background,
60
+ textColor: viraTheme.colors['vira-accent-behind-bg-header'].foreground,
61
+ borderColor: viraTheme.colors['vira-accent-behind-bg-body'].background,
62
+ },
63
+ active: {
64
+ backgroundColor: viraTheme.colors['vira-accent-behind-bg-body'].background,
65
+ textColor: viraTheme.colors['vira-accent-behind-bg-body'].foreground,
66
+ borderColor: viraTheme.colors['vira-accent-behind-bg-body'].background,
67
+ },
68
+ },
69
+ [ViraEmphasis.Subtle]: {
70
+ idle: {
71
+ backgroundColor: transparentColor,
72
+ textColor: viraTheme.colors['vira-accent-foreground-non-body'].foreground,
73
+ borderColor: transparentColor,
74
+ },
75
+ hover: {
76
+ backgroundColor: viraTheme.colors['vira-accent-on-self-body'].background,
77
+ textColor: viraTheme.colors['vira-accent-on-self-body'].foreground,
78
+ borderColor: viraTheme.colors['vira-accent-on-self-body'].foreground,
79
+ },
80
+ active: {
81
+ backgroundColor: viraTheme.colors['vira-accent-on-self-non-body'].background,
82
+ textColor: viraTheme.colors['vira-accent-on-self-non-body'].foreground,
83
+ borderColor: viraTheme.colors['vira-accent-on-self-non-body'].foreground,
84
+ },
85
+ },
86
+ },
87
+ [ViraColorVariant.Neutral]: {
88
+ [ViraEmphasis.Standard]: {
89
+ idle: {
90
+ backgroundColor: viraTheme.colors[themeDefaultKey].background,
91
+ textColor: viraTheme.colors[themeDefaultKey].foreground,
92
+ borderColor: viraTheme.colors[themeDefaultKey].foreground,
93
+ },
94
+ hover: {
95
+ backgroundColor: viraTheme.colors['vira-grey-behind-fg-small-body'].background,
96
+ textColor: viraTheme.colors['vira-grey-behind-fg-small-body'].foreground,
97
+ borderColor: viraTheme.colors[themeDefaultKey].foreground,
98
+ },
99
+ active: {
100
+ backgroundColor: viraTheme.colors['vira-grey-behind-fg-body'].background,
101
+ textColor: viraTheme.colors['vira-grey-behind-fg-body'].foreground,
102
+ borderColor: viraTheme.colors[themeDefaultKey].foreground,
103
+ },
104
+ },
105
+ [ViraEmphasis.Subtle]: {
106
+ idle: {
107
+ backgroundColor: transparentColor,
108
+ textColor: viraTheme.colors['vira-grey-foreground-non-body'].foreground,
109
+ borderColor: transparentColor,
110
+ },
111
+ hover: {
112
+ backgroundColor: viraTheme.colors['vira-grey-on-self-body'].background,
113
+ textColor: viraTheme.colors['vira-grey-on-self-body'].foreground,
114
+ borderColor: viraTheme.colors['vira-grey-on-self-body'].foreground,
115
+ },
116
+ active: {
117
+ backgroundColor: viraTheme.colors['vira-grey-on-self-non-body'].background,
118
+ textColor: viraTheme.colors['vira-grey-on-self-non-body'].foreground,
119
+ borderColor: viraTheme.colors['vira-grey-on-self-non-body'].foreground,
120
+ },
121
+ },
122
+ },
123
+ [ViraColorVariant.Danger]: {
124
+ [ViraEmphasis.Standard]: {
125
+ idle: {
126
+ backgroundColor: viraTheme.colors['vira-red-behind-bg-non-body'].background,
127
+ textColor: viraTheme.colors['vira-red-behind-bg-non-body'].foreground,
128
+ borderColor: viraTheme.colors['vira-red-behind-bg-body'].background,
129
+ },
130
+ hover: {
131
+ backgroundColor: viraTheme.colors['vira-red-behind-bg-header'].background,
132
+ textColor: viraTheme.colors['vira-red-behind-bg-header'].foreground,
133
+ borderColor: viraTheme.colors['vira-red-behind-bg-body'].background,
134
+ },
135
+ active: {
136
+ backgroundColor: viraTheme.colors['vira-red-behind-bg-body'].background,
137
+ textColor: viraTheme.colors['vira-red-behind-bg-body'].foreground,
138
+ borderColor: viraTheme.colors['vira-red-behind-bg-body'].background,
139
+ },
140
+ },
141
+ [ViraEmphasis.Subtle]: {
142
+ idle: {
143
+ backgroundColor: transparentColor,
144
+ textColor: viraTheme.colors['vira-red-foreground-non-body'].foreground,
145
+ borderColor: transparentColor,
146
+ },
147
+ hover: {
148
+ backgroundColor: viraTheme.colors['vira-red-on-self-body'].background,
149
+ textColor: viraTheme.colors['vira-red-on-self-body'].foreground,
150
+ borderColor: viraTheme.colors['vira-red-on-self-body'].foreground,
151
+ },
152
+ active: {
153
+ backgroundColor: viraTheme.colors['vira-red-on-self-non-body'].background,
154
+ textColor: viraTheme.colors['vira-red-on-self-non-body'].foreground,
155
+ borderColor: viraTheme.colors['vira-red-on-self-non-body'].foreground,
156
+ },
157
+ },
158
+ },
159
+ [ViraColorVariant.Warning]: {
160
+ [ViraEmphasis.Standard]: {
161
+ idle: {
162
+ backgroundColor: viraTheme.colors['vira-orange-behind-bg-non-body'].background,
163
+ textColor: viraTheme.colors['vira-orange-behind-bg-non-body'].foreground,
164
+ borderColor: viraTheme.colors['vira-orange-behind-bg-body'].background,
165
+ },
166
+ hover: {
167
+ backgroundColor: viraTheme.colors['vira-orange-behind-bg-header'].background,
168
+ textColor: viraTheme.colors['vira-orange-behind-bg-header'].foreground,
169
+ borderColor: viraTheme.colors['vira-orange-behind-bg-body'].background,
170
+ },
171
+ active: {
172
+ backgroundColor: viraTheme.colors['vira-orange-behind-bg-body'].background,
173
+ textColor: viraTheme.colors['vira-orange-behind-bg-body'].foreground,
174
+ borderColor: viraTheme.colors['vira-orange-behind-bg-body'].background,
175
+ },
176
+ },
177
+ [ViraEmphasis.Subtle]: {
178
+ idle: {
179
+ backgroundColor: transparentColor,
180
+ textColor: viraTheme.colors['vira-orange-foreground-non-body'].foreground,
181
+ borderColor: transparentColor,
182
+ },
183
+ hover: {
184
+ backgroundColor: viraTheme.colors['vira-orange-on-self-body'].background,
185
+ textColor: viraTheme.colors['vira-orange-on-self-body'].foreground,
186
+ borderColor: viraTheme.colors['vira-orange-on-self-body'].foreground,
187
+ },
188
+ active: {
189
+ backgroundColor: viraTheme.colors['vira-orange-on-self-non-body'].background,
190
+ textColor: viraTheme.colors['vira-orange-on-self-non-body'].foreground,
191
+ borderColor: viraTheme.colors['vira-orange-on-self-non-body'].foreground,
192
+ },
193
+ },
194
+ },
195
+ [ViraColorVariant.Positive]: {
196
+ [ViraEmphasis.Standard]: {
197
+ idle: {
198
+ backgroundColor: viraTheme.colors['vira-green-behind-bg-non-body'].background,
199
+ textColor: viraTheme.colors['vira-green-behind-bg-non-body'].foreground,
200
+ borderColor: viraTheme.colors['vira-green-behind-bg-body'].background,
201
+ },
202
+ hover: {
203
+ backgroundColor: viraTheme.colors['vira-green-behind-bg-header'].background,
204
+ textColor: viraTheme.colors['vira-green-behind-bg-header'].foreground,
205
+ borderColor: viraTheme.colors['vira-green-behind-bg-body'].background,
206
+ },
207
+ active: {
208
+ backgroundColor: viraTheme.colors['vira-green-behind-bg-body'].background,
209
+ textColor: viraTheme.colors['vira-green-behind-bg-body'].foreground,
210
+ borderColor: viraTheme.colors['vira-green-behind-bg-body'].background,
211
+ },
212
+ },
213
+ [ViraEmphasis.Subtle]: {
214
+ idle: {
215
+ backgroundColor: transparentColor,
216
+ textColor: viraTheme.colors['vira-green-foreground-non-body'].foreground,
217
+ borderColor: transparentColor,
218
+ },
219
+ hover: {
220
+ backgroundColor: viraTheme.colors['vira-green-on-self-body'].background,
221
+ textColor: viraTheme.colors['vira-green-on-self-body'].foreground,
222
+ borderColor: viraTheme.colors['vira-green-on-self-body'].foreground,
223
+ },
224
+ active: {
225
+ backgroundColor: viraTheme.colors['vira-green-on-self-non-body'].background,
226
+ textColor: viraTheme.colors['vira-green-on-self-non-body'].foreground,
227
+ borderColor: viraTheme.colors['vira-green-on-self-non-body'].foreground,
228
+ },
229
+ },
230
+ },
231
+ };
25
232
  /**
26
233
  * A custom button with default styling.
27
234
  *
@@ -32,164 +239,187 @@ export var ViraButtonStyle;
32
239
  export const ViraButton = defineViraElement()({
33
240
  tagName: 'vira-button',
34
241
  hostClasses: {
35
- 'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Outline ||
36
- inputs.buttonStyle === ViraButtonStyle.DangerOutline,
37
- 'vira-button-danger-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Danger ||
38
- inputs.buttonStyle === ViraButtonStyle.DangerOutline,
39
- 'vira-button-ghost-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Ghost,
40
- 'vira-button-disabled': ({ inputs }) => !!inputs.disabled,
41
- 'vira-button-expand-to-fit-icon': ({ inputs }) => !!inputs.expandToFitIcon,
42
- 'vira-button-icon-only': ({ inputs }) => !!inputs.icon && !inputs.text,
43
- 'vira-button-plain-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Plain,
44
- 'vira-button-default-style': ({ inputs }) => !inputs.buttonStyle || inputs.buttonStyle === ViraButtonStyle.Default,
45
242
  'vira-button-with-menu-caret': ({ inputs }) => !!inputs.showMenuCaret,
243
+ 'vira-button-size-large': ({ inputs }) => inputs.buttonSize === ViraSize.Large,
244
+ 'vira-button-size-medium': ({ inputs }) => !inputs.buttonSize || inputs.buttonSize === ViraSize.Medium,
245
+ 'vira-button-size-small': ({ inputs }) => inputs.buttonSize === ViraSize.Small,
246
+ 'vira-button-emphasis-standard': ({ inputs }) => !inputs.buttonEmphasis || inputs.buttonEmphasis === ViraEmphasis.Standard,
247
+ 'vira-button-emphasis-subtle': ({ inputs }) => inputs.buttonEmphasis === ViraEmphasis.Subtle,
248
+ 'vira-button-color-accent': ({ inputs }) => !inputs.colorVariant || inputs.colorVariant === ViraColorVariant.Accent,
249
+ 'vira-button-color-plain': ({ inputs }) => inputs.colorVariant === ViraColorVariant.Plain,
250
+ 'vira-button-color-neutral': ({ inputs }) => inputs.colorVariant === ViraColorVariant.Neutral,
251
+ 'vira-button-color-danger': ({ inputs }) => inputs.colorVariant === ViraColorVariant.Danger,
252
+ 'vira-button-color-warning': ({ inputs }) => inputs.colorVariant === ViraColorVariant.Warning,
253
+ 'vira-button-color-positive': ({ inputs }) => inputs.colorVariant === ViraColorVariant.Positive,
254
+ 'vira-button-disabled': ({ inputs }) => !!inputs.isDisabled,
255
+ 'vira-button-icon-only': ({ inputs }) => !inputs.text && !!inputs.icon,
46
256
  },
47
257
  cssVars: {
48
- 'vira-button-padding': '5px 10px',
49
- 'vira-button-internal-foreground-color': viraFormCssVars['vira-form-background-color'].value,
50
- 'vira-button-internal-background-color': viraFormCssVars['vira-form-accent-primary-color'].value,
258
+ 'vira-button-text-color': 'transparent',
259
+ 'vira-button-background-color': 'transparent',
51
260
  'vira-button-border-color': 'transparent',
261
+ 'vira-button-hover-text-color': 'transparent',
262
+ 'vira-button-hover-background-color': 'transparent',
263
+ 'vira-button-hover-border-color': 'transparent',
264
+ 'vira-button-active-text-color': 'transparent',
265
+ 'vira-button-active-background-color': 'transparent',
266
+ 'vira-button-active-border-color': 'transparent',
267
+ 'vira-button-disabled-text-color': viraTheme.colors['vira-grey-behind-bg-decoration'].foreground.value,
268
+ 'vira-button-disabled-background-color': viraTheme.colors['vira-grey-behind-bg-decoration'].background.value,
269
+ 'vira-button-disabled-border-color': viraTheme.colors['vira-grey-behind-bg-decoration'].background.value,
270
+ 'vira-button-border-width': '1px',
271
+ 'vira-button-border-radius': viraFormCssVars['vira-form-radius'].value,
52
272
  },
53
- styles: ({ hostClasses, cssVars }) => css `
54
- :host {
55
- height: 32px;
56
- font-weight: bold;
57
- display: inline-flex;
58
- position: relative;
59
- vertical-align: middle;
60
- align-items: center;
61
- box-sizing: border-box;
62
- ${noUserSelect};
63
- ${viraFormCssVars['vira-form-focus-outline-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value}
64
- }
273
+ styles: ({ hostClasses, cssVars }) => {
274
+ function generateVariantCss() {
275
+ const allStyles = viraEmphasisVariants.flatMap((emphasis) => {
276
+ return viraColorVariants.map((colorVariant) => {
277
+ const colors = colorVariantColors[colorVariant][emphasis];
278
+ const variantSelector = hostClasses[`vira-button-color-${colorVariant}`].selector;
279
+ const emphasisSelector = hostClasses[`vira-button-emphasis-${emphasis}`].selector;
280
+ return css `
281
+ ${variantSelector}${emphasisSelector} {
282
+ ${cssVars['vira-button-background-color'].name}: ${colors.idle
283
+ .backgroundColor.value};
284
+ ${cssVars['vira-button-text-color'].name}: ${colors.idle.textColor
285
+ .value};
286
+ ${cssVars['vira-button-border-color'].name}: ${colors.idle.borderColor
287
+ .value};
65
288
 
66
- ${hostClasses['vira-button-icon-only'].selector} {
67
- ${cssVars['vira-button-padding'].name}: 5px;
68
- }
289
+ ${cssVars['vira-button-hover-background-color'].name}: ${colors.hover
290
+ .backgroundColor.value};
291
+ ${cssVars['vira-button-hover-text-color'].name}: ${colors.hover
292
+ .textColor.value};
293
+ ${cssVars['vira-button-hover-border-color'].name}: ${colors.hover
294
+ .borderColor.value};
69
295
 
70
- ${hostClasses['vira-button-disabled'].selector} {
71
- ${viraDisabledStyles};
296
+ ${cssVars['vira-button-active-background-color'].name}: ${colors.active
297
+ .backgroundColor.value};
298
+ ${cssVars['vira-button-active-text-color'].name}: ${colors.active
299
+ .textColor.value};
300
+ ${cssVars['vira-button-active-border-color'].name}: ${colors.active
301
+ .borderColor.value};
302
+ }
303
+ `;
304
+ });
305
+ });
306
+ return unsafeCSS(allStyles.join('\n'));
72
307
  }
308
+ function generateSizeVariantCss() {
309
+ const styles = viraSizeVariants.map((sizeVariant) => {
310
+ return css `
311
+ ${hostClasses[`vira-button-size-${sizeVariant}`].selector} {
312
+ height: ${viraSizeHeights[sizeVariant]}px;
313
+ font-size: ${viraFormCssVars[`vira-form-${sizeVariant}-text-size`].value};
73
314
 
74
- :host(:hover) button,
75
- button:hover {
76
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value};
315
+ button {
316
+ padding: 0
317
+ ${viraFormCssVars[`vira-form-${sizeVariant}-text-size`].value};
318
+ }
319
+ }
320
+ `;
321
+ });
322
+ return unsafeCSS(styles.join('\n'));
77
323
  }
324
+ return css `
325
+ :host {
326
+ cursor: pointer;
327
+ display: inline-flex;
328
+ position: relative;
329
+ vertical-align: middle;
330
+ align-items: center;
331
+ box-sizing: border-box;
332
+ ${noUserSelect};
333
+ ${viraFormCssVars['vira-form-focus-outline-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value}
334
+ }
78
335
 
79
- :host(:active) button,
80
- button:active {
81
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-accent-primary-active-color'].value};
82
- }
336
+ ${generateSizeVariantCss()}
337
+ ${generateVariantCss()}
83
338
 
84
- ${hostClasses['vira-button-danger-style'].selector} {
85
- & button {
86
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-color'].value};
87
- }
339
+ button {
340
+ ${noNativeFormStyles};
341
+ flex-shrink: 0;
342
+ position: relative;
343
+ cursor: pointer;
88
344
 
89
- &:hover button,
90
- & button:hover {
91
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-hover-color'].value};
92
- }
345
+ width: 100%;
346
+ height: 100%;
93
347
 
94
- &:active button,
95
- & button:active {
96
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-error-active-color'].value};
97
- }
98
- }
348
+ border-width: ${cssVars['vira-button-border-width'].value};
349
+ border-style: solid;
350
+ border-color: ${cssVars['vira-button-border-color'].value};
99
351
 
100
- ${hostClasses['vira-button-ghost-style'].selector} {
101
- & button {
102
- ${cssVars['vira-button-internal-background-color'].name}: transparent;
103
- ${cssVars['vira-button-internal-foreground-color'].name}: currentColor;
104
- }
352
+ box-sizing: border-box;
353
+ display: inline-flex;
354
+ justify-content: center;
355
+ align-items: center;
105
356
 
106
- &:hover button,
107
- & button:hover {
108
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-filled-background-color'].value};
109
- }
357
+ border-radius: ${cssVars['vira-button-border-radius'].value};
110
358
 
111
- &:active button,
112
- & button:active {
113
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-filled-active-background-color'].value};
114
- }
115
- }
359
+ background-color: ${cssVars['vira-button-background-color'].value};
360
+ color: ${cssVars['vira-button-text-color'].value};
116
361
 
117
- ${hostClasses['vira-button-plain-style'].selector} {
118
- & button {
119
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-plain-color'].value};
120
- color: currentColor;
121
- ${cssVars['vira-button-border-color'].name}: ${viraFormCssVars['vira-form-plain-active-color'].value};
122
- border-width: 1px;
362
+ ${createFocusStyles({
363
+ elementBorderSize: cssVars['vira-button-border-width'],
364
+ })}
123
365
  }
124
- &:hover button,
366
+
367
+ :host(:hover) button,
125
368
  & button:hover {
126
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-plain-hover-color'].value};
369
+ background-color: ${cssVars['vira-button-hover-background-color'].value};
370
+ color: ${cssVars['vira-button-hover-text-color'].value};
371
+ border-color: ${cssVars['vira-button-hover-border-color'].value};
127
372
  }
128
373
 
129
- &:active button,
374
+ :host(:active) button,
130
375
  & button:active {
131
- ${cssVars['vira-button-internal-background-color'].name}: ${viraFormCssVars['vira-form-plain-active-color'].value};
376
+ background-color: ${cssVars['vira-button-active-background-color'].value};
377
+ color: ${cssVars['vira-button-active-text-color'].value};
378
+ border-color: ${cssVars['vira-button-active-border-color'].value};
132
379
  }
133
- }
134
-
135
- ${hostClasses['vira-button-outline-style'].selector} button {
136
- color: ${cssVars['vira-button-internal-background-color'].value};
137
- background-color: ${cssVars['vira-button-internal-foreground-color'].value};
138
- ${cssVars['vira-button-border-color'].name}: currentColor;
139
- }
140
380
 
141
- button {
142
- ${noNativeFormStyles};
143
- cursor: pointer;
144
- position: relative;
145
- width: 100%;
146
- height: 100%;
147
- border: 2px solid ${cssVars['vira-button-border-color'].value};
148
- box-sizing: border-box;
149
- display: inline-flex;
150
- justify-content: center;
151
- align-items: center;
152
- border-radius: ${viraFormCssVars['vira-form-radius'].value};
153
- background-color: ${cssVars['vira-button-internal-background-color'].value};
154
- color: ${cssVars['vira-button-internal-foreground-color'].value};
155
- padding: ${cssVars['vira-button-padding'].value};
156
- transition:
157
- color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
158
- background-color
159
- ${viraAnimationDurations['vira-interaction-animation-duration'].value},
160
- border-color ${viraAnimationDurations['vira-interaction-animation-duration'].value};
161
-
162
- ${createFocusStyles({
163
- elementBorderSize: 2,
164
- })}
165
- }
166
-
167
- .empty-text {
168
- width: 0;
169
- }
381
+ .empty-text {
382
+ width: 0;
383
+ }
170
384
 
171
- button ${ViraIcon} + .text-template {
172
- margin-left: 8px;
173
- }
385
+ button ${ViraIcon} + .text-template {
386
+ margin-left: 8px;
387
+ }
174
388
 
175
- :host(:not(.${hostClasses['vira-button-expand-to-fit-icon'].name})) {
176
- & ${ViraIcon} {
389
+ ${ViraIcon} {
177
390
  height: 0;
178
391
  display: flex;
179
392
  align-items: center;
180
393
  }
181
- }
182
394
 
183
- .caret-icon {
184
- margin-left: 8px;
185
- }
395
+ .caret-icon {
396
+ margin-left: 8px;
397
+ }
186
398
 
187
- ${hostClasses['vira-button-with-menu-caret'].selector} {
188
- button {
189
- padding-right: 6px;
399
+ ${hostClasses['vira-button-with-menu-caret'].selector} {
400
+ button {
401
+ padding-right: 6px;
402
+ }
190
403
  }
191
- }
192
- `,
404
+
405
+ ${hostClasses['vira-button-disabled'].selector} {
406
+ cursor: not-allowed;
407
+
408
+ & button {
409
+ pointer-events: none;
410
+ color: ${cssVars['vira-button-disabled-text-color'].value};
411
+ background-color: ${cssVars['vira-button-disabled-background-color'].value};
412
+ border-color: ${cssVars['vira-button-disabled-border-color'].value};
413
+ }
414
+ }
415
+
416
+ ${hostClasses['vira-button-icon-only'].selector} {
417
+ button {
418
+ aspect-ratio: 1;
419
+ }
420
+ }
421
+ `;
422
+ },
193
423
  render: ({ inputs }) => {
194
424
  const iconTemplate = inputs.icon
195
425
  ? html `
@@ -215,7 +445,7 @@ export const ViraButton = defineViraElement()({
215
445
  `
216
446
  : nothing;
217
447
  return html `
218
- <button ?disabled=${inputs.disabled}>
448
+ <button ?disabled=${inputs.isDisabled}>
219
449
  ${iconTemplate}${textTemplate}${caretIconTemplate}
220
450
  </button>
221
451
  `;
@@ -107,7 +107,7 @@ export const ViraCheckbox = defineViraElement()({
107
107
  cursor: pointer;
108
108
 
109
109
  ${createFocusStyles({
110
- elementBorderSize: 1,
110
+ elementBorderSize: '1px',
111
111
  })}
112
112
 
113
113
  &.checked {