Something went wrong. Try again.
hardened bluesky app fork with microcosm
Something went wrong. Try again.
1.1 kB · 60 lines
TSX
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import {createContext, useContext, useMemo} from 'react'import {View} from 'react-native'
import {atoms as a, type ViewStyleProp} from '#/alf'
const Context = createContext({ gap: 0,})Context.displayName = 'GridContext'
export function Row({ children, gap = 0, style,}: ViewStyleProp & { children: React.ReactNode gap?: number}) { return ( <Context.Provider value={useMemo(() => ({gap}), [gap])}> <View style={[ a.flex_row, a.flex_1, { marginLeft: -gap / 2, marginRight: -gap / 2, }, style, ]}> {children} </View> </Context.Provider> )}
export function Col({ children, width = 1, style,}: ViewStyleProp & { children: React.ReactNode width?: number}) { const {gap} = useContext(Context) return ( <View style={[ a.flex_col, { paddingLeft: gap / 2, paddingRight: gap / 2, width: `${width * 100}%`, }, style, ]}> {children} </View> )}