mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-06 23:43:45 +02:00
refact: convert components to use React.FC type + type improvements
This commit is contained in:
committed by
Jean-Philippe Sirois
parent
d61c218657
commit
1d88367645
@@ -1,23 +1,22 @@
|
||||
import React, { createContext, useMemo } from "react"
|
||||
import React, { createContext, FC, useMemo } from "react"
|
||||
import { ThemeProvider as BaseThemeProvider } from "styled-components"
|
||||
|
||||
import { darkTheme, lightTheme } from "./design/themes"
|
||||
import { useLocalStorage } from "./hooks/useLocalStorage"
|
||||
|
||||
interface IThemeProviderProps {
|
||||
// TODO: type this properly, BaseThemeProvider doesn't like React.ReactNode
|
||||
children: any
|
||||
}
|
||||
|
||||
export interface IThemeContext {
|
||||
theme: "dark" | "light"
|
||||
setTheme: () => void
|
||||
toggleTheme: () => void
|
||||
}
|
||||
|
||||
interface IScopedDownChildren {
|
||||
children: JSX.Element
|
||||
}
|
||||
|
||||
export const ThemeContext = createContext<IThemeContext | null>(null)
|
||||
|
||||
const ThemeProvider = ({ children }: IThemeProviderProps) => {
|
||||
const ThemeProvider: FC<IScopedDownChildren> = ({ children }) => {
|
||||
const [theme, setTheme] = useLocalStorage("theme", "light")
|
||||
|
||||
const themeObject = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user