ConstraintToken.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { ReactNode } from 'react'
  2. import { cn } from 'ui'
  3. interface ConstraintTokenProps {
  4. icon?: ReactNode
  5. label: string
  6. variant?: 'default' | 'secondary' | 'primary'
  7. }
  8. const constraintTokenClassName = cn(
  9. 'inline-flex items-center justify-center rounded-md text-center font-mono uppercase whitespace-nowrap font-medium',
  10. 'tracking-[0.06em] text-[11px] leading-[1.1] px-[5.5px] h-[21px]',
  11. 'transition-all border'
  12. )
  13. export const ConstraintToken = ({ icon, label, variant = 'default' }: ConstraintTokenProps) => {
  14. const tokenToneClassName =
  15. variant === 'primary'
  16. ? 'bg-brand/10 text-brand-600 border-brand-500'
  17. : variant === 'default'
  18. ? 'bg-surface-75 text-foreground-light border-strong'
  19. : 'bg-surface-75/50 text-foreground-light border-strong'
  20. return (
  21. <div className="inline-flex items-center whitespace-nowrap">
  22. {icon && (
  23. <span
  24. className={cn(constraintTokenClassName, tokenToneClassName, 'rounded-r-none border-r-0')}
  25. >
  26. {icon}
  27. </span>
  28. )}
  29. <span
  30. className={cn(
  31. constraintTokenClassName,
  32. tokenToneClassName,
  33. icon ? 'rounded-l-none' : 'rounded-md'
  34. )}
  35. >
  36. {label}
  37. </span>
  38. </div>
  39. )
  40. }