Add hooks example
This commit is contained in:
+114
-68
@@ -1,9 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import {View, Text as RNText} from 'react-native'
|
||||||
import {CenteredView, ScrollView} from '#/view/com/util/Views'
|
import {CenteredView, ScrollView} from '#/view/com/util/Views'
|
||||||
|
|
||||||
import {useSetColorMode} from '#/state/shell'
|
import {useSetColorMode} from '#/state/shell'
|
||||||
import {
|
import {
|
||||||
useBreakpoints,
|
useBreakpoints,
|
||||||
|
useStyle,
|
||||||
|
useStyles,
|
||||||
Box,
|
Box,
|
||||||
Text,
|
Text,
|
||||||
Button,
|
Button,
|
||||||
@@ -15,14 +18,32 @@ import {
|
|||||||
H6,
|
H6,
|
||||||
} from '#/view/nova'
|
} from '#/view/nova'
|
||||||
|
|
||||||
|
function ThemeSelector() {
|
||||||
|
const setColorMode = useSetColorMode()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box row gap="s">
|
||||||
|
<Button onPress={() => setColorMode('system')}>
|
||||||
|
<Text>System</Text>
|
||||||
|
</Button>
|
||||||
|
<Button onPress={() => setColorMode('light')}>
|
||||||
|
<Text>Light</Text>
|
||||||
|
</Button>
|
||||||
|
<Button onPress={() => setColorMode('dark')}>
|
||||||
|
<Text>Dark</Text>
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function BreakpointDebugger() {
|
function BreakpointDebugger() {
|
||||||
const breakpoints = useBreakpoints()
|
const breakpoints = useBreakpoints()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Text fontSize="l" fontWeight="900">
|
<H3 pb="s" fontWeight="900">
|
||||||
Breakpoints
|
Breakpoint Debugger
|
||||||
</Text>
|
</H3>
|
||||||
<Text pa="m" bg="l2" fontFamily="monospace">
|
<Text pa="m" bg="l2" fontFamily="monospace">
|
||||||
{JSON.stringify(breakpoints, null, 2)}
|
{JSON.stringify(breakpoints, null, 2)}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -30,83 +51,108 @@ function BreakpointDebugger() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DebugScreen() {
|
function Hooks() {
|
||||||
const setColorMode = useSetColorMode()
|
const outer = useStyle({
|
||||||
|
pa: 'm',
|
||||||
|
bg: 'l2',
|
||||||
|
})
|
||||||
|
const {heading} = useStyles({
|
||||||
|
heading: {
|
||||||
|
fontSize: 'l',
|
||||||
|
fontWeight: '900',
|
||||||
|
gtTablet: {
|
||||||
|
fontSize: 'xl',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={outer}>
|
||||||
|
<RNText style={heading}>Hooks</RNText>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DebugScreen() {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<CenteredView>
|
<CenteredView>
|
||||||
<Box pa="xl" gap="xxl">
|
<Box pa="xl" gap="xxl">
|
||||||
<Box row gap="s">
|
<ThemeSelector />
|
||||||
<Button onPress={() => setColorMode('system')}>
|
|
||||||
<Text>System</Text>
|
|
||||||
</Button>
|
|
||||||
<Button onPress={() => setColorMode('light')}>
|
|
||||||
<Text>Light</Text>
|
|
||||||
</Button>
|
|
||||||
<Button onPress={() => setColorMode('dark')}>
|
|
||||||
<Text>Dark</Text>
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<BreakpointDebugger />
|
<BreakpointDebugger />
|
||||||
|
|
||||||
<Box gap="m">
|
<Box>
|
||||||
<H1>Heading 1</H1>
|
<H3 pb="s" fontWeight="900">
|
||||||
<H2>Heading 2</H2>
|
Typography
|
||||||
<H3>Heading 3</H3>
|
</H3>
|
||||||
<H4>Heading 4</H4>
|
|
||||||
<H5>Heading 5</H5>
|
|
||||||
<H6>Heading 6</H6>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box gap="m">
|
<Box gap="m" pa="m" bg="l2">
|
||||||
<Text fontSize="xl" fontWeight="900">
|
<H1>Heading 1</H1>
|
||||||
H1 Size Text
|
<H2>Heading 2</H2>
|
||||||
</Text>
|
<H3>Heading 3</H3>
|
||||||
<Text fontSize="l">H2 Size Text</Text>
|
<H4>Heading 4</H4>
|
||||||
<Text fontSize="m">H3 Size Text</Text>
|
<H5>Heading 5</H5>
|
||||||
<Text fontSize="s">H4 Size Text</Text>
|
<H6>Heading 6</H6>
|
||||||
<Text fontSize="xs">H5 Size Text</Text>
|
<Text fontSize="xl" fontWeight="900">
|
||||||
<Text fontSize="xxs">H6 Size Text</Text>
|
H1 Size Text
|
||||||
</Box>
|
</Text>
|
||||||
|
<Text fontSize="l">H2 Size Text</Text>
|
||||||
<Box pa="s" gap="m" bg="l3">
|
<Text fontSize="m">H3 Size Text</Text>
|
||||||
<Box row gap="s">
|
<Text fontSize="s">H4 Size Text</Text>
|
||||||
<Box pa="s" bg="l6" />
|
<Text fontSize="xs">H5 Size Text</Text>
|
||||||
<Box pa="s" bg="l6" />
|
<Text fontSize="xxs">H6 Size Text</Text>
|
||||||
<Box pa="s" bg="l6" />
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box row gap="s">
|
|
||||||
<Box pa="s" bg="l6" flex={1} />
|
|
||||||
<Box pa="s" bg="l6" flex={1} />
|
|
||||||
<Box pa="s" bg="l6" flex={1} />
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box row gap="s">
|
|
||||||
<Box pa="s" bg="l6" flex={1} />
|
|
||||||
<Box pa="s" bg="l6" flex={2} />
|
|
||||||
<Box pa="s" bg="l6" flex={1} />
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
<Box>
|
||||||
row
|
<H3 pb="s" fontWeight="900">
|
||||||
justifyContent="center"
|
Grid
|
||||||
px="l"
|
</H3>
|
||||||
py="l"
|
<Box pa="m" gap="m" bg="l3">
|
||||||
bg="l3"
|
<Box row gap="s">
|
||||||
gtMobile={{
|
<Box pa="s" bg="l6" />
|
||||||
py: 'xl',
|
<Box pa="s" bg="l6" />
|
||||||
bg: 'l5',
|
<Box pa="s" bg="l6" />
|
||||||
}}
|
</Box>
|
||||||
gtTablet={{
|
|
||||||
py: 64,
|
<Box row gap="s">
|
||||||
bg: 'l7',
|
<Box pa="s" bg="l6" flex={1} />
|
||||||
}}>
|
<Box pa="s" bg="l6" flex={1} />
|
||||||
<Box w={64} h={64} bg="primary" />
|
<Box pa="s" bg="l6" flex={1} />
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box row gap="s">
|
||||||
|
<Box pa="s" bg="l6" flex={1} />
|
||||||
|
<Box pa="s" bg="l6" flex={2} />
|
||||||
|
<Box pa="s" bg="l6" flex={1} />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
<Box>
|
||||||
|
<H3 pb="s" fontWeight="900">
|
||||||
|
Breakpoint styles
|
||||||
|
</H3>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
row
|
||||||
|
justifyContent="center"
|
||||||
|
px="l"
|
||||||
|
py="l"
|
||||||
|
bg="l3"
|
||||||
|
gtMobile={{
|
||||||
|
py: 'xl',
|
||||||
|
bg: 'l5',
|
||||||
|
}}
|
||||||
|
gtTablet={{
|
||||||
|
py: 64,
|
||||||
|
bg: 'l7',
|
||||||
|
}}>
|
||||||
|
<Box w={64} h={64} bg="primary" />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Hooks />
|
||||||
</Box>
|
</Box>
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
Reference in New Issue
Block a user