add initial accessibility panel
This commit is contained in:
1 parent
605ff872e8
commit
85c0d8c4ab
15 files changed
+764
-56
No files matched your search
@@ -1,17 +0,0 @@
|
||||
import { useLocalStorage } from "react-use"
|
||||
import { ThemeContext } from "./ThemeContext"
|
||||
import { ThemeType } from "./types"
|
||||
|
||||
export type ThemeProps = {
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Theme: React.FC<ThemeProps> = ({ children }) => {
|
||||
const [theme, setTheme] = useLocalStorage<ThemeType>("hudozka-theme", "default")
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={[theme ?? "default", setTheme]}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createContext } from "react"
|
||||
import { SetTheme, ThemeType } from "./types"
|
||||
import { DEFAULT } from "./const"
|
||||
import { SetTheme, ThemeOptions } from "./types"
|
||||
|
||||
export const ThemeContext = createContext<[ThemeType, SetTheme]>(["default", () => {}])
|
||||
export const ThemeContext = createContext<[ThemeOptions, SetTheme]>([DEFAULT, () => {}])
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ThemeOptions } from "./types"
|
||||
|
||||
export const DEFAULT: ThemeOptions = {
|
||||
theme: "default",
|
||||
}
|
||||
@@ -1,2 +1,5 @@
|
||||
export type ThemeType = "default" | "contrast"
|
||||
export type SetTheme = (theme: ThemeType) => void
|
||||
export type ThemeOptions = {
|
||||
theme: "default" | "contrast"
|
||||
fontSize?: number
|
||||
}
|
||||
export type SetTheme = (theme: ThemeOptions["theme"]) => void
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useContext } from "react"
|
||||
import { ThemeContext } from "./ThemeContext"
|
||||
import { SetTheme, ThemeType } from "./types"
|
||||
import { SetTheme, ThemeOptions } from "./types"
|
||||
|
||||
export type UseThemeResult = {
|
||||
theme: ThemeType
|
||||
theme: ThemeOptions["theme"]
|
||||
setTheme: SetTheme
|
||||
// toggleTheme:
|
||||
}
|
||||
@@ -11,5 +11,8 @@ export type UseThemeResult = {
|
||||
export function useTheme(): UseThemeResult {
|
||||
const [theme, setTheme] = useContext(ThemeContext)
|
||||
|
||||
return { theme, setTheme }
|
||||
return {
|
||||
setTheme,
|
||||
theme: theme.theme ?? "default",
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user