From 862ce3d9e1fa3039de1738bf41d0d176c3a930c7 Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Thu, 28 Sep 2023 15:40:23 -0400 Subject: [PATCH 1/2] refactor(material/button): switch raised-button to density tokens --- src/material/button/_button-theme.scss | 6 +++++- .../core/tokens/m2/mdc/_button-protected.scss | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/material/button/_button-theme.scss b/src/material/button/_button-theme.scss index 5d6ca3d536da..8e10d14077b5 100644 --- a/src/material/button/_button-theme.scss +++ b/src/material/button/_button-theme.scss @@ -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. diff --git a/src/material/core/tokens/m2/mdc/_button-protected.scss b/src/material/core/tokens/m2/mdc/_button-protected.scss index 489477d56f1e..4fe73d9c680b 100644 --- a/src/material/core/tokens/m2/mdc/_button-protected.scss +++ b/src/material/core/tokens/m2/mdc/_button-protected.scss @@ -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); @@ -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, @@ -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. From f6f399020de7af340d0ebd64ae59442bacabae91 Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Mon, 2 Oct 2023 13:44:42 -0400 Subject: [PATCH 2/2] fixup! refactor(material/button): switch raised-button to density tokens --- src/material/button/_button-theme.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/material/button/_button-theme.scss b/src/material/button/_button-theme.scss index 8e10d14077b5..e4932052b81a 100644 --- a/src/material/button/_button-theme.scss +++ b/src/material/button/_button-theme.scss @@ -229,6 +229,7 @@ .mat-mdc-raised-button { $density-tokens: tokens-mdc-button-protected.get-density-tokens($theme); @include mdc-button-protected-theme.theme($density-tokens); + @include button-theme-private.touch-target-density($density-scale); } .mat-mdc-button,