Skip to content

Commit

Permalink
refactor(material/button): switch raised-button to density tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnermaciel committed Sep 28, 2023
1 parent 06559a0 commit 862ce3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/material/button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,12 @@
@mixin density($theme) {
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);

.mat-mdc-raised-button {
$density-tokens: tokens-mdc-button-protected.get-density-tokens($theme);
@include mdc-button-protected-theme.theme($density-tokens);
}

.mat-mdc-button,
.mat-mdc-raised-button,
.mat-mdc-unelevated-button,
.mat-mdc-outlined-button {
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
Expand Down
17 changes: 15 additions & 2 deletions src/material/core/tokens/m2/mdc/_button-protected.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, button-protected);
Expand All @@ -15,7 +17,6 @@ $prefix: (mdc, button-protected);
@function get-unthemable-tokens() {
@return (
container-shape: 4px,
container-height: 36px,
keep-touch-target: false,

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

// 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 862ce3d

Please sign in to comment.