Skip to content

Commit a39ab3c

Browse files
Improve ha button radius variables (#26382)
* Improve ha button radius variables * fixes --------- Co-authored-by: Bram Kragten <[email protected]>
1 parent 797d2be commit a39ab3c

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

gallery/src/pages/components/ha-button.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ Check the [webawesome documentation](https://webawesome.com/docs/components/butt
6464
**CSS Custom Properties**
6565

6666
- `--ha-button-height` - Height of the button.
67-
- `--ha-button-radius` - Border radius of the button. Defaults to `var(--wa-border-radius-pill)`.
67+
- `--ha-button-border-radius` - Border radius of the button. Defaults to `var(--border-radius-pill)`.

src/components/ha-button.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type Appearance = "accent" | "filled" | "outlined" | "plain";
2727
* @csspart spinner - The spinner that shows when the button is in the loading state.
2828
*
2929
* @cssprop --ha-button-height - The height of the button.
30-
* @cssprop --ha-button-radius - The border radius of the button. defaults to `var(--wa-border-radius-pill)`.
30+
* @cssprop --ha-button-border-radius - The border radius of the button. defaults to `var(--border-radius-pill)`.
3131
*
3232
* @attr {("small"|"medium")} size - Sets the button size.
3333
* @attr {("brand"|"neutral"|"danger"|"warning"|"success")} variant - Sets the button color variant. "primary" is default.
@@ -55,10 +55,9 @@ export class HaButton extends Button {
5555
/* set theme vars */
5656
--wa-form-control-padding-inline: 16px;
5757
--wa-font-weight-action: var(--ha-font-weight-medium);
58-
--wa-border-radius-pill: 9999px;
5958
--wa-form-control-border-radius: var(
60-
--ha-button-radius,
61-
var(--wa-border-radius-pill)
59+
--ha-button-border-radius,
60+
var(--border-radius-pill)
6261
);
6362
6463
--wa-form-control-height: var(

src/components/ha-fab.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ export class HaFab extends FabBase {
2020
--mdc-typography-button-font-family: var(--ha-font-family-body);
2121
--mdc-typography-button-font-weight: var(--ha-font-weight-medium);
2222
}
23+
:host .mdc-fab--extended {
24+
border-radius: var(
25+
--ha-button-border-radius,
26+
var(--border-radius-pill)
27+
);
28+
}
29+
:host .mdc-fab.mdc-fab--extended .ripple {
30+
border-radius: var(
31+
--ha-button-border-radius,
32+
var(--border-radius-pill)
33+
);
34+
}
2335
:host .mdc-fab--extended .mdc-fab__icon {
2436
margin-inline-start: -8px;
2537
margin-inline-end: 12px;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { css } from "lit";
2+
import { extractDerivedVars } from "../../common/style/derived-css-vars";
3+
4+
export const coreStyles = css`
5+
html {
6+
--border-width-sm: 1px;
7+
--border-width-md: 2px;
8+
--border-width-lg: 3px;
9+
10+
--border-radius-sm: 4px;
11+
--border-radius-md: 8px;
12+
--border-radius-lg: 12px;
13+
--border-radius-xl: 16px;
14+
--border-radius-2xl: 24px;
15+
--border-radius-3xl: 28px;
16+
--border-radius-4xl: 32px;
17+
--border-radius-5xl: 36px;
18+
--border-radius-pill: 9999px;
19+
--border-radius-circle: 50%;
20+
--border-radius-square: 0;
21+
}
22+
`;
23+
24+
export const coreDerivedVariables = extractDerivedVars(coreStyles);

src/resources/theme/theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { fontStyles } from "../roboto";
22
import { colorDerivedVariables, colorStylesCollection } from "./color";
3+
import { coreDerivedVariables, coreStyles } from "./core.globals";
34
import { mainDerivedVariables, mainStyles } from "./main.globals";
45
import {
56
typographyDerivedVariables,
@@ -8,6 +9,7 @@ import {
89
import { waMainDerivedVariables, waMainStyles } from "./wa.globals";
910

1011
export const themeStyles = [
12+
coreStyles.toString(),
1113
mainStyles.toString(),
1214
typographyStyles.toString(),
1315
...colorStylesCollection,
@@ -16,6 +18,7 @@ export const themeStyles = [
1618
].join("");
1719

1820
export const derivedStyles = {
21+
...coreDerivedVariables,
1922
...mainDerivedVariables,
2023
...typographyDerivedVariables,
2124
...colorDerivedVariables,

0 commit comments

Comments
 (0)