From a6a7aa00c20d3fbf89e74817f878a1fdd1e68383 Mon Sep 17 00:00:00 2001 From: Liam <67254223+RealFascinated@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:53:27 +0100 Subject: [PATCH] Added dark mode toggle --- pages/index.js | 15 ++++++++--- src/components/Navbar.js | 7 ++++- src/components/Settings.js | 52 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 src/components/Settings.js diff --git a/pages/index.js b/pages/index.js index c78e9ca..cbb083c 100644 --- a/pages/index.js +++ b/pages/index.js @@ -112,11 +112,14 @@ export default class Home extends Component { } render() { + console.log(this.state.steamId); return this.state.loading ? (

Loading...

) : (
- + - BeatSaber Overlay - Welcome to the Setup panel + + BeatSaber Overlay + + + Welcome to the Setup panel +
- + diff --git a/src/components/Navbar.js b/src/components/Navbar.js index afebcda..db60231 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -1,6 +1,7 @@ import { Navbar, Text } from "@nextui-org/react"; +import Settings from "./Settings"; -const NavBar = () => { +const NavBar = (props) => { return ( @@ -8,6 +9,10 @@ const NavBar = () => { BeatSaber Overlay + + + + ); }; diff --git a/src/components/Settings.js b/src/components/Settings.js new file mode 100644 index 0000000..50ff349 --- /dev/null +++ b/src/components/Settings.js @@ -0,0 +1,52 @@ +import { + Avatar as NextAvatar, + changeTheme, + Dropdown, + Text, + useTheme, +} from "@nextui-org/react"; + +const Avatar = (props) => { + const { isDark } = useTheme(); + + const avatarUrl = + props.avatarUrl || "https://cdn.fascinated.cc/IkQFyodbZv.jpg?raw=true"; + + const handleChange = () => { + const nextTheme = isDark ? "light" : "dark"; + window.localStorage.setItem("theme", nextTheme); // you can use any storage + changeTheme(nextTheme); + }; + + return ( + <> + + + + + + +
+ handleChange()}> + Toggle Dark Mode + +
+
+
+
+ + ); +}; + +export default Avatar;