Fix theming in web app

This commit is contained in:
Pavel Prichodko 2023-01-16 16:19:06 +01:00
parent d2a3d65900
commit 98e9c1850d
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
2 changed files with 7 additions and 6 deletions

View File

@ -19,7 +19,7 @@ function App() {
const [theme, setTheme] = useState<ThemeVars>('light') const [theme, setTheme] = useState<ThemeVars>('light')
return ( return (
<TamaguiProvider config={tamaguiConfig}> <TamaguiProvider config={tamaguiConfig} defaultTheme={theme}>
<div id="app"> <div id="app">
<div id="sidebar"> <div id="sidebar">
<Sidebar <Sidebar
@ -53,11 +53,11 @@ function App() {
<Paragraph marginVertical={20}> <Paragraph marginVertical={20}>
Theme selected - {theme}{' '} Theme selected - {theme}{' '}
</Paragraph> </Paragraph>
<button <Button
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')} onPress={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
> >
Toogle theme Toogle theme
</button> </Button>
<Shape marginTop={20} /> <Shape marginTop={20} />
</Stack> </Stack>
</Stack> </Stack>

View File

@ -44,13 +44,14 @@ type BaseProps = GetProps<typeof Base>
interface Props { interface Props {
type?: BaseProps['type'] type?: BaseProps['type']
children: string children: string
onPress?: () => void
} }
const Button = (props: Props) => { const Button = (props: Props) => {
const { type = 'primary', children } = props const { type = 'primary', children, onPress } = props
return ( return (
<Base type={type}> <Base type={type} onPress={onPress}>
<ButtonText>{children}</ButtonText> <ButtonText>{children}</ButtonText>
</Base> </Base>
) )