From 18c66b4eb08dfb8cce8296ee99c26fbcc628ea49 Mon Sep 17 00:00:00 2001 From: "haitao(lj)" Date: Thu, 15 Dec 2022 17:23:05 +0800 Subject: [PATCH] fix(NavBar): Make the navbar follow the theme settings --- ui/src/components/Header/index.scss | 43 ++++------------------------- ui/src/components/Header/index.tsx | 16 +++++++++-- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/ui/src/components/Header/index.scss b/ui/src/components/Header/index.scss index f35cb57e..bbcb74f8 100644 --- a/ui/src/components/Header/index.scss +++ b/ui/src/components/Header/index.scss @@ -2,21 +2,21 @@ @import 'bootstrap/scss/variables'; #header { --bs-navbar-padding-y: 0.75rem; + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0.125rem 0.25rem rgb(0 0 0 / 8%); .logo { max-height: 1.75rem; } .nav-link { + &.active { + font-weight: 700; + } &.icon-link { width: 36px; height: 36px; } } - .placeholder-search { - box-shadow: none; - } - .answer-navBar { font-size: 1rem; padding: 0.25rem 0.5rem; @@ -31,21 +31,13 @@ } .hr { - color: #fff; + color: var(--bs-navbar-color); } // style for colored navbar &.theme-colored { - background: linear-gradient(180deg, #0033FF 0%, rgba(0, 51, 255, 0.95) 100%); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15), $box-shadow-sm; - .nav-link { - color: rgba(255, 255, 255, 0.7); - &.active { - font-weight: bold; - color: #fff; - } - } .placeholder-search { + box-shadow: none; color: #fff; background-color: rgba(255, 255, 255, .2); border: $border-width $border-style rgba(255, 255, 255, .2); @@ -57,29 +49,6 @@ } } } - // style for light navbar - &.theme-light { - background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0.95) 100%); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0.125rem 0.25rem rgb(0 0 0 / 8%); - .nav-link { - color: rgba(0, 0, 0, 0.55); - &.active { - font-weight: bold; - color: rgba(0, 0, 0, 0.75) - } - } - .placeholder-search { - color: rgba(0, 0, 0, 0.75); - background-color: #fff; - border: 1px solid #CED4DA; - &:focus { - border: 1px solid rgba(0, 0, 0, 0.75); - } - &::placeholder { - color: #6C757D - } - } - } } diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx index 47b4ba3f..418d7ebc 100644 --- a/ui/src/components/Header/index.tsx +++ b/ui/src/components/Header/index.tsx @@ -44,7 +44,6 @@ const Header: FC = () => { const siteInfo = siteInfoStore((state) => state.siteInfo); const brandingInfo = brandingStore((state) => state.branding); const loginSetting = loginSettingStore((state) => state.login); - const { theme, theme_config } = themeSettingStore((_) => _); const { data: redDot } = useQueryNotificationStatus(); const location = useLocation(); const handleInput = (val) => { @@ -73,6 +72,7 @@ const Header: FC = () => { } }, [location.pathname]); + const { theme, theme_config } = themeSettingStore((_) => _); let themeType = 'theme-colored'; if (theme && theme_config[theme]) { themeType = `theme-${theme_config[theme].navbar_style}`; @@ -80,8 +80,12 @@ const Header: FC = () => { return ( { {/* mobile nav */}
{user?.username ? ( - + ) : ( <>