questionTooltip.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import styled from '@emotion/styled';
  2. import Tooltip from 'sentry/components/tooltip';
  3. import {IconQuestion} from 'sentry/icons';
  4. import type {Color, IconSize} from 'sentry/utils/theme';
  5. type ContainerProps = {
  6. size: IconSize | string;
  7. className?: string;
  8. };
  9. const QuestionIconContainer = styled('span')<ContainerProps>`
  10. display: inline-block;
  11. height: ${p => p.theme.iconSizes[p.size] ?? p.size};
  12. line-height: ${p => p.theme.iconSizes[p.size] ?? p.size};
  13. & svg {
  14. transition: 120ms opacity;
  15. color: ${p => p.theme.subText};
  16. opacity: 0.6;
  17. &:hover {
  18. opacity: 1;
  19. }
  20. }
  21. `;
  22. type QuestionProps = {
  23. size: string;
  24. title: React.ReactNode;
  25. className?: string;
  26. color?: Color;
  27. } & Pick<React.ComponentProps<typeof Tooltip>, 'position'> &
  28. Partial<
  29. Pick<
  30. React.ComponentProps<typeof Tooltip>,
  31. 'containerDisplayMode' | 'isHoverable' | 'overlayStyle'
  32. >
  33. >;
  34. function QuestionTooltip({
  35. title,
  36. size,
  37. color,
  38. className,
  39. ...tooltipProps
  40. }: QuestionProps) {
  41. return (
  42. <QuestionIconContainer size={size} className={className}>
  43. <Tooltip title={title} {...tooltipProps}>
  44. <IconQuestion size={size} color={color} data-test-id="more-information" />
  45. </Tooltip>
  46. </QuestionIconContainer>
  47. );
  48. }
  49. export default QuestionTooltip;