diff --git a/theme/components/LogoHeader.tsx b/theme/components/LogoHeader.tsx index 1d9c3b7..69c510c 100644 --- a/theme/components/LogoHeader.tsx +++ b/theme/components/LogoHeader.tsx @@ -1,16 +1,13 @@ import MainIcon from "@Components/icon/MainIcon"; -import { ThemeContext, usePageData } from "rspress/runtime"; -import { FC, useContext } from "react"; +import { usePageData } from "rspress/runtime"; +import { FC } from "react"; import { Link } from "rspress/theme"; +import classes from "@Styles/Icon.module.scss"; export const LogoHeader: FC = () => { - const { theme } = useContext(ThemeContext); const pageData = usePageData(); const defaultLang = pageData.siteData.lang ?? ""; const lang = pageData.page.lang; - const lightMode = theme === "light"; - const color = lightMode ? "#414141" : "#fff"; - const highlightColor = lightMode ? "#02BFA5" : "#0AD7AF"; return (
@@ -19,8 +16,11 @@ export const LogoHeader: FC = () => { className="flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60" > - - GZ::CTF + + GZ::CTF
diff --git a/theme/components/icon/MainIcon.tsx b/theme/components/icon/MainIcon.tsx index d4f3533..34f941e 100644 --- a/theme/components/icon/MainIcon.tsx +++ b/theme/components/icon/MainIcon.tsx @@ -1,5 +1,5 @@ -import { ThemeContext } from "rspress/runtime"; -import { SVGProps, FC, useContext } from "react"; +import classes from "@Styles/Icon.module.scss"; +import { SVGProps, FC } from "react"; interface MainIconProps extends SVGProps { ignoreTheme?: boolean; @@ -7,9 +7,6 @@ interface MainIconProps extends SVGProps { const MainIcon: FC = (props: MainIconProps) => { const { ignoreTheme, ...svgProps } = props; - const { theme } = useContext(ThemeContext); - - const color = theme === "light" ? "#414141" : "#fff"; return ( @@ -22,7 +19,7 @@ const MainIcon: FC = (props: MainIconProps) => { ) : ( )} diff --git a/theme/styles/Icon.module.scss b/theme/styles/Icon.module.scss new file mode 100644 index 0000000..3d5eb9e --- /dev/null +++ b/theme/styles/Icon.module.scss @@ -0,0 +1,19 @@ +:global(html.dark) { + --icon-color: #fff; + --icon-highlight: #0ad7af; +} + +:global(html) { + --icon-color: #414141; + --icon-highlight: #02bfa5; +} + +.icon { + color: var(--icon-color); + fill: var(--icon-color); +} + +.highlight { + color: var(--icon-highlight); + fill: var(--icon-highlight); +} diff --git a/tsconfig.json b/tsconfig.json index d254381..0e61371 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,8 @@ "allowImportingTsExtensions": true, "paths": { "i18n": ["./i18n.json"], - "@Components/*": ["./theme/components/*"] + "@Components/*": ["./theme/components/*"], + "@Styles/*": ["./theme/styles/*"], } }, "include": ["docs", "theme", "rspress.config.ts", "docs/en/guide/break-changes.mdx", "_old/en/deployment.mdx", "docs/en/guide/thanks.mdx"],