|
57 | 57 | );
|
58 | 58 | }
|
59 | 59 |
|
| 60 | +$_cached-token-slots: null; |
| 61 | + |
| 62 | +/// Determines the token slots for all components. |
| 63 | +@function _get-token-slots() { |
| 64 | + // Cache the slots since they're constant and calculating |
| 65 | + // them appears to be expensive (see #29009). |
| 66 | + @if ($_cached-token-slots) { |
| 67 | + @return $_cached-token-slots; |
| 68 | + } |
| 69 | + |
| 70 | + // TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of |
| 71 | + // material-experimental. This is a hack for now because there is no good way to get the token |
| 72 | + // slots in material-experimental without exposing them all from material. |
| 73 | + $fake-theme: m2-theming.define-light-theme(( |
| 74 | + color: ( |
| 75 | + primary: m2-theming.define-palette(m2-theming.$red-palette), |
| 76 | + accent: m2-theming.define-palette(m2-theming.$red-palette), |
| 77 | + warn: m2-theming.define-palette(m2-theming.$red-palette), |
| 78 | + ), |
| 79 | + typography: m2-theming.define-typography-config(), |
| 80 | + density: 0 |
| 81 | + )); |
| 82 | + $_cached-token-slots: m2-tokens.m2-tokens-from-theme($fake-theme) !global; |
| 83 | + @return $_cached-token-slots; |
| 84 | +} |
| 85 | + |
60 | 86 | /// Generates a set of namespaced tokens for all components.
|
61 | 87 | /// @param {Map} $systems The MDC system tokens
|
62 | 88 | /// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
|
|
75 | 101 | // DO NOT REMOVE
|
76 | 102 | // This function is used internally.
|
77 | 103 | $systems: format-tokens.private-format-tokens($systems);
|
78 |
| - |
79 |
| - // TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of |
80 |
| - // material-experimental. This is a hack for now because there is no good way to get the token |
81 |
| - // slots in material-experimental without exposing them all from material. |
82 |
| - $fake-theme: m2-theming.define-light-theme(( |
83 |
| - color: ( |
84 |
| - primary: m2-theming.define-palette(m2-theming.$red-palette), |
85 |
| - accent: m2-theming.define-palette(m2-theming.$red-palette), |
86 |
| - warn: m2-theming.define-palette(m2-theming.$red-palette), |
87 |
| - ), |
88 |
| - typography: m2-theming.define-typography-config(), |
89 |
| - density: 0 |
90 |
| - )); |
91 |
| - $token-slots: m2-tokens.m2-tokens-from-theme($fake-theme); |
| 104 | + $token-slots: _get-token-slots(); |
92 | 105 |
|
93 | 106 | // TODO(mmalerba): Fill in remaining tokens.
|
94 | 107 | $result: sass-utils.deep-merge-all(
|
|
0 commit comments