treeConnector.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import styled from '@emotion/styled';
  2. import {ROW_HEIGHT} from 'sentry/components/performance/waterfall/constants';
  3. import {getToggleTheme} from 'sentry/components/performance/waterfall/utils';
  4. import {IconChevron} from 'sentry/icons';
  5. import space from 'sentry/styles/space';
  6. const TOGGLE_BUTTON_MARGIN_RIGHT = 16;
  7. export const TOGGLE_BUTTON_MAX_WIDTH = 30;
  8. export const TOGGLE_BORDER_BOX = TOGGLE_BUTTON_MAX_WIDTH + TOGGLE_BUTTON_MARGIN_RIGHT;
  9. const TREE_TOGGLE_CONTAINER_WIDTH = 40;
  10. export const ConnectorBar = styled('div')<{orphanBranch: boolean}>`
  11. height: 250%;
  12. border-left: 2px ${p => (p.orphanBranch ? 'dashed' : 'solid')} ${p => p.theme.border};
  13. position: absolute;
  14. top: 0;
  15. `;
  16. type TogglerTypes = {
  17. hasToggler?: boolean;
  18. isLast?: boolean;
  19. };
  20. export const TreeConnector = styled('div')<TogglerTypes & {orphanBranch: boolean}>`
  21. height: ${p => (p.isLast ? ROW_HEIGHT / 2 + 1 : ROW_HEIGHT)}px;
  22. width: 100%;
  23. border-left: ${p => `2px ${p.orphanBranch ? 'dashed' : 'solid'} ${p.theme.border};`};
  24. position: absolute;
  25. top: 0;
  26. ${p =>
  27. p.isLast
  28. ? `
  29. border-bottom: 2px ${p.orphanBranch ? 'dashed' : 'solid'} ${p.theme.border};
  30. border-bottom-left-radius: ${p.theme.borderRadius};`
  31. : `
  32. &:before {
  33. content: '';
  34. height: 2px;
  35. left: -2px;
  36. border-bottom: 2px ${p.orphanBranch ? 'dashed' : 'solid'} ${p.theme.border};
  37. width: calc(100% - 2px);
  38. position: absolute;
  39. bottom: calc(50% - 1px);
  40. }`}
  41. &:after {
  42. content: '';
  43. background-color: ${p => p.theme.border};
  44. border-radius: 50%;
  45. height: 6px;
  46. width: 6px;
  47. position: absolute;
  48. right: 0;
  49. top: ${ROW_HEIGHT / 2 - 3}px;
  50. }
  51. `;
  52. type SpanTreeTogglerAndDivProps = {
  53. disabled: boolean;
  54. errored: boolean;
  55. isExpanded: boolean;
  56. isSpanGroupToggler?: boolean;
  57. };
  58. export const TreeToggle = styled('div')<SpanTreeTogglerAndDivProps>`
  59. height: 16px;
  60. white-space: nowrap;
  61. min-width: 30px;
  62. display: flex;
  63. align-items: center;
  64. justify-content: center;
  65. border-radius: 99px;
  66. padding: 0px ${space(0.5)};
  67. transition: all 0.15s ease-in-out;
  68. font-size: 10px;
  69. line-height: 0;
  70. z-index: 1;
  71. box-shadow: ${p => p.theme.dropShadowLightest};
  72. ${p => getToggleTheme(p)}
  73. `;
  74. export const TreeToggleContainer = styled('div')<TogglerTypes>`
  75. position: relative;
  76. height: ${ROW_HEIGHT}px;
  77. width: ${TREE_TOGGLE_CONTAINER_WIDTH}px;
  78. min-width: ${TREE_TOGGLE_CONTAINER_WIDTH}px;
  79. margin-right: ${space(1)};
  80. z-index: ${p => p.theme.zIndex.traceView.spanTreeToggler};
  81. display: flex;
  82. justify-content: flex-end;
  83. align-items: center;
  84. `;
  85. export const TreeToggleIcon = styled(IconChevron)`
  86. width: 7px;
  87. margin-left: ${space(0.25)};
  88. `;