From 3c20ee61d2515bc3a8f28950f2137af1ecbdec39 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 26 Mar 2025 14:10:29 +0100 Subject: [PATCH] Stop using header link and bg colors if `theme` is set --- .../RootLayout/CustomizationRootLayout.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx b/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx index 24ba744ee..f521cda2e 100644 --- a/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx +++ b/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx @@ -111,12 +111,13 @@ export async function CustomizationRootLayout(props: { /** If the site still has a (deprecated) custom header link or background set, we use that. * These values are no longer supported in the Customiser, and will eventually be unsupported in the front-end. */ hexToRgb( - customization.header.backgroundColor?.light ?? - tintColor?.light ?? - customization.styling.primaryColor.light + 'theme' in customization.styling && customization.styling.theme + ? customization.styling.primaryColor.light + : (customization.header.backgroundColor?.light ?? + customization.styling.primaryColor.light) ) }; - --header-link: ${hexToRgb(customization.header.linkColor?.light ?? colorContrast(tintColor?.light ?? customization.styling.primaryColor.light))}; + --header-link: ${hexToRgb('theme' in customization.styling && customization.styling.theme ? colorContrast(tintColor?.light ?? customization.styling.primaryColor.light) : (customization.header.linkColor?.light ?? colorContrast(tintColor?.light ?? customization.styling.primaryColor.light)))}; ${generateColorVariable('info', infoColor.light)} ${generateColorVariable('warning', warningColor.light)} @@ -129,8 +130,8 @@ export async function CustomizationRootLayout(props: { ${generateColorVariable('tint', tintColor ? tintColor.dark : DEFAULT_TINT_COLOR, { darkMode: true, mix: mixColor && { color: mixColor?.color.dark, ratio: mixColor.ratio.dark } })} ${generateColorVariable('neutral', DEFAULT_TINT_COLOR, { darkMode: true })} - --header-background: ${hexToRgb(customization.header.backgroundColor?.dark ?? tintColor?.dark ?? customization.styling.primaryColor.dark)}; - --header-link: ${hexToRgb(customization.header.linkColor?.dark ?? colorContrast(tintColor?.dark ?? customization.styling.primaryColor.dark))}; + --header-background: ${hexToRgb('theme' in customization.styling && customization.styling.theme ? (tintColor?.dark ?? customization.styling.primaryColor.dark) : (customization.header.backgroundColor?.dark ?? tintColor?.dark ?? customization.styling.primaryColor.dark))}; + --header-link: ${hexToRgb('theme' in customization.styling && customization.styling.theme ? colorContrast(tintColor?.dark ?? customization.styling.primaryColor.dark) : customization.header.linkColor?.dark ?? colorContrast(tintColor?.dark ?? customization.styling.primaryColor.dark))}; ${generateColorVariable('info', infoColor.dark, { darkMode: true })} ${generateColorVariable('warning', warningColor.dark, { darkMode: true })}