forked from dungeon-revealer/dungeon-revealer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add DarkModeManager for managing dark mode p
- Loading branch information
1 parent
a8cdc1d
commit f922321
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |