import * as React from 'react' import { useThemeValue } from '../system' import { StackView, StackViewProps } from '../StackView' import { cloneChildren } from '../utils' export type CardProps = { /** Adds a slightly higher contrast background. */ subdued?: boolean } & StackViewProps type Props = React.RefAttributes & React.HTMLAttributes & CardProps function Section({ subdued, ...restProps }: Props) { return ( ) } export function Card({ children, subdued, radius = 3, ...restProps }: Props) { const cardTheme = useThemeValue('card') return ( {radius > 0 ? cloneChildren(children, (child, { firstChild, lastChild }) => child.props.radius === undefined ? firstChild ? { [`radius${ restProps.axis === 'horizontal' ? 'Left' : 'Top' }`]: (radius as number) - 1, } : lastChild ? { [`radius${ restProps.axis === 'horizontal' ? 'Right' : 'Bottom' }`]: (radius as number) - 1, } : {} : {} ) : children} ) } Card.Section = Section