spanBarCursorGuide.tsx 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import styled from '@emotion/styled';
  2. import {toPercent} from 'sentry/components/performance/waterfall/utils';
  3. import * as CursorGuideHandler from './cursorGuideHandler';
  4. function SpanBarCursorGuide() {
  5. return (
  6. <CursorGuideHandler.Consumer>
  7. {({
  8. showCursorGuide,
  9. traceViewMouseLeft,
  10. }: {
  11. showCursorGuide: boolean;
  12. traceViewMouseLeft: number | undefined;
  13. }) => {
  14. if (!showCursorGuide || !traceViewMouseLeft) {
  15. return null;
  16. }
  17. return (
  18. <CursorGuide
  19. style={{
  20. left: toPercent(traceViewMouseLeft),
  21. }}
  22. />
  23. );
  24. }}
  25. </CursorGuideHandler.Consumer>
  26. );
  27. }
  28. const CursorGuide = styled('div')`
  29. position: absolute;
  30. top: 0;
  31. width: 1px;
  32. background-color: ${p => p.theme.red300};
  33. transform: translateX(-50%);
  34. height: 100%;
  35. `;
  36. export default SpanBarCursorGuide;