hensei-web/components/common/SelectItem/index.tsx
Justin Edmund 106b2b8ee4 Update Select component
* data-placeholder style should match only if true
* Adjust corner radius to match cards instead of inputs
* Fix classNames call in SelectItem
2023-06-05 20:20:23 -07:00

31 lines
779 B
TypeScript

import React, { ComponentProps } from 'react'
import * as Select from '@radix-ui/react-select'
import './index.scss'
import classNames from 'classnames'
interface Props extends ComponentProps<'div'> {
value: string | number
iconSrc?: string
altText?: string
}
const SelectItem = React.forwardRef<HTMLDivElement, Props>(function selectItem(
{ children, value, ...props },
forwardedRef
) {
const { altText, iconSrc, ...rest } = props
return (
<Select.Item
{...rest}
className={classNames({ SelectItem: true }, props.className)}
ref={forwardedRef}
value={`${value}`}
>
{iconSrc ? <img alt={altText} src={iconSrc} /> : ''}
<Select.ItemText>{children}</Select.ItemText>
</Select.Item>
)
})
export default SelectItem