learn-more.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { CircleQuestionMark } from 'lucide-react'
  2. import { useTranslation } from 'react-i18next'
  3. import { cn } from '@/lib/utils'
  4. import { Button } from '@/components/ui/button'
  5. import {
  6. Popover,
  7. PopoverContent,
  8. PopoverTrigger,
  9. } from '@/components/ui/popover'
  10. type LearnMoreProps = Omit<React.ComponentProps<typeof Popover>, 'children'> & {
  11. children?: React.ReactNode
  12. contentProps?: React.ComponentProps<typeof PopoverContent>
  13. triggerProps?: React.ComponentProps<typeof PopoverTrigger>
  14. }
  15. export function LearnMore({
  16. children,
  17. contentProps,
  18. triggerProps,
  19. ...props
  20. }: LearnMoreProps) {
  21. const { t } = useTranslation()
  22. return (
  23. <Popover {...props}>
  24. <PopoverTrigger
  25. {...triggerProps}
  26. className={cn('size-5 rounded-full', triggerProps?.className)}
  27. render={<Button variant='outline' size='icon' />}
  28. >
  29. <span className='sr-only'>{t('Learn more')}</span>
  30. <CircleQuestionMark className='size-4 [&>circle]:hidden' />
  31. </PopoverTrigger>
  32. <PopoverContent
  33. side='top'
  34. align='start'
  35. {...contentProps}
  36. className={cn('text-muted-foreground text-sm', contentProps?.className)}
  37. >
  38. {children}
  39. </PopoverContent>
  40. </Popover>
  41. )
  42. }