55@use ' ../typography/typography-utils' ;
66@use ' ../typography/typography' ;
77
8+ /// Key used to access the Angular Material theme internals.
89$_internals : _mat- theming- internals- do- not- access;
910
11+ /// Keys that indicate a config object is a color config.
1012$_color-keys : (
1113 primary,
1214 accent,
@@ -17,6 +19,7 @@ $_color-keys: (
1719 color , /* included for themes that incorrectly nest the color config: (color: (color: (....))) */
1820);
1921
22+ /// Keys that indicate a config object is a typography config.
2023$_typography-keys : (
2124 headline- 1,
2225 headline- 2,
@@ -34,9 +37,23 @@ $_typography-keys: (
3437 overline ,
3538);
3639
40+ /// The CSS typography properties supported by the inspection API.
3741$_typography-properties : (font , font-family , line-height , font-size , letter-spacing , font-weight );
3842
39- /// Checks whether the given theme contains error objects.
43+ /// Gets the m2-config from the theme.
44+ @function _get-m2-config ($theme ) {
45+ // It is possible for a user to pass a "density theme" that is just a number.
46+ @if meta .type-of ($theme ) != ' map' {
47+ @return $theme ;
48+ }
49+ $internal : map .get ($theme , $_internals , m2-config );
50+ $theme : map .remove ($theme , $_internals );
51+ @return if (_is-error-theme ($theme ), $internal , $theme );
52+ }
53+
54+ /// Checks whether the given theme contains error values.
55+ /// @param {*} $theme The theme to check.
56+ /// @return {Boolean} true if the theme contains error values, else false.
4057@function _is-error-theme ($theme ) {
4158 @if meta .type-of ($theme ) != ' map' {
4259 @return false;
@@ -47,15 +64,24 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
4764 @return _is-error-theme (list .nth (map .values ($theme ), 1 ));
4865}
4966
50- /// Gets the m2-config from the theme.
51- @function _get-m2-config ($theme ) {
52- // It is possible for a user to pass a "density theme" that is just a number.
53- @if meta .type-of ($theme ) != ' map' {
54- @return $theme ;
67+ /// Checks whether the given theme object has any of the given keys.
68+ /// @param {Map} $theme The theme to check
69+ /// @param {List} $keys The keys to check for
70+ /// @return {Boolean} Whether the theme has any of the given keys.
71+ @function _has-any-key ($theme , $keys ) {
72+ @each $key in $keys {
73+ @if map .has-key ($theme , $key ) {
74+ @return true;
75+ }
5576 }
56- $internal : map .get ($theme , $_internals , m2-config );
57- $theme : map .remove ($theme , $_internals );
58- @return if (_is-error-theme ($theme ), $internal , $theme );
77+ @return false;
78+ }
79+
80+ /// Checks whether the given theme is a density scale value.
81+ /// @param {*} $theme The theme to check.
82+ /// @return {Boolean} true if the theme is a density scale value, else false.
83+ @function _is-density-value ($theme ) {
84+ @return $theme == minimum or $theme == maximum or meta .type-of ($theme ) == ' number' ;
5985}
6086
6187/// Gets the type of theme represented by a theme object (light or dark).
@@ -177,16 +203,3 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
177203 }
178204 @error ' Valid systems are: base, color, typography, density. Got:' $system ;
179205}
180-
181- @function _has-any-key ($theme , $keys ) {
182- @each $key in $keys {
183- @if map .has-key ($theme , $key ) {
184- @return true;
185- }
186- }
187- @return false;
188- }
189-
190- @function _is-density-value ($theme ) {
191- @return $theme == minimum or $theme == maximum or meta .type-of ($theme ) == ' number' ;
192- }
0 commit comments