info-tooltip.tsx41 lines · main
| 1 | // Required to avoid issue: |
| 2 | // The inferred type of InfoTooltip cannot be named without a reference to TooltipContentProps |
| 3 | import { Tooltip as _RadixToolpip } from 'radix-ui' |
| 4 | import { ElementRef, forwardRef } from 'react' |
| 5 | import { Tooltip, TooltipContent, TooltipTrigger } from 'ui' |
| 6 | |
| 7 | const SVG = forwardRef<SVGSVGElement, React.SVGProps<SVGSVGElement>>((props, ref) => ( |
| 8 | <svg |
| 9 | ref={ref} |
| 10 | xmlns="http://www.w3.org/2000/svg" |
| 11 | viewBox="0 0 16 16" |
| 12 | fill="currentColor" |
| 13 | {...props} |
| 14 | > |
| 15 | <path |
| 16 | d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" |
| 17 | fillRule="evenodd" |
| 18 | clipRule="evenodd" |
| 19 | /> |
| 20 | </svg> |
| 21 | )) |
| 22 | |
| 23 | const InfoTooltip = forwardRef< |
| 24 | ElementRef<typeof TooltipContent>, |
| 25 | React.ComponentPropsWithoutRef<typeof TooltipContent> |
| 26 | >(({ ...props }, _ref) => { |
| 27 | return ( |
| 28 | <Tooltip> |
| 29 | <TooltipTrigger |
| 30 | type="button" |
| 31 | role="button" |
| 32 | className="flex [&_svg]:data-[state=delayed-open]:fill-foreground-lighter [&_svg]:data-[state=instant-open]:fill-foreground-lighter" |
| 33 | > |
| 34 | <SVG strokeWidth={2} className="transition-colors fill-foreground-muted w-4 h-4" /> |
| 35 | </TooltipTrigger> |
| 36 | <TooltipContent {...props} /> |
| 37 | </Tooltip> |
| 38 | ) |
| 39 | }) |
| 40 | |
| 41 | export { InfoTooltip } |