breadcrumbRow.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {CSSProperties, MouseEvent} from 'react';
  2. import styled from '@emotion/styled';
  3. import classNames from 'classnames';
  4. import BreadcrumbItem from 'sentry/components/replays/breadcrumbs/breadcrumbItem';
  5. import {useReplayContext} from 'sentry/components/replays/replayContext';
  6. import useCrumbHandlers from 'sentry/utils/replays/hooks/useCrumbHandlers';
  7. import type {ReplayFrame} from 'sentry/utils/replays/types';
  8. interface Props {
  9. frame: ReplayFrame;
  10. index: number;
  11. onClick: ReturnType<typeof useCrumbHandlers>['onClickTimestamp'];
  12. onDimensionChange: (
  13. index: number,
  14. path: string,
  15. expandedState: Record<string, boolean>,
  16. event: MouseEvent<HTMLDivElement>
  17. ) => void;
  18. startTimestampMs: number;
  19. style: CSSProperties;
  20. breadcrumbIndex?: number[][];
  21. expandPaths?: string[];
  22. }
  23. function BreadcrumbRow({
  24. expandPaths,
  25. frame,
  26. index,
  27. onClick,
  28. onDimensionChange,
  29. startTimestampMs,
  30. style,
  31. }: Props) {
  32. const {currentTime, currentHoverTime} = useReplayContext();
  33. const {onMouseEnter, onMouseLeave} = useCrumbHandlers();
  34. const hasOccurred = currentTime >= frame.offsetMs;
  35. const isBeforeHover =
  36. currentHoverTime === undefined || currentHoverTime >= frame.offsetMs;
  37. return (
  38. <StyledTimeBorder
  39. className={classNames({
  40. beforeCurrentTime: hasOccurred,
  41. afterCurrentTime: !hasOccurred,
  42. beforeHoverTime: currentHoverTime !== undefined ? isBeforeHover : undefined,
  43. afterHoverTime: currentHoverTime !== undefined ? !isBeforeHover : undefined,
  44. })}
  45. style={style}
  46. >
  47. <BreadcrumbItem
  48. index={index}
  49. frame={frame}
  50. onClick={onClick}
  51. onMouseEnter={onMouseEnter}
  52. onMouseLeave={onMouseLeave}
  53. startTimestampMs={startTimestampMs}
  54. expandPaths={expandPaths}
  55. onDimensionChange={onDimensionChange}
  56. />
  57. </StyledTimeBorder>
  58. );
  59. }
  60. const StyledTimeBorder = styled('div')`
  61. /* Overridden in TabItemContainer, depending on *CurrentTime and *HoverTime classes */
  62. border-top: 1px solid transparent;
  63. border-bottom: 1px solid transparent;
  64. `;
  65. export default BreadcrumbRow;