@@ -236,7 +236,6 @@ function getHighContrastOverides(
236236 overrides . set ( 'surface-dim' , hexFromArgb ( scheme . surfaceDim ) ) ;
237237 overrides . set ( 'surface-bright' , hexFromArgb ( scheme . surfaceBright ) ) ;
238238 overrides . set ( 'surface-container-lowest' , hexFromArgb ( scheme . surfaceContainerLowest ) ) ;
239- overrides . set ( 'surface-container-lowest' , hexFromArgb ( scheme . surfaceContainerLow ) ) ;
240239 overrides . set ( 'surface-container' , hexFromArgb ( scheme . surfaceContainer ) ) ;
241240 overrides . set ( 'surface-container-high' , hexFromArgb ( scheme . surfaceContainerHigh ) ) ;
242241 overrides . set ( 'surface-container-highest' , hexFromArgb ( scheme . surfaceContainerHighest ) ) ;
@@ -278,22 +277,48 @@ function generateHighContrastOverrideMixinsSCSS(
278277 neutralPalette : TonalPalette ,
279278 neutralVariantPalette : TonalPalette ,
280279) : string {
280+ const lightOverrides = getHighContrastOverides (
281+ primaryPalette ,
282+ secondaryPalette ,
283+ tertiaryPalette ,
284+ neutralPalette ,
285+ neutralVariantPalette ,
286+ /** isDark **/ false ,
287+ ) ;
288+
289+ const darkOverrides = getHighContrastOverides (
290+ primaryPalette ,
291+ secondaryPalette ,
292+ tertiaryPalette ,
293+ neutralPalette ,
294+ neutralVariantPalette ,
295+ /** isDark **/ true ,
296+ ) ;
297+
281298 let scss = '\n' ;
299+
300+ // Create high-contrast-overrides mixin which works with light-dark
301+ // https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark
302+ scss += '\n@mixin high-contrast-overrides {\n' ;
303+ scss += ' @include mat.theme-overrides((\n' ;
304+ for ( const [ key , value ] of lightOverrides ! . entries ( ) ) {
305+ scss += ' ' + key + ': light-dark(' + value + ', ' + darkOverrides . get ( key ) + '),\n' ;
306+ }
307+ scss += ' ))\n' ;
308+ scss += '};\n' ;
309+
310+ // Create high-contrast-light-theme-overrides and high-contrast-dark-theme-overrides mixins
282311 for ( const themeType of [ 'light' , 'dark' ] ) {
283- const overrides = getHighContrastOverides (
284- primaryPalette ,
285- secondaryPalette ,
286- tertiaryPalette ,
287- neutralPalette ,
288- neutralVariantPalette ,
289- themeType === 'dark' ,
290- ) ;
291312 scss += '\n@mixin high-contrast-' + themeType + '-theme-overrides {\n' ;
313+ scss += ' @include mat.theme-overrides((\n' ;
314+ const overrides = themeType === 'light' ? lightOverrides : darkOverrides ;
292315 for ( const [ key , value ] of overrides ! . entries ( ) ) {
293- scss += ' --mat-sys- ' + key + ': ' + value + '; \n' ;
316+ scss += ' ' + key + ': ' + value + ', \n' ;
294317 }
318+ scss += ' ))\n' ;
295319 scss += '};\n' ;
296320 }
321+
297322 return scss ;
298323}
299324
0 commit comments