Skip to content

Commit

Permalink
Add DetailsList component
Browse files Browse the repository at this point in the history
  • Loading branch information
Youakeem committed Sep 16, 2024
1 parent 99910b4 commit 2853b82
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/store/src/components/DetailsList/DetailsList.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { style } from '@vanilla-extract/css'
import { tokens, xStack } from 'ui'

export const detailsListRoot = style({
listStyle: 'none',
color: tokens.colors.textTranslucentSecondary,
})

export const detailsListItem = style([
xStack({ justifyContent: 'space-between' }),
{
fontSize: 'inherit',
},
])

export const detailsListLabel = style({
textAlign: 'start',
})

export const detailsListValue = style({
textAlign: 'end',
})
54 changes: 54 additions & 0 deletions apps/store/src/components/DetailsList/DetailsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import clsx from 'clsx'
import { type ComponentProps } from 'react'
import { type FontSizeProps, sprinkles } from 'ui'
import {
detailsListItem,
detailsListLabel,
detailsListRoot,
detailsListValue,
} from './DetailsList.css'

type RootProps = ComponentProps<'ul'> & {
size?: FontSizeProps
}
const DetailsListRoot = ({ size = 'xs', className, children, ...props }: RootProps) => {
return (
<ul className={clsx(detailsListRoot, sprinkles({ fontSize: size }), className)} {...props}>
{children}
</ul>
)
}

type ItemProps = ComponentProps<'li'>
const DetailsListItem = ({ className, children, ...props }: ItemProps) => {
return (
<li className={clsx(className, detailsListItem)} {...props}>
{children}
</li>
)
}

type LabelProps = ComponentProps<'span'>
const DetailsListLabel = ({ className, children, ...props }: LabelProps) => {
return (
<span className={clsx(className, detailsListLabel)} {...props}>
{children}
</span>
)
}

type ValueProps = ComponentProps<'span'>
const DetailsListValue = ({ className, children, ...props }: ValueProps) => {
return (
<span className={clsx(className, detailsListValue)} {...props}>
{children}
</span>
)
}

export const DetailsList = {
Root: DetailsListRoot,
Item: DetailsListItem,
Label: DetailsListLabel,
Value: DetailsListValue,
}

0 comments on commit 2853b82

Please sign in to comment.