Skip to content

Commit 2a0da06

Browse files
committed
refactor(material/button): switch flat-button to density tokens
1 parent 48a988a commit 2a0da06

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/material/button/_button-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,13 @@
207207
@mixin density($theme) {
208208
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
209209

210+
.mat-mdc-unelevated-button {
211+
$density-tokens: tokens-mdc-button-filled.get-density-tokens($theme);
212+
@include mdc-button-filled-theme.theme($density-tokens);
213+
}
214+
210215
.mat-mdc-button,
211216
.mat-mdc-raised-button,
212-
.mat-mdc-unelevated-button,
213217
.mat-mdc-outlined-button {
214218
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
215219
&.mat-mdc-button-base {

src/material/core/tokens/m2/mdc/_button-filled.scss

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
@use 'sass:map';
12
@use '../../token-utils';
23
@use '../../../mdc-helpers/mdc-helpers';
34
@use '../../../style/sass-utils';
45
@use '../../../theming/inspection';
6+
@use '../../../theming/theming';
57

68
// The prefix used to generate the fully qualified name for tokens in this file.
79
$prefix: (mdc, button-filled);
@@ -15,8 +17,6 @@ $prefix: (mdc, button-filled);
1517
@function get-unthemable-tokens() {
1618
@return (
1719
container-elevation: 0,
18-
container-height: 36px,
19-
container-shape: 4px,
2020
disabled-container-elevation: 0,
2121
focus-container-elevation: 0,
2222
hover-container-elevation: 0,
@@ -77,7 +77,21 @@ $prefix: (mdc, button-filled);
7777

7878
// Tokens that can be configured through Angular Material's density theming API.
7979
@function get-density-tokens($theme) {
80-
@return ();
80+
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
81+
82+
@return (
83+
container-height:
84+
map.get(
85+
(
86+
0: 36px,
87+
-1: 32px,
88+
-2: 28px,
89+
-3: 24px,
90+
),
91+
$scale
92+
),
93+
container-shape: 4px
94+
);
8195
}
8296

8397
// Combines the tokens generated by the above functions into a single map with placeholder values.

0 commit comments

Comments
 (0)