|
6 | 6 |
|
7 | 7 | $_internals: _mat-theming-internals-do-not-access;
|
8 | 8 |
|
| 9 | +/// Validates that the given value is a versioned theme object. |
| 10 | +/// @param {Any} $theme The theme object to validate. |
| 11 | +/// @return {Boolean|Null} true if the theme has errors, else null. |
9 | 12 | @function _validate-theme-object($theme) {
|
10 | 13 | $err: validation.validate-type($theme, 'map') or
|
11 | 14 | map.get($theme, $_internals, theme-version) == null;
|
12 | 15 | @return if($err, true, null);
|
13 | 16 | }
|
14 | 17 |
|
| 18 | +/// Gets the version number of a theme object. A theme that is not a valid versioned theme object is |
| 19 | +/// considered to be version 0. |
| 20 | +/// @param {Map} $theme The theme to check the version of |
| 21 | +/// @return {Number} The version number of the theme (0 if unknown). |
15 | 22 | @function get-theme-version($theme) {
|
16 | 23 | $err: _validate-theme-object($theme);
|
17 | 24 | @return if($err, 0, map.get($theme, $_internals, theme-version) or 0);
|
18 | 25 | }
|
19 | 26 |
|
| 27 | +/// Gets the set of tokens from the given theme, limited to those affected by the requested theming |
| 28 | +/// systems. |
| 29 | +/// @param {Map} $theme The theme to get tokens from. |
| 30 | +/// @param {String...} $systems The theming systems to get tokens for. Valid values are: color, |
| 31 | +/// typography, density, other. If no systems are passed, all tokens will be returned. |
| 32 | +/// @return {Map} The requested tokens for the theme. |
20 | 33 | @function get-theme-tokens($theme, $systems...) {
|
21 | 34 | $systems: if(list.length($systems) == 0, (color, typography, density, other), $systems);
|
22 | 35 | $err: _validate-theme-object($theme);
|
|
0 commit comments