|
| 1 | +import { Box, Text, descriptors } from '@/ui/customizables'; |
| 2 | +import { common } from '@/ui/styledSystem'; |
| 3 | +import { colors } from '@/ui/utils/colors'; |
| 4 | +import type { ComponentProps } from 'react'; |
| 5 | + |
| 6 | +export function ListGroup({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) { |
| 7 | + return ( |
| 8 | + <Box |
| 9 | + {...props} |
| 10 | + sx={[ |
| 11 | + t => ({ |
| 12 | + textAlign: 'start', |
| 13 | + borderWidth: t.borderWidths.$normal, |
| 14 | + borderStyle: t.borderStyles.$solid, |
| 15 | + borderColor: t.colors.$borderAlpha100, |
| 16 | + borderRadius: t.radii.$lg, |
| 17 | + overflow: 'hidden', |
| 18 | + }), |
| 19 | + sx, |
| 20 | + ]} |
| 21 | + elementDescriptor={descriptors.listGroup} |
| 22 | + > |
| 23 | + {children} |
| 24 | + </Box> |
| 25 | + ); |
| 26 | +} |
| 27 | + |
| 28 | +export function ListGroupHeader({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) { |
| 29 | + return ( |
| 30 | + <Box |
| 31 | + {...props} |
| 32 | + sx={[ |
| 33 | + t => ({ |
| 34 | + padding: t.space.$3, |
| 35 | + background: common.mergedColorsBackground( |
| 36 | + colors.setAlpha(t.colors.$colorBackground, 1), |
| 37 | + t.colors.$neutralAlpha50, |
| 38 | + ), |
| 39 | + }), |
| 40 | + sx, |
| 41 | + ]} |
| 42 | + elementDescriptor={descriptors.listGroupHeader} |
| 43 | + > |
| 44 | + {children} |
| 45 | + </Box> |
| 46 | + ); |
| 47 | +} |
| 48 | + |
| 49 | +export function ListGroupHeaderTitle(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) { |
| 50 | + return ( |
| 51 | + <Text |
| 52 | + {...props} |
| 53 | + variant='subtitle' |
| 54 | + elementDescriptor={descriptors.listGroupHeaderTitle} |
| 55 | + /> |
| 56 | + ); |
| 57 | +} |
| 58 | + |
| 59 | +export function ListGroupContent({ |
| 60 | + children, |
| 61 | + sx, |
| 62 | + ...props |
| 63 | +}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) { |
| 64 | + return ( |
| 65 | + <Box |
| 66 | + {...props} |
| 67 | + as='ul' |
| 68 | + sx={[t => ({ margin: t.sizes.$none, padding: t.sizes.$none }), sx]} |
| 69 | + elementDescriptor={descriptors.listGroupContent} |
| 70 | + > |
| 71 | + {children} |
| 72 | + </Box> |
| 73 | + ); |
| 74 | +} |
| 75 | + |
| 76 | +export function ListGroupItem({ |
| 77 | + children, |
| 78 | + sx, |
| 79 | + ...props |
| 80 | +}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) { |
| 81 | + return ( |
| 82 | + <Box |
| 83 | + {...props} |
| 84 | + as='li' |
| 85 | + sx={[ |
| 86 | + t => ({ |
| 87 | + display: 'flex', |
| 88 | + alignItems: 'baseline', |
| 89 | + paddingInline: t.space.$3, |
| 90 | + paddingBlock: t.space.$2, |
| 91 | + borderTopWidth: t.borderWidths.$normal, |
| 92 | + borderTopStyle: t.borderStyles.$solid, |
| 93 | + borderTopColor: t.colors.$borderAlpha100, |
| 94 | + '&::before': { |
| 95 | + content: '""', |
| 96 | + display: 'inline-block', |
| 97 | + width: t.space.$1, |
| 98 | + height: t.space.$1, |
| 99 | + background: t.colors.$colorMutedForeground, |
| 100 | + borderRadius: t.radii.$circle, |
| 101 | + transform: 'translateY(-0.1875rem)', |
| 102 | + marginInlineEnd: t.space.$2, |
| 103 | + flexShrink: 0, |
| 104 | + }, |
| 105 | + }), |
| 106 | + sx, |
| 107 | + ]} |
| 108 | + elementDescriptor={descriptors.listGroupItem} |
| 109 | + > |
| 110 | + {children} |
| 111 | + </Box> |
| 112 | + ); |
| 113 | +} |
| 114 | + |
| 115 | +export function ListGroupItemLabel(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) { |
| 116 | + return ( |
| 117 | + <Text |
| 118 | + {...props} |
| 119 | + variant='subtitle' |
| 120 | + elementDescriptor={descriptors.listGroupItemLabel} |
| 121 | + /> |
| 122 | + ); |
| 123 | +} |
0 commit comments