@@ -38,9 +38,9 @@ trait CommonThemeTrait {
3838 * will change in between.
3939 */
4040 protected function generatePrimaryVariables (string $ colorMainBackground , string $ colorMainText ): array {
41- $ colorPrimaryLight = $ this ->util ->mix ( $ this -> primaryColor , $ colorMainBackground, - 80 );
42- $ colorPrimaryElement = $ this ->util ->elementColor ($ this ->primaryColor );
43- $ colorPrimaryElementDefault = $ this ->util ->elementColor ( $ this -> defaultPrimaryColor );
41+ $ isBrightColor = $ this ->util ->isBrightColor ( $ colorMainBackground );
42+ $ colorPrimaryElement = $ this ->util ->elementColor ($ this ->primaryColor , $ isBrightColor );
43+ $ colorPrimaryLight = $ this ->util ->mix ( $ colorPrimaryElement , $ colorMainBackground , - 80 );
4444 $ colorPrimaryElementLight = $ this ->util ->mix ($ colorPrimaryElement , $ colorMainBackground , -80 );
4545
4646 // primary related colours
@@ -61,16 +61,17 @@ protected function generatePrimaryVariables(string $colorMainBackground, string
6161 '--color-primary-light ' => $ colorPrimaryLight ,
6262 '--color-primary-light-text ' => $ this ->util ->mix ($ this ->primaryColor , $ this ->util ->invertTextColor ($ colorPrimaryLight ) ? '#000000 ' : '#ffffff ' , -20 ),
6363 '--color-primary-light-hover ' => $ this ->util ->mix ($ colorPrimaryLight , $ colorMainText , 90 ),
64- '--color-primary-text-dark ' => $ this ->util ->darken ($ this ->util ->invertTextColor ($ this ->primaryColor ) ? '#000000 ' : '#ffffff ' , 7 ),
6564
6665 // used for buttons, inputs...
6766 '--color-primary-element ' => $ colorPrimaryElement ,
68- '--color-primary-element-default-hover ' => $ this ->util ->mix ($ colorPrimaryElementDefault , $ colorMainBackground , 60 ),
69- '--color-primary-element-text ' => $ this ->util ->invertTextColor ($ colorPrimaryElement ) ? '#000000 ' : '#ffffff ' ,
7067 '--color-primary-element-hover ' => $ this ->util ->mix ($ colorPrimaryElement , $ colorMainBackground , 60 ),
68+ '--color-primary-element-text ' => $ this ->util ->invertTextColor ($ colorPrimaryElement ) ? '#000000 ' : '#ffffff ' ,
69+
70+ // used for hover/focus states
7171 '--color-primary-element-light ' => $ colorPrimaryElementLight ,
72- '--color-primary-element-light-text ' => $ this ->util ->mix ($ colorPrimaryElement , $ this ->util ->invertTextColor ($ colorPrimaryElementLight ) ? '#000000 ' : '#ffffff ' , -20 ),
7372 '--color-primary-element-light-hover ' => $ this ->util ->mix ($ colorPrimaryElementLight , $ colorMainText , 90 ),
73+ '--color-primary-element-light-text ' => $ this ->util ->mix ($ colorPrimaryElement , $ this ->util ->invertTextColor ($ colorPrimaryElementLight ) ? '#000000 ' : '#ffffff ' , -20 ),
74+ // mostly used for disabled states
7475 '--color-primary-element-text-dark ' => $ this ->util ->darken ($ this ->util ->invertTextColor ($ colorPrimaryElement ) ? '#000000 ' : '#ffffff ' , 7 ),
7576
7677 // to use like this: background-image: var(--gradient-primary-background);
@@ -92,15 +93,6 @@ protected function generateGlobalBackgroundVariables(): array {
9293 $ variables ['--image-background-default ' ] = "url(' " . $ this ->themingDefaults ->getBackground () . "') " ;
9394 $ variables ['--color-background-plain ' ] = $ this ->defaultPrimaryColor ;
9495
95- // If primary as background has been request or if we have a custom primary colour
96- // let's not define the background image
97- if ($ backgroundDeleted ) {
98- $ variables ['--color-background-plain ' ] = $ this ->defaultPrimaryColor ;
99- $ variables ['--image-background-plain ' ] = 'yes ' ;
100- // If no background image is set, we need to check against the shown primary colour
101- $ variables ['--background-image-invert-if-bright ' ] = $ isDefaultPrimaryBright ? 'invert(100%) ' : 'no ' ;
102- }
103-
10496 // Register image variables only if custom-defined
10597 foreach (ImageManager::SUPPORTED_IMAGE_KEYS as $ image ) {
10698 if ($ this ->imageManager ->hasImage ($ image )) {
@@ -110,8 +102,18 @@ protected function generateGlobalBackgroundVariables(): array {
110102 }
111103 }
112104
105+ // If primary as background has been request or if we have a custom primary colour
106+ // let's not define the background image
107+ if ($ backgroundDeleted ) {
108+ $ variables ['--color-background-plain ' ] = $ this ->defaultPrimaryColor ;
109+ $ variables ['--image-background-plain ' ] = 'yes ' ;
110+ $ variables ['--image-background ' ] = 'no ' ;
111+ // If no background image is set, we need to check against the shown primary colour
112+ $ variables ['--background-image-invert-if-bright ' ] = $ isDefaultPrimaryBright ? 'invert(100%) ' : 'no ' ;
113+ }
114+
113115 if ($ hasCustomLogoHeader ) {
114- $ variables [" --image-logoheader-custom " ] = 'true ' ;
116+ $ variables [' --image-logoheader-custom ' ] = 'true ' ;
115117 }
116118
117119 return $ variables ;
0 commit comments