11@use ' sass:map' ;
2+ @use ' sass:list' ;
23@use ' ../core/tokens/m3-utils' ;
34@use ' ../core/style/sass-utils' ;
45@use ' ../core/style/elevation' ;
6+ @use ' ../core/theming/theming' ;
7+ @use ' ../core/theming/inspection' ;
58
69// The prefix used to generate the fully qualified name for tokens in this file.
710$prefix : (mat, button);
@@ -14,7 +17,6 @@ $prefix: (mat, button);
1417@function get-tokens ($systems , $exclude-hardcoded , $token-slots ) {
1518 $tokens : (
1619 filled- container- color: map .get ($systems , md-sys-color , primary ),
17- filled- container- height: if ($exclude-hardcoded , null , 40px ),
1820 filled- container- shape: map .get ($systems , md-sys-shape , corner-full ),
1921 filled- disabled- container- color: sass-utils .safe-color-change (
2022 map .get ($systems , md-sys-color , on-surface ), $alpha : 0.12 ),
@@ -37,7 +39,6 @@ $prefix: (mat, button);
3739 map .get ($systems , md-sys-color , on-primary ),
3840 $alpha : map .get ($systems , md-sys-state , pressed-state-layer-opacity ) ),
3941 filled- state- layer- color: map .get ($systems , md-sys-color , on-primary ),
40- outlined- container- height: if ($exclude-hardcoded , null , 40px ),
4142 outlined- container- shape: map .get ($systems , md-sys-shape , corner-full ),
4243 outlined- disabled- label- text- color: sass-utils .safe-color-change (
4344 map .get ($systems , md-sys-color , on-surface ), $alpha : 0.38 ),
@@ -64,7 +65,6 @@ $prefix: (mat, button);
6465 outlined- state- layer- color: map .get ($systems , md-sys-color , primary ),
6566 protected- container- color: map .get ($systems , md-sys-color , surface ),
6667 protected- container- elevation- shadow: map .get ($systems , md-sys-elevation , level1 ),
67- protected- container- height: if ($exclude-hardcoded , null , 40px ),
6868 protected- container- shape: map .get ($systems , md-sys-shape , corner-full ),
6969 protected- disabled- container- color: sass-utils .safe-color-change (
7070 map .get ($systems , md-sys-color , on-surface ), $alpha : 0.12 ),
@@ -91,7 +91,6 @@ $prefix: (mat, button);
9191 map .get ($systems , md-sys-color , primary ),
9292 $alpha : map .get ($systems , md-sys-state , pressed-state-layer-opacity )),
9393 protected- state- layer- color: map .get ($systems , md-sys-color , primary ),
94- text- container- height: if ($exclude-hardcoded , null , 40px ),
9594 text- container- shape: map .get ($systems , md-sys-shape , corner-full ),
9695 text- disabled- label- text- color: sass-utils .safe-color-change (
9796 map .get ($systems , md-sys-color , on-surface ), $alpha : 0.38 ),
@@ -113,7 +112,6 @@ $prefix: (mat, button);
113112 text- state- layer- color: map .get ($systems , md-sys-color , primary ),
114113 text- with- icon- horizontal- padding: m3-utils .hardcode (16px , $exclude-hardcoded ),
115114 tonal- container- color: map .get ($systems , md-sys-color , secondary-container ),
116- tonal- container- height: if ($exclude-hardcoded , null , 40px ),
117115 tonal- container- shape: map .get ($systems , md-sys-shape , corner-full ),
118116 tonal- disabled- container- color: sass-utils .safe-color-change (
119117 map .get ($systems , md-sys-color , on-surface ), $alpha : 0.12 ),
@@ -241,3 +239,22 @@ $prefix: (mat, button);
241239
242240 @return m3-utils .namespace ($prefix , ($tokens , $variant-tokens ), $token-slots );
243241}
242+
243+ // Tokens that can be configured through Angular Material's density theming API.
244+ @function get-density-tokens ($theme ) {
245+ $scale : theming .clamp-density (inspection .get-theme-density ($theme ), -3 );
246+ $index : ($scale * -1 ) + 1 ;
247+
248+ @return (
249+ filled- touch- target- display: list .nth ((block , block , none , none ), $index ),
250+ filled- container- height: list .nth ((40px , 36px , 32px , 28px ), $index ),
251+ outlined- container- height: list .nth ((40px , 36px , 32px , 28px ), $index ),
252+ outlined- touch- target- display: list .nth ((block , block , none , none ), $index ),
253+ protected- touch- target- display: list .nth ((block , block , none , none ), $index ),
254+ protected- container- height: list .nth ((40px , 36px , 32px , 28px ), $index ),
255+ text- touch- target- display: list .nth ((block , block , none , none ), $index ),
256+ text- container- height: list .nth ((40px , 36px , 32px , 28px ), $index ),
257+ tonal- container- height: list .nth ((40px , 36px , 32px , 28px ), $index ),
258+ tonal- touch- target- display: list .nth ((block , block , none , none ), $index ),
259+ );
260+ }
0 commit comments