Skip to content

Commit

Permalink
refactor(material/button): switch outlined-button to density tokens (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnermaciel authored Oct 25, 2023
1 parent e9fc04d commit 69d5ebd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/material/button/_button-theme.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use '@material/button/button' as mdc-button;
@use '@material/button/button-theme' as mdc-button-theme;
@use '@material/button/button-text-theme' as mdc-button-text-theme;
@use '@material/button/button-filled-theme' as mdc-button-filled-theme;
@use '@material/button/button-protected-theme' as mdc-button-protected-theme;
Expand Down Expand Up @@ -256,11 +255,9 @@
}

.mat-mdc-outlined-button {
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
&.mat-mdc-button-base {
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mdc-base-styles-query);
@include button-theme-private.touch-target-density($density-scale);
}
$density-tokens: tokens-mdc-outlined-button.get-density-tokens($theme);
@include mdc-button-outlined-theme.theme($density-tokens);
@include button-theme-private.touch-target-density($density-scale);
}
}

Expand Down
21 changes: 17 additions & 4 deletions src/material/core/tokens/m2/mdc/_outlined-button.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@use 'sass:map';
@use '../../token-utils';
@use '../../../mdc-helpers/mdc-helpers';
@use '../../../style/sass-utils';
@use '../../../theming/inspection';
@use '../../../theming/theming';

// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, outlined-button);
Expand Down Expand Up @@ -49,9 +51,7 @@ $prefix: (mdc, outlined-button);
label-text-font: null,
label-text-weight: null,
label-text-tracking: null,
label-text-transform: null,

container-height: 36px
label-text-transform: null
);
}

Expand Down Expand Up @@ -82,7 +82,20 @@ $prefix: (mdc, outlined-button);

// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);

@return (
container-height:
map.get(
(
0: 36px,
-1: 32px,
-2: 28px,
-3: 24px,
),
$scale
)
);
}

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

0 comments on commit 69d5ebd

Please sign in to comment.