From 5fcfe1f9131085581198f09c616dd75cc8dc0f4a Mon Sep 17 00:00:00 2001
From: PHOENIX-05 <154254031+PAVANTEJ-05@users.noreply.github.com>
Date: Sun, 29 Dec 2024 19:14:55 +0530
Subject: [PATCH 1/4] Dark mode css added global-styles.tsx
---
site/components/global-styles.tsx | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/site/components/global-styles.tsx b/site/components/global-styles.tsx
index 8da8e4d3f7..ca0bf918e0 100644
--- a/site/components/global-styles.tsx
+++ b/site/components/global-styles.tsx
@@ -3,6 +3,22 @@ import { ReactElement } from 'react'
import { colors, draculaPrism } from '../util'
const globalCss = css({
+ ':root': {
+ '--background-color': '#ffffff',
+ '--text-color': '#000000',
+ '--link-color': colors.pink,
+ '--link-hover-color': colors.hightlight,
+ },
+ '.dark': {
+ '--background-color': '#121212',
+ '--text-color': '#ffffff',
+ '--link-color': colors.pink, // Adjust if different in dark mode
+ '--link-hover-color': colors.hightlight, // Adjust if different in dark mode
+ },
+ body: {
+ backgroundColor: 'var(--background-color)',
+ color: 'var(--text-color)',
+ },
a: {
color: colors.pink,
textDecoration: 'none'
From 320b39dac9396e51e2719d4961dc4c799913b8eb Mon Sep 17 00:00:00 2001
From: PHOENIX-05 <154254031+PAVANTEJ-05@users.noreply.github.com>
Date: Sun, 29 Dec 2024 19:22:02 +0530
Subject: [PATCH 2/4] Update site-header.tsx
dark mode feature added
---
site/components/site-header.tsx | 38 +++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/site/components/site-header.tsx b/site/components/site-header.tsx
index b833c9f543..ca957381fa 100644
--- a/site/components/site-header.tsx
+++ b/site/components/site-header.tsx
@@ -4,6 +4,8 @@ import { colors, mediaQueries, styleConstants } from '../util'
import { css } from '@emotion/react'
import { useRouter } from 'next/router'
import { Container } from './container'
+import {useState, useEffect} from'react'
+import { Moon, Sun } from 'lucide-react'
export const animatedUnderline = css({
'&::after': {
@@ -70,9 +72,8 @@ function UkraineBanner() {
css={{
fontWeight: 'bold',
color: '#fff',
- fontSize: 20,
-
- [mediaQueries.mdUp]: {
+ fontSize: 20,
+ [mediaQueries.mdUp]: {
fontSize: 28
}
}}
@@ -83,13 +84,26 @@ function UkraineBanner() {
)
}
-
export function SiteHeader() {
const router = useRouter()
const path = router.asPath
const onCommunityPage = path === '/docs/community'
+ const [darkMode, setDarkMode] = useState(false);
+ useEffect(() => {
+ const isDark = localStorage.getItem('darkMode') === 'true';
+ setDarkMode(isDark);
+ if (isDark) {
+ document.documentElement.classList.add('dark');
+ }
+ }, []);
+ const toggleDarkMode = () => {
+ const newDarkMode = !darkMode;
+ setDarkMode(newDarkMode);
+ localStorage.setItem('darkMode', String(newDarkMode));
+ document.documentElement.classList.toggle('dark');
+ };
return (
<>