Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Video player UI improvements

Blue Mouse9a24b47c11f3
diff --git a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
index e8f77deff..fee54b001 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
@@ -5,12 +5,15 @@ import {
DialogTitle,
} from '@headlessui/react'
import {
- ArrowsInIcon,
- ArrowsOutIcon,
CameraIcon,
- CaretDownIcon,
+ CaretLeftIcon,
CaretRightIcon,
+ CheckIcon,
+ CornersInIcon,
+ CornersOutIcon,
CursorClickIcon,
+ GaugeIcon,
+ GearSixIcon,
ListBulletsIcon,
PauseIcon,
PlayIcon,
@@ -23,6 +26,7 @@ import {
type ComponentPropsWithoutRef,
type CSSProperties,
type ElementType,
+ type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
useCallback,
useEffect,
@@ -41,7 +45,6 @@ import type {
SessionReplayResponse,
} from '~/api/api.server'
import { useSessionReplayProxy } from '~/hooks/useAnalyticsProxy'
-import { Badge } from '~/ui/Badge'
import Button from '~/ui/Button'
import Loader from '~/ui/Loader'
import { Text } from '~/ui/Text'
@@ -354,9 +357,7 @@ const buildReplayViewportChanges = (
})
})
- return changes.length
- ? changes
- : [{ ...DEFAULT_REPLAY_VIEWPORT, offset: 0 }]
+ return changes.length ? changes : [{ ...DEFAULT_REPLAY_VIEWPORT, offset: 0 }]
}
const getReplayViewportAt = (
@@ -495,13 +496,34 @@ const PlayerIconButton = ({
<Button
{...props}
variant='icon'
+ focus={false}
className={cn(
- 'border-white/0 text-slate-100 hover:border-white/20 hover:bg-white/10 focus-visible:ring-slate-100 focus-visible:ring-offset-slate-950 dark:text-slate-100 dark:hover:border-white/20 dark:hover:bg-white/10 dark:focus-visible:ring-slate-100',
+ 'rounded-full border-white/0 p-2.5 text-slate-100 hover:border-white/0 hover:bg-white/15 focus-visible:ring-2 focus-visible:ring-white/70 focus-visible:ring-offset-0 dark:text-slate-100 dark:hover:border-white/0 dark:hover:bg-white/15',
className,
)}
/>
)
+const SettingsToggle = ({ on }: { on: boolean }) => (
+ <span
+ aria-hidden
+ className={cn(
+ 'relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors duration-150 ease-out',
+ on ? 'bg-red-600' : 'bg-white/25',
+ )}
+ >
+ <span
+ className={cn(
+ 'inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow-sm transition-transform duration-150 ease-out',
+ on ? 'translate-x-[18px]' : 'translate-x-[3px]',
+ )}
+ />
+ </span>
+)
+
+const SETTINGS_ROW_CLASS =
+ 'flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm text-slate-100 transition-colors duration-150 ease-out hover:bg-white/10 focus-visible:bg-white/10 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent'
+
export const SessionReplayModal = ({
isOpen,
onClose,
@@ -523,12 +545,19 @@ export const SessionReplayModal = ({
const [hoverPreview, setHoverPreview] = useState<HoverPreview | null>(null)
const [isPlayerHovered, setIsPlayerHovered] = useState(false)
const [isControlsFocused, setIsControlsFocused] = useState(false)
+ const [settingsOpen, setSettingsOpen] = useState(false)
+ const [settingsView, setSettingsView] = useState<'main' | 'speed'>('main')
+ const [bezel, setBezel] = useState<{
+ kind: 'play' | 'pause'
+ key: number
+ } | null>(null)
const [playerSize, setPlayerSize] = useState<PlayerSize>({
width: 0,
height: 0,
})
const playerRoot = useRef<HTMLDivElement | null>(null)
const previewRoot = useRef<HTMLDivElement | null>(null)
+ const settingsRef = useRef<HTMLDivElement | null>(null)
const fullscreenRoot = useRef<HTMLDivElement | null>(null)
const replayer = useRef<Replayer | null>(null)
const previewReplayer = useRef<Replayer | null>(null)
@@ -557,10 +586,7 @@ export const SessionReplayModal = ({
)
const previewReplayViewport = useMemo(
() =>
- getReplayViewportAt(
- viewportChanges,
- hoverPreview?.offset ?? currentTime,
- ),
+ getReplayViewportAt(viewportChanges, hoverPreview?.offset ?? currentTime),
[currentTime, hoverPreview?.offset, viewportChanges],
)
const playerScale = getContainScale(
@@ -589,7 +615,9 @@ export const SessionReplayModal = ({
'--replay-preview-scale': previewScale,
} as CSSProperties
const progressPercent =
- duration > 0 ? Math.min(100, Math.max(0, (currentTime / duration) * 100)) : 0
+ duration > 0
+ ? Math.min(100, Math.max(0, (currentTime / duration) * 100))
+ : 0
const activeStep = useMemo(
() => getNearestStep(timelineSteps, currentTime),
[currentTime, timelineSteps],
@@ -598,7 +626,13 @@ export const SessionReplayModal = ({
Boolean(hoverPreview) && hasEvents && !error && duration > 0
const canControlReplay = hasEvents && !error && duration > 0
const shouldShowControls =
- !isPlaying || isPlayerHovered || isControlsFocused || !canControlReplay
+ !isPlaying ||
+ isPlayerHovered ||
+ isControlsFocused ||
+ settingsOpen ||
+ !canControlReplay
+ const speedLabel =
+ speed === 1 ? t('project.sessionReplay.normalSpeed') : `${speed}×`
useEffect(() => {
currentTimeRef.current = currentTime
@@ -787,6 +821,40 @@ export const SessionReplayModal = ({
document.removeEventListener('fullscreenchange', onFullscreenChange)
}, [])
+ useEffect(() => {
+ if (!settingsOpen) {
+ setSettingsView('main')
+ return
+ }
+
+ const onPointerDown = (event: PointerEvent) => {
+ if (
+ settingsRef.current &&
+ !settingsRef.current.contains(event.target as Node | null)
+ ) {
+ setSettingsOpen(false)
+ }
+ }
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key === 'Escape') setSettingsOpen(false)
+ }
+
+ document.addEventListener('pointerdown', onPointerDown, true)
+ document.addEventListener('keydown', onKeyDown)
+ return () => {
+ document.removeEventListener('pointerdown', onPointerDown, true)
+ document.removeEventListener('keydown', onKeyDown)
+ }
+ }, [settingsOpen])
+
+ useEffect(() => {
+ if (!isOpen) setSettingsOpen(false)
+ }, [isOpen])
+
+ const flashBezel = useCallback((kind: 'play' | 'pause') => {
+ setBezel({ kind, key: performance.now() })
+ }, [])
+
const syncPlaybackOffset = useCallback(() => {
if (!isPlaying) return currentTimeRef.current
@@ -818,10 +886,12 @@ export const SessionReplayModal = ({
if (isPlaying) {
pause()
+ flashBezel('pause')
} else {
play()
+ flashBezel('play')
}
- }, [canControlReplay, isPlaying, pause, play])
+ }, [canControlReplay, isPlaying, pause, play, flashBezel])
const seekTo = useCallback(
(offset: number, shouldPlay = isPlaying) => {
@@ -850,6 +920,45 @@ export const SessionReplayModal = ({
[duration, isPlaying, speed],
)
+ const handlePlayerClick = useCallback(
+ (event: ReactMouseEvent<HTMLDivElement>) => {
+ if (!canControlReplay) return
+ // Clicks on the controls bar / settings menu drive their own actions.
+ if ((event.target as HTMLElement).closest('[data-replay-controls]')) {
+ return
+ }
+ // First click outside an open settings menu only dismisses it.
+ if (settingsOpen) {
+ setSettingsOpen(false)
+ return
+ }
+ togglePlayback()
+ },
+ [canControlReplay, settingsOpen, togglePlayback],
+ )
+
+ const handlePlayerKeyDown = useCallback(
+ (event: ReactKeyboardEvent<HTMLDivElement>) => {
+ if (!canControlReplay) return
+ // Let focused controls (scrubber, buttons, menu) handle their own keys.
+ if ((event.target as HTMLElement).closest('[data-replay-controls]')) {
+ return
+ }
+
+ if (event.key === ' ' || event.key === 'k') {
+ event.preventDefault()
+ togglePlayback()
+ } else if (event.key === 'ArrowLeft' || event.key === 'j') {
+ event.preventDefault()
+ seekTo(Math.max(0, syncPlaybackOffset() - 5000))
+ } else if (event.key === 'ArrowRight' || event.key === 'l') {
+ event.preventDefault()
+ seekTo(Math.min(duration, syncPlaybackOffset() + 5000))
+ }
+ },
+ [canControlReplay, duration, seekTo, syncPlaybackOffset, togglePlayback],
+ )
+
const updateHoverPreview = useCallback(
(event: ReactMouseEvent<HTMLDivElement>) => {
if (!hasEvents || error || duration <= 0) {
@@ -1024,31 +1133,6 @@ export const SessionReplayModal = ({
</div>
</div>
<div className='flex shrink-0 items-center gap-2'>
- <Button
- variant='secondary'
- size='sm'
- aria-expanded={showTimeline}
- onClick={() => setShowTimeline((value) => !value)}
- className='hidden items-center gap-2 sm:inline-flex'
- >
- <ListBulletsIcon className='size-4' aria-hidden />
- <Text as='span' size='sm' weight='medium' colour='inherit'>
- {t('project.sessionReplay.timeline.title')}
- </Text>
- <Badge
- colour='slate'
- size='sm'
- label={timelineSteps.length.toLocaleString()}
- className='ml-0.5'
- />
- <CaretDownIcon
- className={cn(
- 'size-3.5 transition-transform duration-150 ease-out motion-reduce:transition-none',
- showTimeline && 'rotate-180',
- )}
- aria-hidden
- />
- </Button>
<Button
variant='icon'
aria-label={t('common.close')}
@@ -1061,85 +1145,135 @@ export const SessionReplayModal = ({
<div
className={cn(
- 'grid min-h-0 flex-1 gap-0 bg-gray-50 dark:bg-slate-950',
+ 'grid min-h-0 flex-1 gap-0 bg-black',
showTimeline
- ? 'grid-rows-[minmax(0,1fr)_minmax(220px,34dvh)] xl:grid-cols-[minmax(0,1fr)_340px] xl:grid-rows-1'
+ ? 'grid-rows-[minmax(0,1fr)_minmax(220px,34dvh)] xl:grid-cols-[minmax(0,1fr)_360px] xl:grid-rows-1'
: 'grid-cols-1',
)}
>
- <div className='min-h-0 p-2 sm:p-3 lg:p-4'>
+ <div
+ className='group/player relative min-h-[320px] bg-black focus:outline-none focus-visible:ring-2 focus-visible:ring-white/70 focus-visible:ring-inset'
+ role='application'
+ aria-label={t('project.sessionReplay.title')}
+ tabIndex={canControlReplay ? 0 : -1}
+ onClick={handlePlayerClick}
+ onKeyDown={handlePlayerKeyDown}
+ onMouseEnter={() => setIsPlayerHovered(true)}
+ onMouseLeave={() => {
+ setIsPlayerHovered(false)
+ setHoverPreview(null)
+ }}
+ >
+ {isPreparing || isLoading ? (
+ <div className='absolute inset-0 z-30 flex items-center justify-center bg-black/70'>
+ <Loader />
+ </div>
+ ) : null}
+ {!isPreparing && error ? (
+ <div className='absolute inset-0 z-20 flex items-center justify-center px-6 text-center'>
+ <div className='max-w-md'>
+ <WarningCircleIcon
+ className='mx-auto mb-3 size-8 text-amber-400'
+ weight='duotone'
+ />
+ <Text
+ colour='inherit'
+ weight='semibold'
+ className='text-white'
+ >
+ {t('project.sessionReplay.loadError')}
+ </Text>
+ <Text as='p' size='sm' className='mt-1 text-slate-300'>
+ {error}
+ </Text>
+ </div>
+ </div>
+ ) : null}
+ {!isPreparing && !error && payload && !hasEvents ? (
+ <div className='absolute inset-0 z-20 flex items-center justify-center px-6 text-center'>
+ <Text
+ colour='inherit'
+ weight='semibold'
+ className='text-white'
+ >
+ {t('project.sessionReplay.empty')}
+ </Text>
+ </div>
+ ) : null}
+
<div
- className='relative h-full min-h-[420px] overflow-hidden rounded-lg bg-slate-950 ring-1 ring-slate-900/80 dark:ring-slate-700/70'
- onMouseEnter={() => setIsPlayerHovered(true)}
- onMouseLeave={() => {
- setIsPlayerHovered(false)
- setHoverPreview(null)
- }}
- >
- <div className='relative h-full bg-slate-950'>
- {isPreparing || isLoading ? (
- <div className='absolute inset-0 z-30 flex items-center justify-center bg-slate-950/70'>
- <Loader />
- </div>
- ) : null}
- {!isPreparing && error ? (
- <div className='absolute inset-0 z-20 flex items-center justify-center px-6 text-center'>
- <div className='max-w-md'>
- <WarningCircleIcon
- className='mx-auto mb-3 size-8 text-amber-400'
- weight='duotone'
- />
- <Text
- colour='inherit'
- weight='semibold'
- className='text-white'
- >
- {t('project.sessionReplay.loadError')}
- </Text>
- <Text as='p' size='sm' className='mt-1 text-slate-300'>
- {error}
- </Text>
- </div>
- </div>
- ) : null}
- {!isPreparing && !error && payload && !hasEvents ? (
- <div className='absolute inset-0 z-20 flex items-center justify-center px-6 text-center'>
- <Text
- colour='inherit'
- weight='semibold'
- className='text-white'
- >
- {t('project.sessionReplay.empty')}
- </Text>
- </div>
- ) : null}
- <div
- ref={playerRoot}
- className={cn(
- 'rrweb-player-root h-full w-full',
- (!hasEvents || error) && 'hidden',
+ ref={playerRoot}
+ className={cn(
+ 'rrweb-player-root h-full w-full',
+ (!hasEvents || error) && 'hidden',
+ )}
+ style={playerStyle}
+ />
+
+ {/*
+ * Transparent layer above the replay iframe so player clicks reach
+ * React (an iframe would otherwise swallow them). The toggle itself
+ * is handled by the container's onClick via event bubbling.
+ */}
+ {canControlReplay ? (
+ <div
+ className='absolute inset-0 z-10 cursor-pointer'
+ aria-hidden
+ />
+ ) : null}
+
+ {bezel ? (
+ <div
+ className='pointer-events-none absolute inset-0 z-20 flex items-center justify-center'
+ aria-hidden
+ >
+ <span
+ key={bezel.key}
+ onAnimationEnd={() => setBezel(null)}
+ className='replay-bezel flex size-16 items-center justify-center rounded-full bg-black/60'
+ >
+ {bezel.kind === 'play' ? (
+ <PlayIcon
+ weight='fill'
+ className='size-8 translate-x-0.5 text-white'
+ />
+ ) : (
+ <PauseIcon weight='fill' className='size-8 text-white' />
)}
- style={playerStyle}
- />
- {canControlReplay ? (
- <button
- type='button'
- aria-label={
- isPlaying ? t('common.pause') : t('common.play')
- }
- onClick={togglePlayback}
- className='absolute inset-0 z-10 cursor-pointer bg-transparent focus-visible:ring-2 focus-visible:ring-slate-100 focus-visible:ring-inset focus-visible:outline-none'
+ </span>
+ </div>
+ ) : null}
+
+ {canControlReplay && !isPlaying && !bezel ? (
+ <div
+ className='pointer-events-none absolute inset-0 z-20 flex items-center justify-center'
+ aria-hidden
+ >
+ <span className='flex size-16 items-center justify-center rounded-full bg-black/55 ring-1 ring-white/10 transition-transform duration-150 ease-out group-hover/player:scale-105'>
+ <PlayIcon
+ weight='fill'
+ className='size-8 translate-x-0.5 text-white'
/>
- ) : null}
+ </span>
</div>
+ ) : null}
+ <div
+ className={cn(
+ 'absolute inset-x-0 bottom-0 z-30 transition-opacity duration-200 ease-out motion-reduce:transition-none',
+ shouldShowControls
+ ? 'opacity-100'
+ : 'pointer-events-none opacity-0',
+ )}
+ >
<div
- className={cn(
- 'absolute inset-x-2 bottom-2 z-30 rounded-lg bg-slate-950/80 px-3 py-3 text-slate-100 ring-1 ring-white/10 backdrop-blur-[2px] transition-opacity duration-150 ease-out motion-reduce:transition-none sm:inset-x-3 sm:bottom-3',
- shouldShowControls
- ? 'pointer-events-auto opacity-100'
- : 'pointer-events-none opacity-0',
- )}
+ className='pointer-events-none absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-black/85 via-black/35 to-transparent'
+ aria-hidden
+ />
+
+ <div
+ className='relative'
+ data-replay-controls
onFocusCapture={() => setIsControlsFocused(true)}
onBlurCapture={(event) => {
if (
@@ -1151,80 +1285,76 @@ export const SessionReplayModal = ({
}
}}
>
- <div className='grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2'>
- <Text
- as='span'
- size='xs'
- colour='inherit'
- className='text-slate-300 tabular-nums'
- >
- {formatReplayTime(currentTime)}
- </Text>
+ <div className='px-3 sm:px-4'>
<div
- className='relative h-7'
+ className='group/scrubber relative flex h-4 cursor-pointer items-center'
onMouseMove={updateHoverPreview}
onMouseLeave={() => setHoverPreview(null)}
>
{shouldShowPreview && hoverPreview ? (
<div
- className='pointer-events-none absolute bottom-full z-40 mb-2 w-56 rounded-lg bg-slate-950 p-1.5 ring-1 ring-white/15'
+ className='pointer-events-none absolute bottom-full z-40 mb-3 w-56'
style={{
left: `${hoverPreview.percent * 100}%`,
transform:
- hoverPreview.percent < 0.14
+ hoverPreview.percent < 0.12
? 'translateX(0)'
- : hoverPreview.percent > 0.86
+ : hoverPreview.percent > 0.88
? 'translateX(-100%)'
: 'translateX(-50%)',
}}
>
- <div className='aspect-video overflow-hidden rounded-md bg-white'>
+ <div className='aspect-video overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-white/20'>
<div
ref={previewRoot}
className='rrweb-preview-root h-full w-full'
style={previewStyle}
/>
</div>
- <div className='mt-1.5 flex justify-center px-1'>
- <Text
- as='span'
- size='xs'
- colour='inherit'
- weight='semibold'
- className='text-slate-100 tabular-nums'
- >
+ <div className='mt-1.5 flex justify-center'>
+ <span className='rounded bg-black/85 px-1.5 py-0.5 text-xs font-semibold text-white tabular-nums'>
{formatReplayTime(hoverPreview.offset)}
- </Text>
+ </span>
</div>
</div>
) : null}
- <div className='absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-white/15'>
+
+ <div className='relative h-[3px] w-full rounded-full bg-white/30 transition-[height] duration-100 ease-out group-hover/scrubber:h-[5px]'>
<div
- className='h-full rounded-full bg-slate-100'
+ className='absolute inset-y-0 left-0 rounded-full bg-red-600'
style={{ width: `${progressPercent}%` }}
/>
+ {duration > 0
+ ? timelineSteps.map((step) => {
+ const { markerClass } = getTimelineMeta(step.kind)
+ return (
+ <span
+ key={step.id}
+ className={cn(
+ 'absolute top-1/2 h-2 w-[2px] -translate-x-1/2 -translate-y-1/2 rounded-full opacity-60',
+ markerClass,
+ )}
+ style={{
+ left: `${Math.min(
+ 100,
+ Math.max(
+ 0,
+ (step.offset / duration) * 100,
+ ),
+ )}%`,
+ }}
+ aria-hidden
+ />
+ )
+ })
+ : null}
+ <span
+ className='absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 scale-0 rounded-full bg-red-600 shadow-sm transition-transform duration-100 ease-out group-hover/scrubber:scale-100'
+ style={{ left: `${progressPercent}%` }}
+ aria-hidden
+ />
</div>
- {duration > 0
- ? timelineSteps.map((step) => {
- const { markerClass } = getTimelineMeta(step.kind)
- return (
- <span
- key={step.id}
- className={cn(
- 'absolute top-1/2 h-2 w-px -translate-y-1/2 rounded-full opacity-80',
- markerClass,
- )}
- style={{
- left: `${Math.min(
- 100,
- Math.max(0, (step.offset / duration) * 100),
- )}%`,
- }}
- aria-hidden
- />
- )
- })
- : null}
+
<input
type='range'
aria-label={t('project.sessionReplay.timeline.title')}
@@ -1236,106 +1366,185 @@ export const SessionReplayModal = ({
seekTo(Number(event.currentTarget.value), false)
}
disabled={!canControlReplay}
- className='replay-scrubber absolute inset-0 h-full w-full appearance-none bg-transparent'
+ className='replay-scrubber absolute inset-0 h-full w-full cursor-pointer appearance-none bg-transparent'
/>
</div>
- <Text
- as='span'
- size='xs'
- colour='inherit'
- className='text-slate-300 tabular-nums'
- >
- {formatReplayTime(duration)}
- </Text>
</div>
- <div className='mt-2 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between'>
- <div className='flex min-w-0 items-center gap-1.5'>
+ <div className='flex items-center justify-between gap-2 px-1.5 pt-1 pb-1.5 sm:px-2'>
+ <div className='flex min-w-0 items-center gap-1'>
<Tooltip
asChild
- text={isPlaying ? t('common.pause') : t('common.play')}
+ text={
+ isPlaying
+ ? t('project.sessionReplay.pause')
+ : t('project.sessionReplay.play')
+ }
tooltipNode={
<PlayerIconButton
aria-label={
- isPlaying ? t('common.pause') : t('common.play')
+ isPlaying
+ ? t('project.sessionReplay.pause')
+ : t('project.sessionReplay.play')
}
- onClick={isPlaying ? pause : play}
+ onClick={togglePlayback}
disabled={!canControlReplay}
>
{isPlaying ? (
- <PauseIcon className='size-4' />
+ <PauseIcon weight='fill' className='size-5' />
) : (
- <PlayIcon className='size-4' />
+ <PlayIcon weight='fill' className='size-5' />
)}
</PlayerIconButton>
}
/>
+ <span className='px-1 text-xs text-white/90 tabular-nums sm:text-sm'>
+ {formatReplayTime(currentTime)} /{' '}
+ {formatReplayTime(duration)}
+ </span>
</div>
- <div className='flex flex-wrap items-center gap-1.5 sm:justify-end'>
- <fieldset className='flex rounded-md bg-white/5 p-0.5 ring-1 ring-white/10'>
- <legend className='sr-only'>
- {t('project.sessionReplay.speed')}
- </legend>
- {SPEEDS.map((item) => (
- <button
- key={item}
- type='button'
- onClick={() => setPlaybackSpeed(item)}
- disabled={!canControlReplay}
+ <div className='flex items-center gap-0.5'>
+ <div className='relative' ref={settingsRef}>
+ <PlayerIconButton
+ aria-label={t('project.sessionReplay.settings')}
+ aria-haspopup='menu'
+ aria-expanded={settingsOpen}
+ onClick={() => setSettingsOpen((value) => !value)}
+ className={cn(settingsOpen && 'bg-white/15')}
+ >
+ <GearSixIcon
+ weight='fill'
className={cn(
- 'rounded px-2 py-1 text-xs leading-4 font-medium text-slate-300 transition-colors duration-150 ease-out focus-visible:ring-2 focus-visible:ring-slate-100 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',
- speed === item
- ? 'bg-slate-100 text-slate-950'
- : 'hover:bg-white/10 hover:text-slate-100',
+ 'size-5 transition-transform duration-300 ease-out motion-reduce:transition-none',
+ settingsOpen && 'rotate-[30deg]',
)}
+ />
+ </PlayerIconButton>
+
+ {settingsOpen ? (
+ <div
+ role='menu'
+ className='absolute right-0 bottom-full z-50 mb-3 w-64 overflow-hidden rounded-xl bg-slate-950/95 p-1.5 text-slate-100 shadow-2xl ring-1 ring-white/10 backdrop-blur-md'
>
- <Text
- as='span'
- size='xs'
- weight='medium'
- colour='inherit'
- className='leading-4'
- >
- {item}x
- </Text>
- </button>
- ))}
- </fieldset>
- <Tooltip
- asChild
- text={
- showTimeline
- ? t('project.sessionReplay.hideTimeline')
- : t('project.sessionReplay.showTimeline')
- }
- tooltipNode={
- <PlayerIconButton
- aria-label={
- showTimeline
- ? t('project.sessionReplay.hideTimeline')
- : t('project.sessionReplay.showTimeline')
- }
- aria-expanded={showTimeline}
- onClick={() => setShowTimeline((value) => !value)}
- >
- <ListBulletsIcon className='size-4' />
- </PlayerIconButton>
- }
- />
- <Tooltip
- asChild
- text={t('project.sessionReplay.screenshot')}
- tooltipNode={
- <PlayerIconButton
- aria-label={t('project.sessionReplay.screenshot')}
- onClick={downloadScreenshot}
- disabled={!canControlReplay}
- >
- <CameraIcon className='size-4' />
- </PlayerIconButton>
- }
- />
+ {settingsView === 'main' ? (
+ <div className='flex flex-col'>
+ <button
+ type='button'
+ role='menuitem'
+ onClick={() => setSettingsView('speed')}
+ className={SETTINGS_ROW_CLASS}
+ >
+ <GaugeIcon
+ className='size-5 shrink-0 text-slate-300'
+ aria-hidden
+ />
+ <span className='flex-1'>
+ {t('project.sessionReplay.speed')}
+ </span>
+ <span className='text-slate-400 tabular-nums'>
+ {speedLabel}
+ </span>
+ <CaretRightIcon
+ className='size-4 shrink-0 text-slate-400'
+ aria-hidden
+ />
+ </button>
+
+ <button
+ type='button'
+ role='switch'
+ aria-checked={showTimeline}
+ onClick={() =>
+ setShowTimeline((value) => !value)
+ }
+ className={SETTINGS_ROW_CLASS}
+ >
+ <ListBulletsIcon
+ className='size-5 shrink-0 text-slate-300'
+ aria-hidden
+ />
+ <span className='flex-1'>
+ {t('project.sessionReplay.timeline.title')}
+ </span>
+ <SettingsToggle on={showTimeline} />
+ </button>
+
+ <button
+ type='button'
+ role='menuitem'
+ onClick={() => {
+ setSettingsOpen(false)
+ downloadScreenshot()
+ }}
+ disabled={!canControlReplay}
+ className={SETTINGS_ROW_CLASS}
+ >
+ <CameraIcon
+ className='size-5 shrink-0 text-slate-300'
+ aria-hidden
+ />
+ <span className='flex-1'>
+ {t('project.sessionReplay.screenshot')}
+ </span>
+ </button>
+ </div>
+ ) : (
+ <div className='flex flex-col'>
+ <button
+ type='button'
+ onClick={() => setSettingsView('main')}
+ className='flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm font-semibold text-slate-100 transition-colors duration-150 ease-out hover:bg-white/10 focus-visible:bg-white/10 focus-visible:outline-none'
+ >
+ <CaretLeftIcon
+ className='size-4 shrink-0'
+ aria-hidden
+ />
+ <span>
+ {t('project.sessionReplay.speed')}
+ </span>
+ </button>
+ <div
+ className='mx-2 my-1 h-px bg-white/10'
+ aria-hidden
+ />
+ <div className='flex flex-col'>
+ {SPEEDS.map((item) => (
+ <button
+ key={item}
+ type='button'
+ role='menuitemradio'
+ aria-checked={speed === item}
+ onClick={() => {
+ setPlaybackSpeed(item)
+ setSettingsView('main')
+ }}
+ className='grid grid-cols-[20px_1fr] items-center gap-1 rounded-lg px-3 py-2 text-left text-sm text-slate-100 transition-colors duration-150 ease-out hover:bg-white/10 focus-visible:bg-white/10 focus-visible:outline-none'
+ >
+ {speed === item ? (
+ <CheckIcon
+ className='size-4 text-white'
+ aria-hidden
+ />
+ ) : (
+ <span aria-hidden />
+ )}
+ <span className='tabular-nums'>
+ {item === 1
+ ? t(
+ 'project.sessionReplay.normalSpeed',
+ )
+ : `${item}×`}
+ </span>
+ </button>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ ) : null}
+ </div>
+
<Tooltip
asChild
text={
@@ -1353,9 +1562,9 @@ export const SessionReplayModal = ({
onClick={toggleFullscreen}
>
{isFullscreen ? (
- <ArrowsInIcon className='size-4' />
+ <CornersInIcon className='size-5' />
) : (
- <ArrowsOutIcon className='size-4' />
+ <CornersOutIcon className='size-5' />
)}
</PlayerIconButton>
}
diff --git a/web/app/pages/Project/tabs/Sessions/replayPlayer.css b/web/app/pages/Project/tabs/Sessions/replayPlayer.css
index c1ace10db..02d4be799 100644
--- a/web/app/pages/Project/tabs/Sessions/replayPlayer.css
+++ b/web/app/pages/Project/tabs/Sessions/replayPlayer.css
@@ -54,29 +54,63 @@
.replay-scrubber:focus-visible {
outline: none;
}
+/*
+ * The visible track, fill and handle are drawn with regular DOM nodes (see
+ * SessionReplayModal). This native range input only provides the hit area,
+ * dragging and keyboard support, so its own track and thumb are fully
+ * transparent and stretched to the full grab height.
+ */
.replay-scrubber::-webkit-slider-runnable-track {
- height: 28px;
+ height: 16px;
background: transparent;
}
.replay-scrubber::-webkit-slider-thumb {
- width: 12px;
- height: 12px;
- margin-top: 8px;
+ width: 16px;
+ height: 16px;
+ margin-top: 0;
appearance: none;
- border: 2px solid #0f172a;
+ border: 0;
border-radius: 9999px;
- background: #f8fafc;
+ background: transparent;
}
.replay-scrubber::-moz-range-track {
- height: 28px;
+ height: 16px;
background: transparent;
}
.replay-scrubber::-moz-range-thumb {
- width: 12px;
- height: 12px;
- border: 2px solid #0f172a;
+ width: 16px;
+ height: 16px;
+ border: 0;
border-radius: 9999px;
- background: #f8fafc;
+ background: transparent;
+}
+
+/*
+ * YouTube-style center bezel that flashes the play / pause glyph in the middle
+ * of the player whenever playback is toggled.
+ */
+@keyframes replay-bezel-pop {
+ 0% {
+ opacity: 0;
+ transform: scale(0.6);
+ }
+ 15% {
+ opacity: 0.95;
+ transform: scale(0.85);
+ }
+ 100% {
+ opacity: 0;
+ transform: scale(1.3);
+ }
+}
+.replay-bezel {
+ animation: replay-bezel-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
+}
+@media (prefers-reduced-motion: reduce) {
+ .replay-bezel {
+ animation: none;
+ opacity: 0;
+ }
}
.replayer-mouse {
position: absolute;
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 96431055f..b17579f8a 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1972,7 +1972,11 @@
"empty": "No replay events were found.",
"back10": "Back 10 seconds",
"forward10": "Forward 10 seconds",
+ "play": "Play",
+ "pause": "Pause",
+ "settings": "Settings",
"speed": "Playback speed",
+ "normalSpeed": "Normal",
"screenshot": "Download screenshot",
"screenshotError": "Could not capture this replay frame. Cross-origin media can block screenshots.",
"screenshotDownloaded": "Replay screenshot downloaded",