learn-more.tsx 1.2 KB

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