Skip to content

Commit ce5d5c4

Browse files
committed
feat: add showSwitchThemeLocationTippy state and handler to ThemeProvider for improved theme switching experience
1 parent c982e46 commit ce5d5c4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Shared/Providers/ThemeProvider/ThemeProvider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const themeContext = createContext<ThemeContextType>(null)
2828

2929
export const ThemeProvider = ({ children }: ThemeProviderProps) => {
3030
const [showThemeSwitcherDialog, setShowThemeSwitcherDialog] = useState<boolean>(false)
31+
const [showSwitchThemeLocationTippy, setShowSwitchThemeLocationTippy] = useState<boolean>(false)
3132
const [themeConfig, setThemeConfig] = useState<ThemeConfigType>(getThemeConfigFromLocalStorage)
3233

3334
const handleThemePreferenceChange: ThemeContextType['handleThemePreferenceChange'] = (updatedThemePreference) => {
@@ -73,14 +74,20 @@ export const ThemeProvider = ({ children }: ThemeProviderProps) => {
7374
setShowThemeSwitcherDialog(isVisible)
7475
}
7576

77+
const handleShowSwitchThemeLocationTippyChange = (isVisible: boolean) => {
78+
setShowSwitchThemeLocationTippy(isVisible)
79+
}
80+
7681
const value = useMemo<ThemeContextType>(
7782
() => ({
7883
...themeConfig,
7984
showThemeSwitcherDialog,
8085
handleThemeSwitcherDialogVisibilityChange,
8186
handleThemePreferenceChange,
87+
showSwitchThemeLocationTippy,
88+
handleShowSwitchThemeLocationTippyChange,
8289
}),
83-
[themeConfig, showThemeSwitcherDialog],
90+
[themeConfig, showThemeSwitcherDialog, showSwitchThemeLocationTippy],
8491
)
8592

8693
return <themeContext.Provider value={value}>{children}</themeContext.Provider>

src/Shared/Providers/ThemeProvider/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export interface ThemeConfigType {
4646
}
4747

4848
export interface ThemeContextType extends ThemeConfigType {
49+
showSwitchThemeLocationTippy: boolean
50+
handleShowSwitchThemeLocationTippyChange: (isVisible: boolean) => void
4951
showThemeSwitcherDialog: boolean
5052
handleThemeSwitcherDialogVisibilityChange: (isVisible: boolean) => void
5153
handleThemePreferenceChange: (updatedThemePreference: ThemePreferenceType) => void

0 commit comments

Comments
 (0)