feat(packages): add time display toggle#1669
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📦 Bundle Size Report🎨 @videojs/html
Presets (7)
Media (9)
Players (5)
Skins (30)
UI Components (36)
Sizes are marginal over the root entry point. ⚛️ @videojs/react — no changesPresets (7)
Media (8)
Skins (27)
UI Components (30)
Sizes are marginal over the root entry point. 🧩 @videojs/core — no changesEntries (10)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (10)
📦 @videojs/spf — no changesEntries (4)
ℹ️ How to interpretAll sizes are standalone totals (minified + brotli).
Run |
| const TOGGLE_LABELS: Partial<Record<TimeType, string>> = { | ||
| current: 'Current time, press to show remaining time', | ||
| remaining: 'Remaining time, press to show current time', | ||
| }; |
There was a problem hiding this comment.
Will need to update i18n PRs when this is merged.
| /** Custom label for accessibility. */ | ||
| label?: string | ((state: TimeState) => string) | undefined; | ||
| /** Whether current and remaining time can be toggled. */ | ||
| toggle?: boolean | undefined; |
There was a problem hiding this comment.
Happy to rename this prop but ideally I'd like to keep it a single word if possible since longer feels weird to me. Other possible options I thought of:
interactivealthough it's a bit broadtoggleablenot a real word- ?
| <div class="${time.controls}"> | ||
| <media-time-group class="${time.group}"> | ||
| <media-time type="current" class="${time.current}"></media-time> | ||
| <media-time toggle type="current" class="${time.current}"></media-time> |
There was a problem hiding this comment.
I only added it to the minimal skin as the default skin felt a bit better with the remaining in place of the duration. We'll revisit this before GA though I guess as we may want to make minimal a bit more minimal in terms of UI. I'm just waiting for the menus stuff to merge so we're reasonably feature stable for the skins.
7e84c02 to
30ff9cc
Compare
30ff9cc to
fdcbd0a
Compare
fdcbd0a to
77ee050
Compare
77ee050 to
4040e28
Compare
4040e28 to
205a982
Compare
205a982 to
436267d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 436267d. Configure here.
436267d to
255dbe0
Compare

Summary
Slightly different to the issue in that:
type="duration" toggleswitches duration ↔ remaining.type="remaining" togglestill switches remaining ↔ duration.type="current" togglestill switches current ↔ remaining.Why? I noticed Apple Music toggles between duration and remaining and that pattern also worked well with the default skin. Minimal's time layout suited the standard toggle between current and remaining. Happy to run through it on a call if need be.
Validation
Closes #1422
Note
Medium Risk
Changes default and minimal player chrome (trailing time is now remaining-with-toggle) and introduces interactive button semantics on time elements; behavior is covered by tests and remains opt-in for custom UIs.
Overview
Adds an opt-in
toggleprop/attribute on time displays so users can switch between paired modes: current ↔ remaining whentype="current", or remaining ↔ duration whentypeisremainingorduration.TimeCoregainstoggle(defaultfalse), toggle-specificaria-labelstrings, and when enabled exposesrole="button"andtabIndex={0}.media-time/Time.Valuetrack a local display type, handle click plus Enter/Space (with repeat anddefaultPreventedguards), reset whentype/togglechange, and strip ARIA when media state is missing.Built-in minimal skins turn
toggleon for the current-time control; default skins keep separate current and slider labels but replace the trailing clock withtoggle type="remaining"(was static duration). Skin CSS adds pointer/focus styles for[role="button"]time elements. Docs and core/React/HTML tests cover the new behavior.Reviewed by Cursor Bugbot for commit 255dbe0. Bugbot is set up for automated code reviews on this repo. Configure here.