From 8eb224e0180c90c0af5ae0dd8b2991825b083eb1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 20 Apr 2023 22:39:47 -0500 Subject: [PATCH] feat: begin working on being able to immplement dark mode and light mode --- src/app/components/CodeSnippet.module.css | 1 + src/app/components/Main.tsx | 8 ++++- src/app/components/NavBar.tsx | 10 ++++-- src/app/components/Section.module.css | 2 +- src/app/components/SideBar.tsx | 28 +++++++++++---- src/app/global-error.tsx | 27 --------------- src/app/layout.tsx | 12 ++++++- src/app/theme.tsx | 42 +++++++++++++++++++++++ 8 files changed, 91 insertions(+), 39 deletions(-) delete mode 100644 src/app/global-error.tsx create mode 100644 src/app/theme.tsx diff --git a/src/app/components/CodeSnippet.module.css b/src/app/components/CodeSnippet.module.css index 257ba6e..4b6b06d 100644 --- a/src/app/components/CodeSnippet.module.css +++ b/src/app/components/CodeSnippet.module.css @@ -14,6 +14,7 @@ border-top-right-radius: 10px; border-top-left-radius: 10px; font-size: 1rem; + color: white; } .snippetContent>pre { diff --git a/src/app/components/Main.tsx b/src/app/components/Main.tsx index e5749fa..6f97a05 100644 --- a/src/app/components/Main.tsx +++ b/src/app/components/Main.tsx @@ -1,4 +1,7 @@ +'use client'; + import { Fragment } from 'react'; +import { themes, useThemeContext } from '../theme'; import { DocSection } from '../types/types'; import styles from './Main.module.css'; import Section from './Section'; @@ -8,8 +11,11 @@ export default function Main({ }: { versionSections: DocSection[]; }) { + const { theme } = useThemeContext(); + const themeStyles = themes[theme]; + return ( -
+
{versionSections.map(section => (
diff --git a/src/app/components/NavBar.tsx b/src/app/components/NavBar.tsx index 48ea0da..6dec8a9 100644 --- a/src/app/components/NavBar.tsx +++ b/src/app/components/NavBar.tsx @@ -1,8 +1,9 @@ 'use client'; -import Link from 'next/link.js'; +import Link from 'next/link'; import { Fragment, useState } from 'react'; -import { Doc, DocsStructure } from '../types/types.js'; +import { themes, useThemeContext } from '../theme'; +import { Doc, DocsStructure } from '../types/types'; import styles from './NavBar.module.css'; function VersionsDropdown({ @@ -153,6 +154,9 @@ export default function NavBar({ }: { version: DocsStructure; }) { + const { theme } = useThemeContext(); + const themeStyles = themes[theme]; + const [isNavOpen, setIsNavOpen] = useState(false); @@ -161,7 +165,7 @@ export default function NavBar({ }; return ( -