diff --git a/static/app/components/replays/breadcrumbs/replayTimeline.tsx b/static/app/components/replays/breadcrumbs/replayTimeline.tsx index b6d464a6c31cb7..76ffbd737c5d21 100644 --- a/static/app/components/replays/breadcrumbs/replayTimeline.tsx +++ b/static/app/components/replays/breadcrumbs/replayTimeline.tsx @@ -15,10 +15,12 @@ import {useTimelineScrubberMouseTracking} from 'sentry/components/replays/player import {useReplayContext} from 'sentry/components/replays/replayContext'; import divide from 'sentry/utils/number/divide'; import toPercent from 'sentry/utils/number/toPercent'; +import useTimelineScale from 'sentry/utils/replays/hooks/useTimelineScale'; import {useDimensions} from 'sentry/utils/useDimensions'; export default function ReplayTimeline() { - const {replay, currentTime, timelineScale} = useReplayContext(); + const {replay, currentTime} = useReplayContext(); + const [timelineScale] = useTimelineScale(); const panelRef = useRef(null); const mouseTrackingProps = useTimelineScrubberMouseTracking( diff --git a/static/app/components/replays/player/scrubber.tsx b/static/app/components/replays/player/scrubber.tsx index d08347b1beee61..d0b2b01ce2c958 100644 --- a/static/app/components/replays/player/scrubber.tsx +++ b/static/app/components/replays/player/scrubber.tsx @@ -11,6 +11,7 @@ import {space} from 'sentry/styles/space'; import formatReplayDuration from 'sentry/utils/duration/formatReplayDuration'; import divide from 'sentry/utils/number/divide'; import toPercent from 'sentry/utils/number/toPercent'; +import useTimelineScale from 'sentry/utils/replays/hooks/useTimelineScale'; type Props = { className?: string; @@ -18,8 +19,8 @@ type Props = { }; function Scrubber({className, showZoomIndicators = false}: Props) { - const {replay, currentHoverTime, currentTime, setCurrentTime, timelineScale} = - useReplayContext(); + const {replay, currentHoverTime, currentTime, setCurrentTime} = useReplayContext(); + const [timelineScale] = useTimelineScale(); const durationMs = replay?.getDurationMs() ?? 0; const percentComplete = divide(currentTime, durationMs); @@ -44,15 +45,15 @@ function Scrubber({className, showZoomIndicators = false}: Props) { {showZoomIndicators ? ( - + + - ) : null} @@ -140,8 +141,9 @@ const ZoomIndicatorContainer = styled('div')` display: flex; flex-direction: column; align-items: center; - gap: ${space(0.5)}; + gap: ${space(0.75)}; translate: -6px; + top: -12px; `; const ZoomIndicator = styled('div')` @@ -158,14 +160,6 @@ const ZoomTriangleDown = styled('div')` border-top: 4px solid ${p => p.theme.gray500}; `; -const ZoomTriangleUp = styled('div')` - width: 0; - height: 0; - border-left: 4px solid transparent; - border-right: 4px solid transparent; - border-bottom: 4px solid ${p => p.theme.gray500}; -`; - export const TimelineScrubber = styled(Scrubber)` height: 100%; diff --git a/static/app/components/replays/replayContext.tsx b/static/app/components/replays/replayContext.tsx index a74c882e17e0de..e87c5c54bfcff2 100644 --- a/static/app/components/replays/replayContext.tsx +++ b/static/app/components/replays/replayContext.tsx @@ -138,21 +138,11 @@ interface ReplayPlayerContextProps extends HighlightCallbacks { */ setSpeed: (speed: number) => void; - /** - * Set the timeline width to the specific scale, starting at 1x and growing larger - */ - setTimelineScale: (size: number) => void; - /** * The speed for normal playback */ speed: number; - /** - * Scale of the timeline width, starts from 1x and increases by 1x - */ - timelineScale: number; - /** * Start or stop playback * @@ -189,9 +179,7 @@ const ReplayPlayerContext = createContext({ setCurrentTime: () => {}, setRoot: () => {}, setSpeed: () => {}, - setTimelineScale: () => {}, speed: 1, - timelineScale: 1, togglePlayPause: () => {}, toggleSkipInactive: () => {}, }); @@ -275,7 +263,6 @@ export function Provider({ const [isVideoBuffering, setVideoBuffering] = useState(false); const playTimer = useRef(undefined); const didApplyInitialOffset = useRef(false); - const [timelineScale, setTimelineScale] = useState(1); const [rootEl, setRoot] = useState(null); const durationMs = replay?.getDurationMs() ?? 0; @@ -721,9 +708,7 @@ export function Provider({ setCurrentHoverTime, setCurrentTime, setSpeed, - setTimelineScale, speed, - timelineScale, togglePlayPause, toggleSkipInactive, ...value, diff --git a/static/app/components/replays/timeAndScrubberGrid.tsx b/static/app/components/replays/timeAndScrubberGrid.tsx index dbf30feda23f71..42daa42676d769 100644 --- a/static/app/components/replays/timeAndScrubberGrid.tsx +++ b/static/app/components/replays/timeAndScrubberGrid.tsx @@ -11,6 +11,9 @@ import {IconAdd, IconSubtract} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import formatReplayDuration from 'sentry/utils/duration/formatReplayDuration'; +import useTimelineScale, { + TimelineScaleContextProvider, +} from 'sentry/utils/replays/hooks/useTimelineScale'; type TimeAndScrubberGridProps = { isCompact?: boolean; @@ -18,12 +21,13 @@ type TimeAndScrubberGridProps = { }; function TimelineSizeBar() { - const {replay, timelineScale, setTimelineScale} = useReplayContext(); + const {replay} = useReplayContext(); + const [timelineScale, setTimelineScale] = useTimelineScale(); const durationMs = replay?.getDurationMs(); const maxScale = durationMs ? Math.ceil(durationMs / 60000) : 10; return ( - +