questionTooltip.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import styled from '@emotion/styled';
  2. import {Tooltip, TooltipProps} from 'sentry/components/tooltip';
  3. import {IconQuestion} from 'sentry/icons';
  4. import type {IconSize} from 'sentry/utils/theme';
  5. interface QuestionProps
  6. extends Partial<
  7. Pick<
  8. TooltipProps,
  9. 'containerDisplayMode' | 'isHoverable' | 'overlayStyle' | 'position'
  10. >
  11. > {
  12. /**
  13. * Set's the size of the icon.
  14. *
  15. * Remember to keep the size relative to the text or content it is near.
  16. */
  17. size: IconSize;
  18. /**
  19. * The message to show in the question icons tooltip
  20. */
  21. title: React.ReactNode;
  22. className?: string;
  23. }
  24. function QuestionTooltip({title, size, className, ...tooltipProps}: QuestionProps) {
  25. return (
  26. <QuestionIconContainer size={size} className={className}>
  27. <Tooltip title={title} {...tooltipProps}>
  28. <IconQuestion size={size} color="subText" data-test-id="more-information" />
  29. </Tooltip>
  30. </QuestionIconContainer>
  31. );
  32. }
  33. const QuestionIconContainer = styled('span')<Pick<QuestionProps, 'size' | 'className'>>`
  34. display: inline-block;
  35. height: ${p => p.theme.iconSizes[p.size]};
  36. line-height: ${p => p.theme.iconSizes[p.size]};
  37. & svg {
  38. transition: 120ms opacity;
  39. opacity: 0.6;
  40. &:hover {
  41. opacity: 1;
  42. }
  43. }
  44. `;
  45. export default QuestionTooltip;