howl/src/divider.tsx
Chris Wanstrath 0cad100197 ________ ______ _______ ______ ________
/        |/      \ /       \  /      \ /        |
$$$$$$$$//$$$$$$  |$$$$$$$  |/$$$$$$  |$$$$$$$$/
$$ |__   $$ |  $$ |$$ |__$$ |$$ | _$$/ $$ |__
$$    |  $$ |  $$ |$$    $$< $$ |/    |$$    |
$$$$$/   $$ |  $$ |$$$$$$$  |$$ |$$$$ |$$$$$/
$$ |     $$ \__$$ |$$ |  $$ |$$ \__$$ |$$ |_____
$$ |     $$    $$/ $$ |  $$ |$$    $$/ $$       |
$$/       $$$$$$/  $$/   $$/  $$$$$$/  $$$$$$$$/
2026-01-16 08:33:38 -08:00

63 lines
1.3 KiB
TypeScript

import { define } from 'forge'
import { theme } from './theme'
import { Section } from './section'
import { H2 } from './text'
import { VStack } from './stack'
export const Divider = define('Divider', {
display: 'flex',
alignItems: 'center',
margin: `${theme('spacing-4')} 0`,
parts: {
Line: {
flex: 1,
borderTop: `1px solid ${theme('colors-border')}`,
},
Text: {
base: 'span',
padding: `0 ${theme('spacing-3')}`,
fontSize: theme('fontSize-sm'),
color: theme('colors-fgMuted'),
background: theme('colors-bg'),
},
},
render({ props, parts: { Root, Line, Text } }) {
const { children, ...rest } = props
return (
<Root {...rest}>
<Line />
{children && (
<>
<Text>{children}</Text>
<Line />
</>
)}
</Root>
)
},
})
export const Test = () => {
return (
<Section gap={4} style={{ maxWidth: '448px', padding: '16px' }}>
<H2>Divider Examples</H2>
<VStack gap={0}>
<p>Would you like to continue</p>
<Divider>OR WOULD YOU LIKE TO</Divider>
<p>Submit to certain death</p>
</VStack>
{/* Just a line */}
<VStack gap={0}>
<p>Look a line</p>
<Divider />
<p>So cool, so straight!</p>
</VStack>
</Section>
)
}