default.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import styled from '@emotion/styled';
  2. import {IconRefresh} from 'sentry/icons/iconRefresh';
  3. import {tn} from 'sentry/locale';
  4. import space from 'sentry/styles/space';
  5. import {Frame} from 'sentry/types';
  6. import {defined} from 'sentry/utils';
  7. import DefaultTitle from '../defaultTitle';
  8. import Expander from './expander';
  9. import LeadHint from './leadHint';
  10. import Wrapper from './wrapper';
  11. type Props = React.ComponentProps<typeof Expander> &
  12. React.ComponentProps<typeof LeadHint> & {
  13. frame: Frame;
  14. isUsedForGrouping: boolean;
  15. onClick?: () => void;
  16. onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
  17. timesRepeated?: number;
  18. };
  19. function Default({
  20. frame,
  21. nextFrame,
  22. isHoverPreviewed,
  23. isExpanded,
  24. platform,
  25. timesRepeated,
  26. isUsedForGrouping,
  27. leadsToApp,
  28. onMouseDown,
  29. onClick,
  30. ...props
  31. }: Props) {
  32. function renderRepeats() {
  33. if (defined(timesRepeated) && timesRepeated > 0) {
  34. return (
  35. <RepeatedFrames
  36. title={tn('Frame repeated %s time', 'Frame repeated %s times', timesRepeated)}
  37. >
  38. <RepeatedContent>
  39. <StyledIconRefresh />
  40. <span>{timesRepeated}</span>
  41. </RepeatedContent>
  42. </RepeatedFrames>
  43. );
  44. }
  45. return null;
  46. }
  47. return (
  48. <Wrapper className="title" onMouseDown={onMouseDown} onClick={onClick}>
  49. <VertCenterWrapper>
  50. <Title>
  51. <LeadHint
  52. isExpanded={isExpanded}
  53. nextFrame={nextFrame}
  54. leadsToApp={leadsToApp}
  55. />
  56. <DefaultTitle
  57. frame={frame}
  58. platform={platform}
  59. isHoverPreviewed={isHoverPreviewed}
  60. isUsedForGrouping={isUsedForGrouping}
  61. />
  62. </Title>
  63. {renderRepeats()}
  64. </VertCenterWrapper>
  65. <Expander
  66. isExpanded={isExpanded}
  67. isHoverPreviewed={isHoverPreviewed}
  68. platform={platform}
  69. {...props}
  70. />
  71. </Wrapper>
  72. );
  73. }
  74. export default Default;
  75. const VertCenterWrapper = styled('div')`
  76. display: flex;
  77. align-items: center;
  78. `;
  79. const Title = styled('div')`
  80. > * {
  81. vertical-align: middle;
  82. line-height: 1;
  83. }
  84. `;
  85. const RepeatedContent = styled(VertCenterWrapper)`
  86. justify-content: center;
  87. `;
  88. const RepeatedFrames = styled('div')`
  89. display: inline-block;
  90. border-radius: 50px;
  91. padding: 1px 3px;
  92. margin-left: ${space(1)};
  93. border-width: thin;
  94. border-style: solid;
  95. border-color: ${p => p.theme.pink200};
  96. color: ${p => p.theme.pink300};
  97. background-color: ${p => p.theme.backgroundSecondary};
  98. white-space: nowrap;
  99. `;
  100. const StyledIconRefresh = styled(IconRefresh)`
  101. margin-right: ${space(0.25)};
  102. `;