From f40ddc59f5cfc5b4d7b3dd3b10febddbfc298c3e Mon Sep 17 00:00:00 2001
From: Derek Sonnenberg
Date: Fri, 8 Dec 2023 12:15:25 -0600
Subject: [PATCH] refactor: clean up code PE-5161
---
src/Router.tsx | 22 ++++-----------
src/{ => components}/ArDriveLogo.tsx | 28 ++++---------------
src/components/Footer.tsx | 9 ++++++
src/components/LogoHeader.tsx | 2 +-
src/components/RouterPage.tsx | 23 ---------------
src/hooks/useIsDarkMode.ts | 25 +++++++++++++++++
src/{GiftForm.css => pages/GiftPage.css} | 0
src/{GiftForm.tsx => pages/GiftPage.tsx} | 24 ++++++++--------
.../RouterPage.css => pages/Page.css} | 0
src/pages/Page.tsx | 21 ++++++++++++++
src/types.ts | 4 +++
11 files changed, 83 insertions(+), 75 deletions(-)
rename src/{ => components}/ArDriveLogo.tsx (99%)
create mode 100644 src/components/Footer.tsx
delete mode 100644 src/components/RouterPage.tsx
create mode 100644 src/hooks/useIsDarkMode.ts
rename src/{GiftForm.css => pages/GiftPage.css} (100%)
rename src/{GiftForm.tsx => pages/GiftPage.tsx} (90%)
rename src/{components/RouterPage.css => pages/Page.css} (100%)
create mode 100644 src/pages/Page.tsx
create mode 100644 src/types.ts
diff --git a/src/Router.tsx b/src/Router.tsx
index cd6ae27..eee1585 100644
--- a/src/Router.tsx
+++ b/src/Router.tsx
@@ -1,33 +1,21 @@
import { BrowserRouter, Route, Routes } from "react-router-dom";
-import { GiftForm } from "./GiftForm";
-import { Page } from "./components/RouterPage";
+import { GiftPage } from "./pages/GiftPage";
+import { Page } from "./pages/Page";
export function Router() {
return (
- (
-
- )}
- />
- }
- />
+ } />
TODO
} />} />
(
-
- )}
- />
+
}
/>
+ 404
} />
);
diff --git a/src/ArDriveLogo.tsx b/src/components/ArDriveLogo.tsx
similarity index 99%
rename from src/ArDriveLogo.tsx
rename to src/components/ArDriveLogo.tsx
index b79a72d..4fb09f5 100644
--- a/src/ArDriveLogo.tsx
+++ b/src/components/ArDriveLogo.tsx
@@ -1,25 +1,7 @@
-import { JSX, useEffect, useState } from "react";
+import { useIsDarkMode } from "../hooks/useIsDarkMode";
-export function ArDriveLogo(): JSX.Element {
- const [isDarkMode, setIsDarkMode] = useState(() => {
- // Check the current theme using matchMedia
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
- });
-
- useEffect(() => {
- // Update the theme on changes
- const mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
- const handleChange = (e: MediaQueryListEvent) => {
- setIsDarkMode(e.matches);
- };
-
- mediaQueryList.addEventListener("change", handleChange);
-
- // Cleanup event listener on component unmount
- return () => {
- mediaQueryList.removeEventListener("change", handleChange);
- };
- }, []);
+export function ArDriveLogo() {
+ const isDarkMode = useIsDarkMode();
return (
@@ -28,7 +10,7 @@ export function ArDriveLogo(): JSX.Element {
);
}
-function ArDriveLogoLight(): JSX.Element {
+function ArDriveLogoLight() {
return (