stackTraceMiniFrame.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ProjectAvatar from 'sentry/components/avatar/projectAvatar';
  4. import {t} from 'sentry/locale';
  5. import {space} from 'sentry/styles/space';
  6. import {Frame, Project} from 'sentry/types';
  7. interface Props {
  8. frame: Partial<Pick<Frame, 'absPath' | 'colNo' | 'function' | 'lineNo'>>;
  9. project?: Project;
  10. }
  11. export function StackTraceMiniFrame({frame, project}: Props) {
  12. return (
  13. <FrameContainer>
  14. {project && (
  15. <ProjectAvatarContainer>
  16. <ProjectAvatar project={project} size={16} />
  17. </ProjectAvatarContainer>
  18. )}
  19. {frame.absPath && <Emphasize>{frame?.absPath}</Emphasize>}
  20. {frame.function && (
  21. <Fragment>
  22. <Deemphasize> {t('in')} </Deemphasize>
  23. <Emphasize>{frame?.function}</Emphasize>
  24. </Fragment>
  25. )}
  26. {frame.lineNo && (
  27. <Fragment>
  28. <Deemphasize> {t('at line')} </Deemphasize>
  29. <Emphasize>{frame?.lineNo}</Emphasize>
  30. </Fragment>
  31. )}
  32. </FrameContainer>
  33. );
  34. }
  35. const FrameContainer = styled('div')`
  36. display: flex;
  37. align-items: center;
  38. gap: ${space(0.5)};
  39. padding: ${space(1.5)} ${space(2)};
  40. font-family: ${p => p.theme.text.family};
  41. font-size: ${p => p.theme.fontSizeMedium};
  42. border-top: 1px solid ${p => p.theme.border};
  43. background: ${p => p.theme.surface200};
  44. `;
  45. const ProjectAvatarContainer = styled('div')`
  46. margin-right: ${space(1)};
  47. `;
  48. const Emphasize = styled('span')`
  49. color: ${p => p.theme.gray500};
  50. `;
  51. const Deemphasize = styled('span')`
  52. color: ${p => p.theme.gray300};
  53. `;