@@ -32,6 +32,7 @@ angular.module('material.core.theming', ['material.core.theming.palette'])
32
32
*
33
33
* {{primary-100}} - grab shade 100 from the primary palette
34
34
* {{primary-100-0.7}} - grab shade 100, apply opacity of 0.7
35
+ * {{primary-100-contrast}} - grab shade 100's contrast color
35
36
* {{primary-hue-1}} - grab the shade assigned to hue-1 from the primary palette
36
37
* {{primary-hue-1-0.7}} - apply 0.7 opacity to primary-hue-1
37
38
* {{primary-color}} - Generates .md-hue-1, .md-hue-2, .md-hue-3 with configured shades set for each hue
@@ -404,13 +405,13 @@ function parseRules(theme, colorType, rules) {
404
405
var themeNameRegex = new RegExp ( '.md-' + theme . name + '-theme' , 'g' ) ;
405
406
// Matches '{{ primary-color }}', etc
406
407
var hueRegex = new RegExp ( '(\'|")?{{\\s*(' + colorType + ')-(color|contrast)-?(\\d\\.?\\d*)?\\s*}}(\"|\')?' , 'g' ) ;
407
- var simpleVariableRegex = / ' ? " ? \{ \{ \s * ( [ a - z A - Z ] + ) - ( A ? \d + | h u e \- [ 0 - 3 ] | s h a d o w ) - ? ( \d \. ? \d * ) ? \s * \} \} ' ? " ? / g;
408
+ var simpleVariableRegex = / ' ? " ? \{ \{ \s * ( [ a - z A - Z ] + ) - ( A ? \d + | h u e \- [ 0 - 3 ] | s h a d o w ) - ? ( \d \. ? \d * ) ? ( c o n t r a s t ) ? \s * \} \} ' ? " ? / g;
408
409
var palette = PALETTES [ color . name ] ;
409
410
410
411
// find and replace simple variables where we use a specific hue, not an entire palette
411
412
// eg. "{{primary-100}}"
412
413
//\(' + THEME_COLOR_TYPES.join('\|') + '\)'
413
- rules = rules . replace ( simpleVariableRegex , function ( match , colorType , hue , opacity ) {
414
+ rules = rules . replace ( simpleVariableRegex , function ( match , colorType , hue , opacity , contrast ) {
414
415
if ( colorType === 'foreground' ) {
415
416
if ( hue == 'shadow' ) {
416
417
return theme . foregroundShadow ;
@@ -421,7 +422,7 @@ function parseRules(theme, colorType, rules) {
421
422
if ( hue . indexOf ( 'hue' ) === 0 ) {
422
423
hue = theme . colors [ colorType ] . hues [ hue ] ;
423
424
}
424
- return rgba ( ( PALETTES [ theme . colors [ colorType ] . name ] [ hue ] || '' ) . value , opacity ) ;
425
+ return rgba ( ( PALETTES [ theme . colors [ colorType ] . name ] [ hue ] || '' ) [ contrast ? 'contrast' : ' value' ] , opacity ) ;
425
426
} ) ;
426
427
427
428
// For each type, generate rules for each hue (ie. default, md-hue-1, md-hue-2, md-hue-3)
0 commit comments