Files
sentinel/static/app/components/githubFeedbackTooltip.tsx
2024-02-15 17:01:50 +00:00

58 lines
1.3 KiB
TypeScript

import {Fragment} from 'react';
import styled from '@emotion/styled';
import ExternalLink from 'sentry/components/links/externalLink';
import type {TooltipProps} from 'sentry/components/tooltip';
import {Tooltip} from 'sentry/components/tooltip';
import {IconGithub} from 'sentry/icons';
import {tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
type GithubFeedbackTooltipProps = TooltipProps & {
href: string;
title?: React.ReactNode;
};
export function GithubFeedbackTooltip({
href,
title,
...props
}: GithubFeedbackTooltipProps) {
return (
<Tooltip
isHoverable
title={
<Fragment>
{title}
<FeedbackLine hasTitle={!!title}>
{tct('Give us feedback on [githubLink]', {
githubLink: (
<GithubLink href={href}>
GitHub <IconGithub size="xs" />
</GithubLink>
),
})}
</FeedbackLine>
</Fragment>
}
{...props}
/>
);
}
const FeedbackLine = styled('div')<{hasTitle: boolean}>`
${p => p.hasTitle && `padding-top: ${space(1)};`}
`;
const GithubLink = styled(ExternalLink)`
display: inline-flex;
align-items: center;
justify-content: center;
gap: ${space(0.5)};
line-height: 0px;
& > svg {
margin-top: -1px;
}
`;