Skip to content

Commit

Permalink
feat: Add DarkModeManager for managing dark mode p
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Feb 12, 2024
1 parent a8cdc1d commit f922321
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/utils/DarkModeManager.ts
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 };

0 comments on commit f922321

Please sign in to comment.