icon-with-tooltip.tsx 1008 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React, { type FC } from 'react'
  2. import cn from '@/utils/classnames'
  3. import Tooltip from '@/app/components/base/tooltip'
  4. import { Theme } from '@/types/app'
  5. type IconWithTooltipProps = {
  6. className?: string
  7. popupContent?: string
  8. theme: Theme
  9. BadgeIconLight: React.ElementType
  10. BadgeIconDark: React.ElementType
  11. }
  12. const IconWithTooltip: FC<IconWithTooltipProps> = ({
  13. className,
  14. theme,
  15. popupContent,
  16. BadgeIconLight,
  17. BadgeIconDark,
  18. }) => {
  19. const isDark = theme === Theme.dark
  20. const iconClassName = cn('h-5 w-5', className)
  21. const Icon = isDark ? BadgeIconDark : BadgeIconLight
  22. return (
  23. <Tooltip
  24. popupClassName='p-1.5 border-[0.5px] border-[0.5px] border-components-panel-border bg-components-tooltip-bg text-text-secondary system-xs-medium'
  25. popupContent={popupContent}
  26. >
  27. <div className='flex shrink-0 items-center justify-center'>
  28. <Icon className={iconClassName} />
  29. </div>
  30. </Tooltip>
  31. )
  32. }
  33. export default React.memo(IconWithTooltip)