--- status: draft date: 2025-02-04 --- # Time Display Displays current time, duration, or remaining time. ## Problem Video players need to display time: 1. **Current playback position** — updates continuously 2. **Total duration** — static once source loads 3. **Remaining time** — duration minus current, often with negative sign Requirements: - Digital format: `1:30:45` or `5:30` - Conditional hour display (hide when duration < 1 hour) - Proper accessibility (screen readers need human-readable time, not "1:30") - Composable for common patterns like `1:30 / 5:00` ## Anatomy ### React ```tsx import { Time } from '@videojs/react'; // Standalone // Composed ``` ### HTML ```ts import '@videojs/html/ui/time'; ``` ```html ``` ## Examples ### Current Time Only ```tsx ``` ### Current / Duration ```tsx ``` ### Remaining Time ```tsx // Renders: -4:30 ``` ### Custom Separator ```tsx of // Renders: 1:30 of 5:00 ``` ### Custom Negative Sign ```tsx // Renders: −4:30 (using proper minus sign U+2212) ``` ## Parts ### Group Container for composed time displays. Renders a `` element. **Why a component?** - **Semantic structure** — Clear boundary around related time displays - **Future API surface** — Room to add formatting options (e.g., `hoursDisplay`) that apply to all children - **Styling container** — Provides a target for layout and theming #### Props | Prop | Type | Default | Description | | -------- | ------------------ | ------- | ---------------------- | | `render` | `RenderProp` | — | Custom render element. | #### Data Attributes | Attribute | Description | | --------- | ----------- | | — | None currently. | #### Renders ```html ``` --- ### Value Displays a formatted time value. Works standalone or within Group. #### Props | Prop | Type | Default | Description | | --------------- | ------------------------------------------ | ----------- | ------------------------------ | | `type` | `'current' \| 'duration' \| 'remaining'` | `'current'` | Which time to display. | | `negativeSign` | `string` | `'-'` | Symbol for remaining time. | | `label` | `string` | Auto | Custom aria-label. | | `render` | `RenderProp` | — | Custom render element. | #### State | Property | Type | Description | | ---------- | ---------- | ------------------------------------------------- | | `type` | `TimeType` | `'current'`, `'duration'`, or `'remaining'` | | `seconds` | `number` | Raw value in seconds. | | `text` | `string` | Formatted display text (`1:30`). | | `phrase` | `string` | Human-readable phrase (`1 minute, 30 seconds`). | | `datetime` | `string` | ISO 8601 duration (`PT1M30S`). | #### Data Attributes | Attribute | Description | | ------------ | ---------------------------------------- | | `data-type` | `current`, `duration`, or `remaining`. | #### Renders **React** — Uses `