-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: polish lightning and add darkmode background (#922)
* enhancement: polish scene lightning * fix: update dep array * chore: remove unused `color` prop from directionalLight --------- Co-authored-by: Begoña Alvarez <[email protected]>
- Loading branch information
1 parent
6ebf10f
commit 95180c0
Showing
4 changed files
with
48 additions
and
8 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,4 @@ | ||
export enum ThemeMode { | ||
Light = "light", | ||
Dark = "dark" | ||
} |
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,30 @@ | ||
import { useEffect, useState } from 'react' | ||
import { ServiceFactory } from '~/factories/serviceFactory' | ||
import { ThemeMode } from '~/features/visualizer-threejs/enums'; | ||
import { SettingsService } from '~/services/settingsService' | ||
|
||
export function useGetThemeMode(): ThemeMode { | ||
const [settingsService] = useState<SettingsService>( | ||
ServiceFactory.get<SettingsService>('settings') | ||
) | ||
|
||
const [isDarkMode, setIsDarkMode] = useState<boolean | null>( | ||
settingsService.get().darkMode ?? null | ||
) | ||
|
||
const themeMode = isDarkMode ? ThemeMode.Dark : ThemeMode.Light | ||
|
||
function toggleDarkMode(event: Event): void { | ||
const darkMode = (event as CustomEvent).detail.darkMode | ||
setIsDarkMode(darkMode) | ||
} | ||
|
||
useEffect(() => { | ||
window.addEventListener('theme-change', toggleDarkMode) | ||
return () => { | ||
window.removeEventListener('theme-change', toggleDarkMode) | ||
} | ||
}, []) | ||
|
||
return themeMode | ||
} |