mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Upgrades biome to 1.6.1, and updates husky pre-commit hook. Most changes here are making type imports explicit.
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import UIContext, { type themeMode } from 'contexts/UIContext';
 | |
| import { useContext } from 'react';
 | |
| import { setLocalStorageItem } from 'utils/storage';
 | |
| import mainTheme from 'themes/theme';
 | |
| import darkTheme from 'themes/dark-theme';
 | |
| import type { Theme } from '@mui/material/styles/createTheme';
 | |
| 
 | |
| interface IUseThemeModeOutput {
 | |
|     resolveTheme: () => Theme;
 | |
|     onSetThemeMode: () => void;
 | |
|     themeMode: themeMode;
 | |
| }
 | |
| 
 | |
| export const useThemeMode = (): IUseThemeModeOutput => {
 | |
|     const { themeMode, setThemeMode } = useContext(UIContext);
 | |
|     const key = 'unleash-theme';
 | |
| 
 | |
|     const resolveTheme = () => {
 | |
|         if (themeMode === 'light') {
 | |
|             return mainTheme;
 | |
|         }
 | |
| 
 | |
|         return darkTheme;
 | |
|     };
 | |
| 
 | |
|     const onSetThemeMode = () => {
 | |
|         setThemeMode((prev: themeMode) => {
 | |
|             if (prev === 'light') {
 | |
|                 setLocalStorageItem(key, 'dark');
 | |
|                 return 'dark';
 | |
|             }
 | |
|             setLocalStorageItem(key, 'light');
 | |
|             return 'light';
 | |
|         });
 | |
|     };
 | |
| 
 | |
|     return { resolveTheme, onSetThemeMode, themeMode };
 | |
| };
 |