Skip to content

Commit

Permalink
feat: add theme property checkup
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeliatf committed Jan 30, 2024
1 parent adb6b34 commit ca565c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import HubButton from 'components/HubButton'
import { darkTheme, lightTheme } from 'components/themes'
import { useMemo } from 'react'
import { ThemeProvider } from 'styled-components'

export const App = ({ theme = 'light' }: { theme?: 'light' | 'dark' }) => {
const safeTheme = useMemo(() => {
if (!['light', 'dark'].includes(theme)) {
return 'light'
}
return theme
}, [theme])

return (
<ThemeProvider theme={theme === 'dark' ? darkTheme : lightTheme}>
<HubButton theme={theme} />
<ThemeProvider theme={safeTheme === 'dark' ? darkTheme : lightTheme}>
<HubButton theme={safeTheme} />
</ThemeProvider>
)
}
Expand Down

0 comments on commit ca565c4

Please sign in to comment.