-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add themeManager to manager global theme (#1835)
* chore: add themeManager to manager global theme * chore: remove momentum components * chore: export themeManager * chore: export default themeManager
- Loading branch information
Showing
4 changed files
with
102 additions
and
30 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
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
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,75 @@ | ||
import { action, computed, observable } from "mobx"; | ||
import { ThemeName } from "./Theme"; | ||
|
||
/** | ||
* ThemeManager is a singleton class that manages the global theme state. | ||
* It provides observable properties that can be observed by other classes | ||
* to set properties on their components, such as whether dark mode is enabled. | ||
*/ | ||
export class ThemeManager { | ||
/** | ||
* Observable property to indicate if dark mode is enabled | ||
* Is needed by components styled outside of the web components | ||
*/ | ||
@observable isDarkMode = false; | ||
|
||
/** | ||
* Observable property to store the current theme name | ||
*/ | ||
@observable themeName: ThemeName = "lumos"; | ||
|
||
/** | ||
* Observable property to indicate if visual rebrand is enabled | ||
* Will be used to allow users to toggle to updated visuals | ||
*/ | ||
@observable isVisualRebrandEnabled = false; | ||
|
||
/** | ||
* Observable property to indicate if Momentum Avatar is enabled | ||
* Should be used to set the new momentum style on avatars and sue | ||
* correct momentum presence states | ||
*/ | ||
@observable isMomentumAvatarEnabled = false; | ||
|
||
private static instance: ThemeManager; | ||
|
||
/** | ||
* Returns the singleton instance of ThemeManager. | ||
* If the instance does not exist, it creates a new one. | ||
* @returns {ThemeManager} The singleton instance of ThemeManager | ||
*/ | ||
static getInstance(): ThemeManager { | ||
if (!ThemeManager.instance) { | ||
ThemeManager.instance = new ThemeManager(); | ||
} | ||
|
||
return ThemeManager.instance; | ||
} | ||
|
||
@action setDarkMode(value: boolean) { | ||
this.isDarkMode = value; | ||
} | ||
|
||
@action setThemeName(value: ThemeName) { | ||
this.themeName = value; | ||
} | ||
|
||
@action setVisualRebrandEnabled(value: boolean) { | ||
this.isVisualRebrandEnabled = value; | ||
} | ||
|
||
@action setMomentumAvatar(value: boolean) { | ||
this.isMomentumAvatarEnabled = value; | ||
} | ||
|
||
/** | ||
* Computed property to check if the current theme is Momentum V2. | ||
* @returns {boolean} True if the current theme is Momentum V2, otherwise false | ||
*/ | ||
@computed get isMomentumV2Enabled() { | ||
return this.themeName === "momentumV2"; | ||
} | ||
} | ||
|
||
const themeManager = ThemeManager.getInstance(); | ||
export default themeManager; |
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