Skip to content

feat: add a solution for React preview time display#50

Merged
luwes merged 2 commits intomainfrom
preview-time
Oct 13, 2025
Merged

feat: add a solution for React preview time display#50
luwes merged 2 commits intomainfrom
preview-time

Conversation

@luwes
Copy link
Copy Markdown
Collaborator

@luwes luwes commented Oct 10, 2025

demo: https://vjs-10-demo-react-git-preview-time-mux.vercel.app/?skin=default

There's many ways to go about this. I didn't like the idea of coupling the preview time or any preview feature too closely to the time slider. Made it possible to use this with a regular Tooltip component with an added option trackCursorAxis.

          <Tooltip.Root trackCursorAxis="x">
            <Tooltip.Trigger>
              <TimeSlider.Root className={styles.SliderRoot}>
                <TimeSlider.Track className={styles.SliderTrack}>
                  <TimeSlider.Progress className={styles.SliderProgress} />
                  <TimeSlider.Pointer className={styles.SliderPointer} />
                </TimeSlider.Track>
                <TimeSlider.Thumb className={styles.SliderThumb} />
              </TimeSlider.Root>
            </Tooltip.Trigger>
            <Tooltip.Portal>
              <Tooltip.Positioner side="top" sideOffset={18} collisionPadding={12}>
                <Tooltip.Popup className={`${styles.TooltipPopup}`}>
                  <PreviewTimeDisplay />
                </Tooltip.Popup>
              </Tooltip.Positioner>
            </Tooltip.Portal>
          </Tooltip.Root>

This pull request introduces support for previewing the time when hovering or interacting with the time slider, enabling features like displaying a tooltip with the previewed time. The main changes include expanding the state and actions for the time slider, adding a new preview time display component, and updating the media store and tooltip logic to support these features.

Time Slider Preview Functionality:

  • Added a previewTime state and requestPreview method to the TimeSliderState and connected them to pointer movement in the TimeSlider component, enabling tracking of the time under the pointer for preview purposes. [1] [2] [3]
  • Updated the media store's state mediator, factory, and initialization logic to support the new previewTime property, including a new preview state mediator and associated action handling. [1] [2] [3] [4] [5] [6] [7]

Preview Time Display Component:

  • Introduced a new state definition for preview time display and exported it from the media store, allowing UI components to consume and display the previewed time. [1] [2]
  • Added a new PreviewTimeDisplay React component, including its state hook and rendering logic, to display the formatted preview time in the UI.

Tooltip Enhancements:

  • Enhanced the tooltip system to support tracking the cursor axis (x, y, or both) for scenarios like time slider tooltips, including new props and integration with the floating UI logic. [1] [2] [3] [4] [5] [6] [7]

React Component Improvements:

  • Improved TimeSlider and related components to better support refs and composed refs, and made minor type improvements for props and state. [1] [2] [3] [4]
  • Cleaned up and clarified types in CurrentTimeDisplay for consistency. [1] [2] [3]

These changes collectively enable a richer, more interactive time slider experience, supporting features like preview tooltips and improved accessibility.

References: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27]

@luwes luwes requested a review from Copilot October 10, 2025 22:12
@luwes luwes self-assigned this Oct 10, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vjs-10-demo-html Error Error Oct 13, 2025 5:46pm
vjs-10-demo-react Error Error Oct 13, 2025 5:46pm
vjs-10-website Ready Ready Preview Comment Oct 13, 2025 5:46pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds time preview functionality to the TimeSlider component, allowing users to preview the time at the cursor position when hovering over the slider. This feature is implemented with a new PreviewTimeDisplay component and enhanced Tooltip system that can track cursor position.

  • Added preview time state management to media store with new preview mediator
  • Created PreviewTimeDisplay component for showing previewed time in tooltips
  • Enhanced Tooltip component with cursor tracking capabilities

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react/react/src/utils/component-factory.tsx Improved ref handling and component type definitions
packages/react/react/src/skins/default/styles.ts Added background color to SliderPointer for visual consistency
packages/react/react/src/skins/default/MediaSkinDefault.tsx Integrated preview tooltip with TimeSlider component
packages/react/react/src/index.ts Added PreviewTimeDisplay to public exports
packages/react/react/src/components/Tooltip.tsx Added cursor tracking functionality for tooltips
packages/react/react/src/components/TimeSlider.tsx Enhanced with ref composition and prop types
packages/react/react/src/components/PreviewTimeDisplay.tsx New component for displaying preview time
packages/react/react/src/components/CurrentTimeDisplay.tsx Cleaned up type definitions for consistency
packages/core/media-store/src/state-mediators/preview.ts New preview state mediator for handling preview time
packages/core/media-store/src/state-mediators/index.ts Added preview mediator to exports
packages/core/media-store/src/media-store.ts Integrated preview mediator into default store
packages/core/media-store/src/index.ts Added preview time display to exports
packages/core/media-store/src/factory.ts Enhanced factory to support preview state and action handling
packages/core/media-store/src/component-state-definitions/time-slider.ts Added preview time state and request method
packages/core/media-store/src/component-state-definitions/preview-time-display.ts New state definition for preview time display
packages/core/core/src/components/time-slider.ts Added preview time dispatching on pointer movement

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/react/react/src/components/Tooltip.tsx
Comment thread packages/core/media-store/src/factory.ts
Comment thread packages/react/react/src/components/PreviewTimeDisplay.tsx
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-react October 13, 2025 17:46 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-html October 13, 2025 17:46 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-website October 13, 2025 17:46 Inactive
@luwes luwes merged commit f78b09f into main Oct 13, 2025
2 of 4 checks passed
@luwes luwes deleted the preview-time branch October 13, 2025 18:07
@github-actions github-actions bot mentioned this pull request Oct 24, 2025
@github-actions github-actions bot mentioned this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants