githubFeedbackTooltip.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import {Tooltip, TooltipProps} from 'sentry/components/tooltip';
  5. import {IconGithub} from 'sentry/icons';
  6. import {tct} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. type GithubFeedbackTooltipProps = TooltipProps & {
  9. href: string;
  10. title?: React.ReactNode;
  11. };
  12. export function GithubFeedbackTooltip({
  13. href,
  14. title,
  15. ...props
  16. }: GithubFeedbackTooltipProps) {
  17. return (
  18. <Tooltip
  19. isHoverable
  20. title={
  21. <Fragment>
  22. {title}
  23. <FeedbackLine hasTitle={!!title}>
  24. {tct('Give us feedback on [githubLink]', {
  25. githubLink: (
  26. <GithubLink href={href}>
  27. GitHub <IconGithub size="xs" />
  28. </GithubLink>
  29. ),
  30. })}
  31. </FeedbackLine>
  32. </Fragment>
  33. }
  34. {...props}
  35. />
  36. );
  37. }
  38. const FeedbackLine = styled('div')<{hasTitle: boolean}>`
  39. ${p => p.hasTitle && `padding-top: ${space(1)};`}
  40. `;
  41. const GithubLink = styled(ExternalLink)`
  42. display: inline-flex;
  43. align-items: center;
  44. justify-content: center;
  45. gap: ${space(0.5)};
  46. line-height: 0px;
  47. & > svg {
  48. margin-top: -1px;
  49. }
  50. `;