UPDATE: Added Button Light/Dark Theme

This commit is contained in:
EvanLin3141
2025-02-05 13:47:41 +00:00
parent 96e4df12a8
commit 870d1435ae
4 changed files with 33 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react";
import Theme from "./Theme";
import "../../assets/styles/sidebar.css"
interface SideBarProps {
@@ -21,10 +22,18 @@ const Sidebar: React.FC<SideBarProps> = ( {scrollActiveSideBar}) => {
};
}, [isCursorOnSidebar]);
return <div id="sidebar" className={"fixed top-0 left-0 bg-[var(--sideNav-LightBG)] w-[250px] text-sideBar-text p-4 z-[90] h-screen overflow-y-auto scrollbar-hide"}
onMouseEnter={() => setIsCursorOnSidebar(true)}
const handleTheme = () => {
setThisTheme(!thisTheme);
}
return <div id="sidebar" 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)]"
} p-4 z-[90] h-screen overflow-y-auto scrollbar-hide`}
onMouseLeave={() => setIsCursorOnSidebar(false)}
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}>
<Theme onClick={handleTheme}/>
<ul className="overflow-y-auto">
<li>1</li>
<li>1</li>

View File

@@ -0,0 +1,18 @@
import React from 'react'
interface ThemeProps {
children? : React.ReactNode;
onClick : () => void;
}
const Theme: React.FC<ThemeProps> = ( {onClick, children} ) => {
return (
<button
onClick={onClick}
className={` p-2 text-[1.5rem] text-white hover:text-purple-600 bg-black/30 hover:bg-black/80 rounded-md border border-gray-300 hover:border-purple-500 hover:border-b-4 hover:border-l-4 active:border-b-2 active:border-l-2 transition-all`}>
Light/Dark
</button>
)
}
export default Theme