From 4cc48fe0b279f642e84e55a65d1141d6eef62ec4 Mon Sep 17 00:00:00 2001 From: EvanLin3141 Date: Sun, 9 Feb 2025 17:19:34 +0000 Subject: [PATCH] MOVE: Theme to quick settings --- frontend/src/App.tsx | 2 - frontend/src/assets/styles/index.css | 31 ++++++++++++ frontend/src/components/Auth/LoginForm.tsx | 5 ++ frontend/src/components/Layout/Navbar.tsx | 6 +-- .../src/components/Layout/QuickSettings.tsx | 20 +++++--- frontend/src/components/Layout/Sidebar.tsx | 34 ++++--------- frontend/src/components/Layout/Theme.tsx | 50 ++++++++++--------- frontend/src/context/ThemeContext.tsx | 27 ++++++++++ frontend/src/main.tsx | 3 ++ 9 files changed, 119 insertions(+), 59 deletions(-) create mode 100644 frontend/src/context/ThemeContext.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1403733..7786faf 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -8,7 +8,6 @@ import NotFoundPage from "./pages/NotFoundPage"; import UserPage from "./pages/UserPage"; import ResetPasswordPage from "./pages/ResetPasswordPage"; import CategoryPage from "./pages/CategoryPage"; -import ForgotPasswordForm from "./components/Auth/ForgotPasswordForm"; function App() { const [isLoggedIn, setIsLoggedIn] = useState(false); @@ -44,7 +43,6 @@ function App() { } /> } /> }> - }> }> } /> diff --git a/frontend/src/assets/styles/index.css b/frontend/src/assets/styles/index.css index 4a3eab1..9766b6f 100644 --- a/frontend/src/assets/styles/index.css +++ b/frontend/src/assets/styles/index.css @@ -8,6 +8,8 @@ --sideBar-DarkBG: black; --sideBar-DarkText: white; + + --quickBar-DarkBG: rgb(0,0,0,0.5) } @@ -30,6 +32,35 @@ } +body[data-theme="light"] { + --bg-color: white; + --text-color: black; +} + +body[data-theme="dark"] { + --bg-color: black; + --text-color: white; +} + +body[data-theme="blue"] { + --bg-color: #e0f7fa; + --text-color: #004d40; +} + +body[data-theme="green"] { + --bg-color: #e8f5e9; + --text-color: #2e7d32; +} + +body[data-theme="orange"] { + --bg-color: #ffe0b2; + --text-color: #e65100; +} + +body { + background-color: var(--bg-color); + color: var(--text-color); +} diff --git a/frontend/src/components/Auth/LoginForm.tsx b/frontend/src/components/Auth/LoginForm.tsx index 6e48d60..0a2628d 100644 --- a/frontend/src/components/Auth/LoginForm.tsx +++ b/frontend/src/components/Auth/LoginForm.tsx @@ -97,6 +97,9 @@ const LoginForm: React.FC = ({ onSubmit }) => { }; return ( + <> +
+

Login

= ({ onSubmit }) => {
+
+ ); }; diff --git a/frontend/src/components/Layout/Navbar.tsx b/frontend/src/components/Layout/Navbar.tsx index 6eeb4c2..76c5386 100644 --- a/frontend/src/components/Layout/Navbar.tsx +++ b/frontend/src/components/Layout/Navbar.tsx @@ -84,7 +84,7 @@ const Navbar: React.FC = ({ variant = "default" }) => {
@@ -102,8 +102,8 @@ const Navbar: React.FC = ({ variant = "default" }) => {
diff --git a/frontend/src/components/Layout/QuickSettings.tsx b/frontend/src/components/Layout/QuickSettings.tsx index a0fd76a..422667d 100644 --- a/frontend/src/components/Layout/QuickSettings.tsx +++ b/frontend/src/components/Layout/QuickSettings.tsx @@ -1,9 +1,17 @@ -import React from 'react' +import React from "react"; +import Theme from "./Theme"; +import { useTheme } from "../../context/ThemeContext"; + +const QuickSettings: React.FC = () => { + const { theme } = useTheme(); -const QuickSettings = () => { return ( -
QuickSettings
- ) -} +
+

Current Theme: {theme}

+ +
+ ); +}; -export default QuickSettings \ No newline at end of file +export default QuickSettings; diff --git a/frontend/src/components/Layout/Sidebar.tsx b/frontend/src/components/Layout/Sidebar.tsx index 97477f3..0f8ea28 100644 --- a/frontend/src/components/Layout/Sidebar.tsx +++ b/frontend/src/components/Layout/Sidebar.tsx @@ -8,7 +8,6 @@ interface SideBarProps { } const Sidebar: React.FC = () => { - const [thisTheme, setThisTheme] = useState(false); const [isCursorOnSidebar, setIsCursorOnSidebar] = useState(false); const [triggerAnimation, setTriggerAnimation] = useState(false); useEffect(() => { @@ -22,23 +21,19 @@ const Sidebar: React.FC = () => { }; }, [isCursorOnSidebar]); - const handleTheme = () => { - setThisTheme(!thisTheme); - setTriggerAnimation(false); // Reset animation - setTimeout(() => setTriggerAnimation(true), 0); // Re-trigger animation - }; + const testStreamer: Record = { "Markiplier": "Slink1", "Jacksepticeye": "Slink2", "8-BitRyan": "Slink3", }; - const testCategory: Record = { - "Action": {dummyLink : "link1", dummyImage: "../../../images/icons/Action.webp"}, - "Horror": {dummyLink : "link2", dummyImage: "../../../images/icons/Horror.png"}, - "Psychological": {dummyLink : "link3", dummyImage: "../../../images/icons/Psychological.png"}, - "Adult": {dummyLink : "link4", dummyImage: "../../../images/icons/R-18.png"}, - "Shooter": {dummyLink : "link5", dummyImage: "../../../images/icons/Shooter.png"} + const testCategory: Record = { + "Action": { dummyLink: "link1", dummyImage: "../../../images/icons/Action.webp" }, + "Horror": { dummyLink: "link2", dummyImage: "../../../images/icons/Horror.png" }, + "Psychological": { dummyLink: "link3", dummyImage: "../../../images/icons/Psychological.png" }, + "Adult": { dummyLink: "link4", dummyImage: "../../../images/icons/R-18.png" }, + "Shooter": { dummyLink: "link5", dummyImage: "../../../images/icons/Shooter.png" } }; const shownStreamers = Object.entries(testStreamer).map(([dummyCategory, dummyLink]) => { @@ -49,11 +44,11 @@ const Sidebar: React.FC = () => { ); }); - const shownCategory = Object.entries(testCategory).map(([dummyCategory, {dummyLink, dummyImage}]) => { + const shownCategory = Object.entries(testCategory).map(([dummyCategory, { dummyLink, dummyImage }]) => { return (
  • - {dummyCategory} + {dummyCategory} {dummyCategory}
  • ); @@ -61,17 +56,8 @@ const Sidebar: React.FC = () => { return ( <> -