groupingComponent.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import styled from '@emotion/styled';
  2. import space from 'sentry/styles/space';
  3. import {EventGroupComponent} from 'sentry/types';
  4. import GroupingComponentChildren from './groupingComponentChildren';
  5. import GroupingComponentStacktrace from './groupingComponentStacktrace';
  6. import {shouldInlineComponentValue} from './utils';
  7. type Props = {
  8. component: EventGroupComponent;
  9. showNonContributing: boolean;
  10. };
  11. const GroupingComponent = ({component, showNonContributing}: Props) => {
  12. const shouldInlineValue = shouldInlineComponentValue(component);
  13. const GroupingComponentListItems =
  14. component.id === 'stacktrace'
  15. ? GroupingComponentStacktrace
  16. : GroupingComponentChildren;
  17. return (
  18. <GroupingComponentWrapper isContributing={component.contributes}>
  19. <span>
  20. {component.name || component.id}
  21. {component.hint && <GroupingHint>{` (${component.hint})`}</GroupingHint>}
  22. </span>
  23. <GroupingComponentList isInline={shouldInlineValue}>
  24. <GroupingComponentListItems
  25. component={component}
  26. showNonContributing={showNonContributing}
  27. />
  28. </GroupingComponentList>
  29. </GroupingComponentWrapper>
  30. );
  31. };
  32. const GroupingComponentList = styled('ul')<{isInline: boolean}>`
  33. padding: 0;
  34. margin: 0;
  35. list-style: none;
  36. &,
  37. & > li {
  38. display: ${p => (p.isInline ? 'inline' : 'block')};
  39. }
  40. `;
  41. export const GroupingComponentListItem = styled('li')<{isCollapsible?: boolean}>`
  42. padding: 0;
  43. margin: ${space(0.25)} 0 ${space(0.25)} ${space(1.5)};
  44. ${p =>
  45. p.isCollapsible &&
  46. `
  47. border-left: 1px solid ${p.theme.innerBorder};
  48. margin: 0 0 -${space(0.25)} ${space(1)};
  49. padding-left: ${space(0.5)};
  50. `}
  51. `;
  52. export const GroupingValue = styled('code')<{valueType: string}>`
  53. display: inline-block;
  54. margin: ${space(0.25)} ${space(0.5)} ${space(0.25)} 0;
  55. font-size: ${p => p.theme.fontSizeSmall};
  56. padding: 0 ${space(0.25)};
  57. background: rgba(112, 163, 214, 0.1);
  58. color: ${p => p.theme.textColor};
  59. ${({valueType}) =>
  60. (valueType === 'function' || valueType === 'symbol') &&
  61. `
  62. font-weight: bold;
  63. color: ${p => p.theme.textColor};
  64. `}
  65. `;
  66. const GroupingComponentWrapper = styled('div')<{isContributing: boolean}>`
  67. color: ${p => (p.isContributing ? null : p.theme.textColor)};
  68. ${GroupingValue}, button {
  69. opacity: 1;
  70. }
  71. `;
  72. const GroupingHint = styled('small')`
  73. font-size: 0.8em;
  74. `;
  75. export default GroupingComponent;