From f922321b57b6b665a160aef88ce79a22b88ad376 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 02:29:34 +0000 Subject: [PATCH 1/5] feat: Add DarkModeManager for managing dark mode p --- src/utils/DarkModeManager.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/utils/DarkModeManager.ts diff --git a/src/utils/DarkModeManager.ts b/src/utils/DarkModeManager.ts new file mode 100644 index 000000000..e2ae4938a --- /dev/null +++ b/src/utils/DarkModeManager.ts @@ -0,0 +1,27 @@ +class DarkModeManager { + private darkModeKey: string; + + constructor() { + this.darkModeKey = 'darkMode'; + } + + enableDarkMode(): void { + localStorage.setItem(this.darkModeKey, 'true'); + } + + disableDarkMode(): void { + localStorage.setItem(this.darkModeKey, 'false'); + } + + toggleDarkMode(): void { + const isCurrentlyEnabled = this.isDarkModeEnabled(); + localStorage.setItem(this.darkModeKey, isCurrentlyEnabled ? 'false' : 'true'); + } + + isDarkModeEnabled(): boolean { + const storedValue = localStorage.getItem(this.darkModeKey); + return storedValue === 'true'; + } +} + +export { DarkModeManager }; From 6f96b80a6598f3ba47a36170d5b41ddf90f7fab8 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 02:32:17 +0000 Subject: [PATCH 2/5] feat: Add dark mode styles for UI elements --- src/styles/darkmode.scss | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/styles/darkmode.scss diff --git a/src/styles/darkmode.scss b/src/styles/darkmode.scss new file mode 100644 index 000000000..3ba41436f --- /dev/null +++ b/src/styles/darkmode.scss @@ -0,0 +1,44 @@ +:root { + --primary-color: #ffffff; + --background-color: #121212; + --secondary-color: #bbbbbb; + --accent-color: #007bff; + --shadow-color: rgba(0, 0, 0, 0.5); +} + +.dark-mode { + --primary-color: #e0e0e0; + --background-color: #333333; + --secondary-color: #888888; + --accent-color: #4a90e2; + --shadow-color: rgba(255, 255, 255, 0.1); +} + +body { + color: var(--primary-color); + background-color: var(--background-color); +} + +.button { + background-color: var(--accent-color); + box-shadow: 0 2px 4px var(--shadow-color); +} + +.button:hover { + background-color: darken(var(--accent-color), 10%); +} + +.header, .footer { + background-color: darken(var(--background-color), 5%); + color: var(--secondary-color); +} + +.token { + border-color: var(--accent-color); +} + +.note { + background-color: lighten(var(--background-color), 5%); + color: var(--secondary-color); + box-shadow: 0 2px 4px var(--shadow-color); +} From 7192fe8afc9ffd7d88d68dd217a692ee7c6d93b3 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 02:35:27 +0000 Subject: [PATCH 3/5] feat: Add dark mode toggle functionality to App co --- src/components/App.tsx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/components/App.tsx diff --git a/src/components/App.tsx b/src/components/App.tsx new file mode 100644 index 000000000..688f443a4 --- /dev/null +++ b/src/components/App.tsx @@ -0,0 +1,34 @@ +import React, { Component } from 'react'; +import { DarkModeManager } from '../utils/DarkModeManager'; + +class App extends Component { + state = { + isDarkModeEnabled: false, + }; + + componentDidMount() { + const isDarkMode = DarkModeManager.isDarkModeEnabled(); + this.setState({ isDarkModeEnabled: isDarkMode }); + } + + handleDarkModeToggle = () => { + DarkModeManager.toggleDarkMode(); + this.setState(prevState => ({ + isDarkModeEnabled: !prevState.isDarkModeEnabled, + })); + }; + + render() { + const { isDarkModeEnabled } = this.state; + return ( +