-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added theme toggler to parallax scroll view, added new icon, deleted …
…unused hooks
- Loading branch information
1 parent
8b2d2e4
commit 9db947b
Showing
8 changed files
with
76 additions
and
41 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
import React, { createContext, ReactNode, useContext, useState } from 'react'; | ||
type Theme = 'light' | 'dark'; | ||
type ThemContextType = { | ||
theme: Theme; | ||
toggleTheme: () => void; | ||
}; | ||
|
||
const ThemeContext = createContext<ThemContextType | undefined>(undefined); | ||
|
||
export const ThemeProvider = ({children} : { children: ReactNode}) => { | ||
const [theme, setTheme] = useState<Theme>('light'); | ||
|
||
const toggleTheme = () => { | ||
setTheme((prevTheme) => (prevTheme === 'light' ? 'dark' : 'light')); | ||
}; | ||
|
||
return ( | ||
<ThemeContext.Provider value={{ theme, toggleTheme}}> | ||
{children} | ||
</ThemeContext.Provider> | ||
); | ||
}; | ||
|
||
export const useTheme = () => { | ||
const context = useContext(ThemeContext); | ||
if (!context) { | ||
throw new Error('useTheme must be used within a ThemeProvider'); | ||
} | ||
return context; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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