@@ -3,7 +3,9 @@ import prefixAll from "../utils/prefixAll";
33import { Toast } from "../Toast" ;
44import { StyleManager , CustomCSSProperties , StyleClasses } from "./StyleManager" ;
55import generateAcrylicTexture from "./generateAcrylicTexture" ;
6+ import { getAcrylicTextureStyle , AcrylicConfig , isSupportBackdropFilter } from "./getAcrylicTextureStyle" ;
67
8+ const supportedBackdropFilter = isSupportBackdropFilter ( ) ;
79export function darken ( color : string , coefficient : number ) {
810 const hsl = tinycolor ( color ) . toHsl ( ) ;
911 hsl . l = hsl . l * ( 1 - coefficient ) ;
@@ -17,6 +19,7 @@ export function lighten(color: string, coefficient: number) {
1719}
1820
1921export interface AcrylicTexture {
22+ style ?: React . CSSProperties ;
2023 tintColor ?: string ;
2124 tintOpacity ?: number ;
2225 blurSize ?: number ;
@@ -381,39 +384,68 @@ export class Theme {
381384 }
382385 } as Theme ) ;
383386
387+ const blurSize = 24 ;
388+ const acrylicTexture40Config : AcrylicConfig = {
389+ tintColor : this . chromeMedium ,
390+ opacity : .4 ,
391+ blurSize
392+ } ;
393+ this . acrylicTexture40 . style = getAcrylicTextureStyle ( acrylicTexture40Config ) ;
394+ this . acrylicTexture40 . background = this . acrylicTexture40 . style . background as string ;
395+
396+ const acrylicTexture60Config : AcrylicConfig = {
397+ tintColor : this . chromeMediumLow ,
398+ opacity : .6 ,
399+ blurSize
400+ } ;
401+ this . acrylicTexture60 . style = getAcrylicTextureStyle ( acrylicTexture60Config ) ;
402+ this . acrylicTexture60 . background = this . acrylicTexture60 . style . background as string ;
403+
404+ const acrylicTexture80Config : AcrylicConfig = {
405+ tintColor : this . chromeLow ,
406+ opacity : .8 ,
407+ blurSize
408+ } ;
409+ this . acrylicTexture80 . style = getAcrylicTextureStyle ( acrylicTexture80Config ) ;
410+ this . acrylicTexture80 . background = this . acrylicTexture80 . style . background as string ;
411+
384412 // generateAcrylicTextures method.
385413 this . generateAcrylicTextures = ( themeCallback ?: ( theme ?: Theme ) => void ) => {
414+ if ( supportedBackdropFilter ) {
415+ return ;
416+ }
386417 this . acrylicTextureCount = 0 ;
387- const baseConfig = {
388- blurSize : 24
389- } ;
390418
391419 const callback = ( image : string , key : number ) => {
420+ const background = `url(${ image } ) no-repeat fixed top left / cover` ;
392421 if ( key === 4 ) {
393422 this . acrylicTextureCount += 1 ;
394423 Object . assign ( this . acrylicTexture40 , {
395- tintColor : this . chromeMediumLow ,
396- tintOpacity : 0.4 ,
397- background : `url(${ image } ) no-repeat fixed top left / cover` ,
398- ...baseConfig
424+ tintColor : acrylicTexture40Config . tintColor ,
425+ tintOpacity : acrylicTexture40Config . opacity ,
426+ style : { background } ,
427+ background,
428+ blurSize
399429 } ) ;
400430 }
401431 if ( key === 6 ) {
402432 this . acrylicTextureCount += 1 ;
403433 Object . assign ( this . acrylicTexture60 , {
404- tintColor : this . chromeLow ,
405- tintOpacity : 0.6 ,
406- background : `url(${ image } ) no-repeat fixed top left / cover` ,
407- ...baseConfig
434+ tintColor : acrylicTexture60Config . tintColor ,
435+ tintOpacity : acrylicTexture60Config . opacity ,
436+ style : { background } ,
437+ background,
438+ blurSize
408439 } ) ;
409440 }
410441 if ( key === 8 ) {
411442 this . acrylicTextureCount += 1 ;
412443 Object . assign ( this . acrylicTexture80 , {
413- tintColor : this . chromeLow ,
414- tintOpacity : 0.8 ,
415- background : `url(${ image } ) no-repeat fixed top left / cover` ,
416- ...baseConfig
444+ tintColor : acrylicTexture80Config . tintColor ,
445+ tintOpacity : acrylicTexture80Config . opacity ,
446+ style : { background } ,
447+ background,
448+ blurSize
417449 } ) ;
418450 }
419451
@@ -428,21 +460,21 @@ export class Theme {
428460 image : this . desktopBackgroundImage ,
429461 tintColor : this . chromeMediumLow ,
430462 tintOpacity : 0.4 ,
431- blurSize : baseConfig . blurSize ,
463+ blurSize,
432464 callback : image => callback ( image , 4 )
433465 } ) ;
434466 generateAcrylicTexture ( {
435467 image : this . desktopBackgroundImage ,
436468 tintColor : this . chromeLow ,
437469 tintOpacity : 0.6 ,
438- blurSize : baseConfig . blurSize ,
470+ blurSize,
439471 callback : image => callback ( image , 6 )
440472 } ) ;
441473 generateAcrylicTexture ( {
442474 image : this . desktopBackgroundImage ,
443475 tintColor : this . chromeLow ,
444476 tintOpacity : 0.8 ,
445- blurSize : baseConfig . blurSize ,
477+ blurSize,
446478 callback : image => callback ( image , 8 )
447479 } ) ;
448480 } ;
0 commit comments