@@ -98,28 +98,28 @@ $mdc-theme-property-values: (
98
98
text-icon-on-dark : mdc-theme-ink-color-for-fill_ (icon , dark )
99
99
);
100
100
101
- // If `$property ` is a literal color value (e.g. , `blue `, `#fff` ), it is returned verbatim. Otherwise, the value of the
102
- // corresponding theme property (from `$mdc-theme-property-values`) is returned. If `$ property` is not a color and no
103
- // such theme property exists , an error is thrown.
101
+ // If `$style ` is a color (a literal color value, `currentColor `, or a CSS custom property ), it is returned verbatim.
102
+ // Otherwise, `$style` is treated as a theme property name, and the corresponding value from
103
+ // `$mdc- theme- property-values` is returned. If this also fails , an error is thrown.
104
104
//
105
105
// This is mainly useful in situations where `mdc-theme-prop` cannot be used directly (e.g., `box-shadow`).
106
106
//
107
107
// Examples:
108
108
//
109
- // 1. mdc-theme-prop-value(primary) => "#3f51b5 "
109
+ // 1. mdc-theme-prop-value(primary) => "#6200ee "
110
110
// 2. mdc-theme-prop-value(blue) => "blue"
111
111
//
112
112
// NOTE: This function must be defined in _variables.scss instead of _functions.scss to avoid circular imports.
113
- @function mdc-theme-prop-value ($property ) {
114
- @if type-of ( $property ) == " color " or $property == " currentColor " {
115
- @return $property ;
113
+ @function mdc-theme-prop-value ($style ) {
114
+ @if mdc-theme-is-valid-theme-prop-value_ ( $style ) {
115
+ @return $style ;
116
116
}
117
117
118
- @if not map-has-key ($mdc-theme-property-values , $property ) {
119
- @error " Invalid theme property: '#{$property } '. Choose one of: #{map-keys ($mdc-theme-property-values )} " ;
118
+ @if not map-has-key ($mdc-theme-property-values , $style ) {
119
+ @error " Invalid theme property: '#{$style } '. Choose one of: #{map-keys ($mdc-theme-property-values )} " ;
120
120
}
121
121
122
- @return map-get ($mdc-theme-property-values , $property );
122
+ @return map-get ($mdc-theme-property-values , $style );
123
123
}
124
124
125
125
// NOTE: This function must be defined in _variables.scss instead of _functions.scss to avoid circular imports.
@@ -133,3 +133,8 @@ $mdc-theme-property-values: (
133
133
134
134
@return map-get ($color-map-for-tone , $text-style );
135
135
}
136
+
137
+ // NOTE: This function is depended upon by mdc-theme-prop-value (above) and thus must be defined in this file.
138
+ @function mdc-theme-is-valid-theme-prop-value_ ($style ) {
139
+ @return type-of ($style ) == " color" or $style == " currentColor" or str_slice ($style , 1 , 4 ) == " var(" ;
140
+ }
0 commit comments