MOVE: Theme to quick settings
This commit is contained in:
@@ -8,7 +8,6 @@ import NotFoundPage from "./pages/NotFoundPage";
|
|||||||
import UserPage from "./pages/UserPage";
|
import UserPage from "./pages/UserPage";
|
||||||
import ResetPasswordPage from "./pages/ResetPasswordPage";
|
import ResetPasswordPage from "./pages/ResetPasswordPage";
|
||||||
import CategoryPage from "./pages/CategoryPage";
|
import CategoryPage from "./pages/CategoryPage";
|
||||||
import ForgotPasswordForm from "./components/Auth/ForgotPasswordForm";
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||||
@@ -44,7 +43,6 @@ function App() {
|
|||||||
<Route path="/:streamerName" element={<StreamerRoute />} />
|
<Route path="/:streamerName" element={<StreamerRoute />} />
|
||||||
<Route path="/user/:username" element={<UserPage />} />
|
<Route path="/user/:username" element={<UserPage />} />
|
||||||
<Route path="/reset_password/:token" element={<ResetPasswordPage />}></Route>
|
<Route path="/reset_password/:token" element={<ResetPasswordPage />}></Route>
|
||||||
<Route path="/forgot_password/" element={<ForgotPasswordForm />}></Route>
|
|
||||||
<Route path="/category/:category_name" element={<CategoryPage />}></Route>
|
<Route path="/category/:category_name" element={<CategoryPage />}></Route>
|
||||||
|
|
||||||
<Route path="/404" element={<NotFoundPage />} />
|
<Route path="/404" element={<NotFoundPage />} />
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
--sideBar-DarkBG: black;
|
--sideBar-DarkBG: black;
|
||||||
--sideBar-DarkText: white;
|
--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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ const LoginForm: React.FC<SubmitProps> = ({ onSubmit }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<div className="h-[100%] flex flex-col justify-evenly items-center">
|
||||||
|
<h1 className="text-white text-lg"> Login </h1>
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
id="login-form"
|
id="login-form"
|
||||||
@@ -131,6 +134,8 @@ const LoginForm: React.FC<SubmitProps> = ({ onSubmit }) => {
|
|||||||
|
|
||||||
<Button type="submit">Login</Button>
|
<Button type="submit">Login</Button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const Navbar: React.FC<NavbarProps> = ({ variant = "default" }) => {
|
|||||||
<SidebarIcon className="top-[0.20em] left-[10em] mr-1 z-[90]" />
|
<SidebarIcon className="top-[0.20em] left-[10em] mr-1 z-[90]" />
|
||||||
</Button>
|
</Button>
|
||||||
<div
|
<div
|
||||||
className={`fixed top-0 left-0 w-[250px] h-screen bg-[var(--sideBar-LightBG)] text-[var(--sideBar-LightText)] z-[90] overflow-y-auto scrollbar-hide
|
className={`fixed top-0 left-0 w-[250px] h-screen bg-[var(--bg-color)] text-[var(--text-color)] z-[90] overflow-y-auto scrollbar-hide
|
||||||
transition-transform transition-opacity duration-500 ease-in-out ${showSideBar ? "translate-x-0 opacity-100" : "-translate-x-full opacity-0"
|
transition-transform transition-opacity duration-500 ease-in-out ${showSideBar ? "translate-x-0 opacity-100" : "-translate-x-full opacity-0"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
@@ -102,8 +102,8 @@ const Navbar: React.FC<NavbarProps> = ({ variant = "default" }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={`fixed top-0 right-0 w-[250px] h-screen bg-[var(--sideBar-LightBG)] text-[var(--sideBar-LightText)] z-[90] overflow-y-auto scrollbar-hide
|
className={`fixed top-0 right-0 w-[250px] h-screen ] z-[90] overflow-y-auto scrollbar-hide
|
||||||
transition-transform transition-opacity duration-500 ease-in-out ${showQuickSettings? "translate-x-0 opacity-100" : "translate-x-full opacity-0"
|
transition-opacity duration-500 ease-in-out ${showQuickSettings? "translate-x-0 opacity-100" : "translate-x-full opacity-0"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<QuickSettings />
|
<QuickSettings />
|
||||||
|
|||||||
@@ -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 (
|
return (
|
||||||
<div className='bg-white'>QuickSettings</div>
|
<div className="fixed top-0 right-0 w-[250px] h-screen p-4 z-[90] overflow-y-auto"
|
||||||
)
|
style={{ backgroundColor: 'var(--bg-color)', color: 'var(--text-color)' }}>
|
||||||
}
|
<h3 className="text-xl">Current Theme: {theme}</h3>
|
||||||
|
<Theme />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default QuickSettings
|
export default QuickSettings;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ interface SideBarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Sidebar: React.FC<SideBarProps> = () => {
|
const Sidebar: React.FC<SideBarProps> = () => {
|
||||||
const [thisTheme, setThisTheme] = useState(false);
|
|
||||||
const [isCursorOnSidebar, setIsCursorOnSidebar] = useState(false);
|
const [isCursorOnSidebar, setIsCursorOnSidebar] = useState(false);
|
||||||
const [triggerAnimation, setTriggerAnimation] = useState(false);
|
const [triggerAnimation, setTriggerAnimation] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -22,23 +21,19 @@ const Sidebar: React.FC<SideBarProps> = () => {
|
|||||||
};
|
};
|
||||||
}, [isCursorOnSidebar]);
|
}, [isCursorOnSidebar]);
|
||||||
|
|
||||||
const handleTheme = () => {
|
|
||||||
setThisTheme(!thisTheme);
|
|
||||||
setTriggerAnimation(false); // Reset animation
|
|
||||||
setTimeout(() => setTriggerAnimation(true), 0); // Re-trigger animation
|
|
||||||
};
|
|
||||||
const testStreamer: Record<string, string> = {
|
const testStreamer: Record<string, string> = {
|
||||||
"Markiplier": "Slink1",
|
"Markiplier": "Slink1",
|
||||||
"Jacksepticeye": "Slink2",
|
"Jacksepticeye": "Slink2",
|
||||||
"8-BitRyan": "Slink3",
|
"8-BitRyan": "Slink3",
|
||||||
};
|
};
|
||||||
|
|
||||||
const testCategory: Record<string, {dummyLink: string; dummyImage: string} > = {
|
const testCategory: Record<string, { dummyLink: string; dummyImage: string }> = {
|
||||||
"Action": {dummyLink : "link1", dummyImage: "../../../images/icons/Action.webp"},
|
"Action": { dummyLink: "link1", dummyImage: "../../../images/icons/Action.webp" },
|
||||||
"Horror": {dummyLink : "link2", dummyImage: "../../../images/icons/Horror.png"},
|
"Horror": { dummyLink: "link2", dummyImage: "../../../images/icons/Horror.png" },
|
||||||
"Psychological": {dummyLink : "link3", dummyImage: "../../../images/icons/Psychological.png"},
|
"Psychological": { dummyLink: "link3", dummyImage: "../../../images/icons/Psychological.png" },
|
||||||
"Adult": {dummyLink : "link4", dummyImage: "../../../images/icons/R-18.png"},
|
"Adult": { dummyLink: "link4", dummyImage: "../../../images/icons/R-18.png" },
|
||||||
"Shooter": {dummyLink : "link5", dummyImage: "../../../images/icons/Shooter.png"}
|
"Shooter": { dummyLink: "link5", dummyImage: "../../../images/icons/Shooter.png" }
|
||||||
};
|
};
|
||||||
|
|
||||||
const shownStreamers = Object.entries(testStreamer).map(([dummyCategory, dummyLink]) => {
|
const shownStreamers = Object.entries(testStreamer).map(([dummyCategory, dummyLink]) => {
|
||||||
@@ -49,11 +44,11 @@ const Sidebar: React.FC<SideBarProps> = () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const shownCategory = Object.entries(testCategory).map(([dummyCategory, {dummyLink, dummyImage}]) => {
|
const shownCategory = Object.entries(testCategory).map(([dummyCategory, { dummyLink, dummyImage }]) => {
|
||||||
return (
|
return (
|
||||||
<li key={dummyCategory} className="flex items-center border border-7 border-black space-x-3 rounded-md p-0 text-center
|
<li key={dummyCategory} className="flex items-center border border-7 border-black space-x-3 rounded-md p-0 text-center
|
||||||
hover:bg-[#800020] hover:scale-110 hover:shadow-[-1px_1.5px_10px_white] transition-all duration-250 m-[0.25em]">
|
hover:bg-[#800020] hover:scale-110 hover:shadow-[-1px_1.5px_10px_white] transition-all duration-250 m-[0.25em]">
|
||||||
<img src={dummyImage} alt={dummyCategory} className="w-[2em] h-[2em] bg-white ml-[0.25em]"/>
|
<img src={dummyImage} alt={dummyCategory} className="w-[2em] h-[2em] bg-white ml-[0.25em]" />
|
||||||
<a href={dummyLink} className="pr-[7.5em] pt-[0.75em] pb-[0.75em]">{dummyCategory}</a>
|
<a href={dummyLink} className="pr-[7.5em] pt-[0.75em] pb-[0.75em]">{dummyCategory}</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
@@ -61,17 +56,8 @@ const Sidebar: React.FC<SideBarProps> = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div id="sidebar"
|
|
||||||
key={triggerAnimation ? 'burn-in' : 'reset'}
|
|
||||||
className={`fixed top-0 left-0 w-[250px] ${thisTheme
|
|
||||||
? " bg-[var(--sideBar-LightBG)] text-[var(--sideBar-LightText)]"
|
|
||||||
: " bg-[var(--sideBar-DarkBG)] text-[var(--sideBar-DarkText)]"
|
|
||||||
} py-4 px-3 z-[90] h-screen overflow-y-auto
|
|
||||||
transition-transform duration-500 ease-in-out animate-burnIn`}
|
|
||||||
onMouseLeave={() => setIsCursorOnSidebar(false)}
|
|
||||||
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}>
|
|
||||||
<Theme isMode={thisTheme} onClick={handleTheme} />
|
|
||||||
|
|
||||||
|
<div>
|
||||||
<h1 className="style"> Followed </h1>
|
<h1 className="style"> Followed </h1>
|
||||||
<ul>
|
<ul>
|
||||||
{shownStreamers}
|
{shownStreamers}
|
||||||
|
|||||||
@@ -1,33 +1,35 @@
|
|||||||
import React, { useState } from 'react';
|
import React from "react";
|
||||||
import { SunMoon as SunMoonIcon, Sun as SunIcon,
|
import { Sun as SunIcon, Moon as MoonIcon, Droplet as BlueIcon, Leaf as GreenIcon, Flame as OrangeIcon } from "lucide-react";
|
||||||
Moon as MoonIcon } from 'lucide-react';
|
import { useTheme } from "../../context/ThemeContext";
|
||||||
|
|
||||||
interface ThemeProps {
|
const themeIcons = {
|
||||||
children?: React.ReactNode;
|
light: <SunIcon size={27} className="text-yellow-400" />,
|
||||||
onClick: () => void;
|
dark: <MoonIcon size={27} className="text-white" />,
|
||||||
isMode: boolean;
|
blue: <BlueIcon size={27} className="text-blue-500" />,
|
||||||
}
|
green: <GreenIcon size={27} className="text-green-500" />,
|
||||||
|
orange: <OrangeIcon size={27} className="text-orange-500" />,
|
||||||
|
};
|
||||||
|
|
||||||
const Theme: React.FC<ThemeProps> = ({ onClick, isMode }) => {
|
const themes = ["light", "dark", "blue", "green", "orange"];
|
||||||
|
|
||||||
|
const Theme: React.FC = () => {
|
||||||
|
const { theme, setTheme } = useTheme();
|
||||||
|
|
||||||
|
const handleNextTheme = () => {
|
||||||
|
const currentIndex = themes.indexOf(theme);
|
||||||
|
const nextIndex = (currentIndex + 1) % themes.length;
|
||||||
|
const nextTheme = themes[nextIndex];
|
||||||
|
setTheme(nextTheme);
|
||||||
|
document.body.setAttribute("data-theme", nextTheme); // Update globally
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative top-[0.20em] left-[10em]'>
|
|
||||||
<button
|
<button
|
||||||
onClick={onClick}
|
onClick={handleNextTheme}
|
||||||
className= {`p-2 text-[1.5rem] flex items-center gap-2 rounded-md border border-3
|
className="p-2 text-[1.5rem] flex items-center gap-2 rounded-md border transition-all"
|
||||||
${isMode ?
|
|
||||||
`text-white bg-[#3478ef] hover:text-[#3478ef] hover:bg-[#000000]
|
|
||||||
border-[#3478ef] hover:border-[##3478ef]` :
|
|
||||||
`text-yellow-400 bg-white hover:text-yellow-400 hover:bg-white
|
|
||||||
border-yellow-400 hover:border-yellow-400`}
|
|
||||||
hover:border-b-4 hover:border-l-4 active:border-b-2 active:border-l-2 transition-all `}
|
|
||||||
>
|
>
|
||||||
{isMode ? <MoonIcon size={27} className={`transition-transform duration-300 ease-in-out`}/>:
|
{themeIcons[theme as keyof typeof themeIcons]} {theme}
|
||||||
<SunIcon size={27} className={`transition-transform duration-300 ease-in-out`}/>
|
</button>
|
||||||
}
|
|
||||||
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
27
frontend/src/context/ThemeContext.tsx
Normal file
27
frontend/src/context/ThemeContext.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import React, { createContext, useContext, useState, ReactNode } from "react";
|
||||||
|
|
||||||
|
// Theme context and types
|
||||||
|
interface ThemeContextType {
|
||||||
|
theme: string;
|
||||||
|
setTheme: (theme: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
export const ThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||||
|
const [theme, setTheme] = useState<string>("light");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ThemeContext.Provider value={{ theme, setTheme }}>
|
||||||
|
{children}
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useTheme = () => {
|
||||||
|
const context = useContext(ThemeContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useTheme must be used within a ThemeProvider");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
|
import { ThemeProvider } from "./context/ThemeContext";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import "./assets/styles/index.css";
|
import "./assets/styles/index.css";
|
||||||
import App from "./App.tsx";
|
import App from "./App.tsx";
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
// <StrictMode>
|
// <StrictMode>
|
||||||
|
<ThemeProvider>
|
||||||
<App />,
|
<App />,
|
||||||
|
</ThemeProvider>
|
||||||
// </StrictMode>,
|
// </StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user