Skip to content

Commit 823c401

Browse files
authored
refactor(material/button): switch raised-button to density tokens (#27866)
* refactor(material/button): switch raised-button to density tokens * fixup! refactor(material/button): switch raised-button to density tokens
1 parent 6ec51e7 commit 823c401

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/material/button/_button-theme.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,13 @@
226226
@mixin density($theme) {
227227
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
228228

229+
.mat-mdc-raised-button {
230+
$density-tokens: tokens-mdc-button-protected.get-density-tokens($theme);
231+
@include mdc-button-protected-theme.theme($density-tokens);
232+
@include button-theme-private.touch-target-density($density-scale);
233+
}
234+
229235
.mat-mdc-button,
230-
.mat-mdc-raised-button,
231236
.mat-mdc-unelevated-button,
232237
.mat-mdc-outlined-button {
233238
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.

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

Lines changed: 15 additions & 2 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-protected);
@@ -15,7 +17,6 @@ $prefix: (mdc, button-protected);
1517
@function get-unthemable-tokens() {
1618
@return (
1719
container-shape: 4px,
18-
container-height: 36px,
1920
keep-touch-target: false,
2021

2122
focus-ring-color: null,
@@ -79,7 +80,19 @@ $prefix: (mdc, button-protected);
7980

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

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

0 commit comments

Comments
 (0)