sourceSuggestionExamples.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import styled from '@emotion/styled';
  2. import {Hovercard} from 'sentry/components/hovercard';
  3. import {IconQuestion} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import {space} from 'sentry/styles/space';
  6. type Props = {
  7. examples: Array<string>;
  8. sourceName: string;
  9. };
  10. function SourceSuggestionExamples({examples, sourceName}: Props) {
  11. return (
  12. <Wrapper>
  13. <ExampleCard
  14. position="right"
  15. header={t('Examples for %s in current event', <code>{sourceName}</code>)}
  16. body={examples.map(example => (
  17. <pre key={example}>{example}</pre>
  18. ))}
  19. >
  20. <Content>
  21. {t('See Example')} <IconQuestion size="xs" />
  22. </Content>
  23. </ExampleCard>
  24. </Wrapper>
  25. );
  26. }
  27. export default SourceSuggestionExamples;
  28. const ExampleCard = styled(Hovercard)`
  29. width: 400px;
  30. pre:last-child {
  31. margin: 0;
  32. }
  33. `;
  34. const Content = styled('span')`
  35. display: inline-grid;
  36. grid-template-columns: repeat(2, max-content);
  37. align-items: center;
  38. gap: ${space(0.5)};
  39. color: ${p => p.theme.gray400};
  40. font-size: ${p => p.theme.fontSizeSmall};
  41. text-decoration: underline;
  42. text-decoration-style: dotted;
  43. `;
  44. const Wrapper = styled('div')`
  45. grid-column: 3/3;
  46. `;