-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f262c3
commit 5beed55
Showing
1 changed file
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
import { ComponentType, ElementType, forwardRef } from 'react' | ||
import { cva, VariantProps } from 'class-variance-authority' | ||
import { ComponentType } from 'react' | ||
|
||
import { | ||
Box, | ||
PolymorphicComponent, | ||
PolymorphicProps, | ||
PolymorphicRef, | ||
} from '~/components/Box' | ||
import { Text } from '~/components/Text' | ||
import { IconProps } from '~/icons/types' | ||
|
||
type TagProps = { | ||
const tagVariants = cva( | ||
[ | ||
'inline-flex', | ||
'gap-1', | ||
'px-2', | ||
'py-1', | ||
'whitespace-nowrap', | ||
'bg-button-glass', | ||
'text-text-80', | ||
'rounded-xs', | ||
], | ||
{ | ||
variants: { | ||
// Add any variants here if needed in the future | ||
}, | ||
} | ||
) | ||
|
||
interface TagProps extends VariantProps<typeof tagVariants> { | ||
label: string | ||
icon?: ComponentType<IconProps> | ||
className?: string | ||
} | ||
|
||
export const Tag: PolymorphicComponent<TagProps, 'div'> = forwardRef( | ||
<T extends ElementType>( | ||
props: PolymorphicProps<TagProps, T>, | ||
ref: PolymorphicRef<T> | ||
) => { | ||
const { icon: Icon, label, ...rest } = props | ||
export const Tag = (props: TagProps) => { | ||
const { icon: Icon, label, className, ...rest } = props | ||
|
||
return ( | ||
<Box | ||
ref={ref} | ||
background="buttonGlass" | ||
borderRadius="xs" | ||
display="inline-flex" | ||
gap="1" | ||
paddingX="2" | ||
paddingY="1" | ||
whiteSpace="nowrap" | ||
color="text80" | ||
{...rest} | ||
> | ||
{Icon && <Icon size="xs" />} | ||
<Text variant="xsmall">{label}</Text> | ||
</Box> | ||
) | ||
} | ||
) | ||
return ( | ||
<div className={tagVariants({ className })} {...rest}> | ||
{Icon && <Icon size="xs" />} | ||
<Text variant="xsmall">{label}</Text> | ||
</div> | ||
) | ||
} |