Skip to content

Commit a486555

Browse files
Add new MinimalVideoPlayer component (#1425)
* Add new MinimalVideoPlayer component * Add changeset * Add tests * Update snapshots * Add docs * Add docs thumbnails * Cleanup CSS * Update tests * Add useMinimalVideoPlayback hook and cleanup * Fixes * Improve ref handling * Add MinimalVideoPlayer to FlexSuite recipe * Update snapshots * Address feedback * roll back the vrt change * update play icon --------- Co-authored-by: Reza Rahman <13340707+rezrah@users.noreply.github.com>
1 parent 8040f9a commit a486555

30 files changed

Lines changed: 1091 additions & 24 deletions

.changeset/calm-videos-play.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@primer/react-brand': minor
3+
---
4+
5+
Added the new `MinimalVideoPlayer` component for presenting muted, looping videos with a minimal play and pause control.
6+
7+
```tsx
8+
<MinimalVideoPlayer poster="/video-poster.jpg" src="/video.webm" title="Product interface demonstration" />
9+
```
10+
11+
🔗 [See `MinimalVideoPlayer` documentation for more usage examples](https://primer.style/brand/components/MinimalVideoPlayer)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: Minimal video player
3+
description: Use MinimalVideoPlayer for muted, looping product demonstrations with a single play and pause control
4+
keywords: ['playback', 'media', 'video', 'motion']
5+
show-tabs: false
6+
ready: true
7+
source: https://github.com/primer/brand/blob/main/packages/react/src/MinimalVideoPlayer/MinimalVideoPlayer.tsx
8+
storybook: '/brand/storybook/?path=/story/components-minimalvideoplayer--playground'
9+
thumbnail: '/images/thumbnails/minimal-video-player-thumbnail.png'
10+
thumbnail_darkMode: '/images/thumbnails/minimal-video-player-thumbnail-dark.png'
11+
---
12+
13+
```js
14+
import {MinimalVideoPlayer} from '@primer/react-brand'
15+
```
16+
17+
Use `MinimalVideoPlayer` for short, silent product demonstrations that need only a play and pause control.
18+
19+
Use [VideoPlayer](/components/VideoPlayer) when viewers need audio, captions, seeking, volume, fullscreen controls,
20+
branding, or a dedicated programmatic playback API.
21+
22+
## Examples
23+
24+
### Default
25+
26+
Pass a native video URL with `src`. The required `title` provides a concise accessible name for the video.
27+
28+
```jsx live
29+
<MinimalVideoPlayer
30+
aria-describedby="product-demo-description"
31+
poster="/images/example-poster.png"
32+
src="/example.mp4"
33+
title="Product interface demonstration"
34+
/>
35+
```
36+
37+
### Native source element
38+
39+
The component also accepts native `<source>` children.
40+
41+
```jsx live
42+
<MinimalVideoPlayer poster="/images/example-poster.png" title="Product interface demonstration">
43+
<source src="/example.mp4" type="video/mp4" />
44+
</MinimalVideoPlayer>
45+
```
46+
47+
### Disable automatic playback
48+
49+
`autoPlay` defaults to `true`, making the video eligible to play when it enters the viewport. Set it to `false` when playback should always begin with an explicit user action.
50+
51+
```jsx live
52+
<MinimalVideoPlayer
53+
autoPlay={false}
54+
poster="/images/example-poster.png"
55+
src="/example.mp4"
56+
title="Product interface demonstration"
57+
/>
58+
```
59+
60+
### Disable looping
61+
62+
Videos loop by default. Set `loop` to `false` when the demonstration should stop after one playback.
63+
64+
```jsx live
65+
<MinimalVideoPlayer
66+
loop={false}
67+
poster="/images/example-poster.png"
68+
src="/example.mp4"
69+
title="Product interface demonstration"
70+
/>
71+
```
72+
73+
### Customize control labels
74+
75+
Provide localized play and pause labels with `internalAccessibleLabels`. Keep `title` focused on naming the video rather than the control.
76+
77+
```jsx live
78+
<MinimalVideoPlayer
79+
autoPlay={false}
80+
internalAccessibleLabels={{
81+
play: 'Play product demonstration',
82+
pause: 'Pause product demonstration',
83+
}}
84+
poster="/images/example-poster.png"
85+
src="/example.mp4"
86+
title="Product interface demonstration"
87+
/>
88+
```
89+
90+
## Playback behavior
91+
92+
`MinimalVideoPlayer` is always muted, plays inline, and hides native controls. When `autoPlay` is enabled, it starts only while visible, pauses after leaving the viewport, and resumes after re-entering the viewport unless the viewer paused it manually.
93+
94+
The forwarded ref provides access to the underlying `<video>` element, but the component does not provide a higher-level programmatic playback API.
95+
96+
The component respects the viewer's reduced-motion preference. It suppresses initial automatic playback when reduced motion is requested and pauses playback if that preference becomes active. A viewer can still start the video with the visible play control.
97+
98+
## Accessibility
99+
100+
The `title` prop provides an accessible name for the video. It does not replace a text alternative for meaningful visual content.
101+
102+
For decorative motion or a demonstration that repeats information already communicated by the surrounding content, use a concise `title`. A separate description is not required because the same information is already available on the page.
103+
104+
For a meaningful silent demonstration, provide adjacent text that communicates the important actions and outcomes shown in the video. Associate that text with the video using the native `aria-describedby` attribute, as shown in the [default example](#default).
105+
106+
Use [VideoPlayer](/components/VideoPlayer) instead when the media needs audio, captions, seeking, volume, fullscreen controls, or a standalone viewing experience.
107+
108+
## Component props
109+
110+
`MinimalVideoPlayer` supports standard native `<video>` attributes except the playback attributes controlled by the component.
111+
112+
| Name | Type | Default | Required | Description |
113+
| :------------------------- | :------------------------------ | :------------------------------------------: | :------: | :--------------------------------------------------------------------- |
114+
| `autoPlay` | `boolean` | `true` | `false` | Plays automatically while visible when reduced motion is not requested |
115+
| `children` | `React.ReactNode` | | `false` | Accepts native `<source>` elements |
116+
| `internalAccessibleLabels` | `{play: string, pause: string}` | `{play: 'Play video', pause: 'Pause video'}` | `false` | Sets accessible labels for the play and pause control |
117+
| `loop` | `boolean` | `true` | `false` | Repeats the video after playback ends |
118+
| `poster` | `string` | | `false` | Sets the image shown before playback begins |
119+
| `src` | `string` | | `false` | Sets the native video source URL |
120+
| `title` | `string` | | `true` | Provides an accessible name for the video |
2.66 KB
Loading
3.03 KB
Loading

apps/storybook/static/locales/de/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "Hast du Visual Studio Code bereits?",
2525
"trailingLinkText": "Jetzt öffnen",
2626
"peekAlt": "GitHub-Copilot-Maskottchen schaut unten aus dem Rasterbereich hervor",
27-
"imageAlt": "GitHub Copilot im Agent-Modus in VS Code"
27+
"imageAlt": "GitHub Copilot im Agent-Modus in VS Code",
28+
"videoControls": {
29+
"play": "Video abspielen",
30+
"pause": "Video pausieren"
31+
}
2832
},
2933
"logoSuiteHeading": "Partnerlogos von GitHub Copilot",
3034
"resourceCards": {

apps/storybook/static/locales/en/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "Already have Visual Studio Code?",
2525
"trailingLinkText": "Open now",
2626
"peekAlt": "GitHub Copilot mascot peeking from the bottom of the grid area",
27-
"imageAlt": "GitHub Copilot agent mode in VS Code"
27+
"imageAlt": "GitHub Copilot agent mode in VS Code",
28+
"videoControls": {
29+
"play": "Play video",
30+
"pause": "Pause video"
31+
}
2832
},
2933
"logoSuiteHeading": "GitHub Copilot partner logos",
3034
"resourceCards": {

apps/storybook/static/locales/es/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "¿Ya tienes Visual Studio Code?",
2525
"trailingLinkText": "Abrir ahora",
2626
"peekAlt": "La mascota de GitHub Copilot asomándose desde la parte inferior del área de cuadrícula",
27-
"imageAlt": "GitHub Copilot en modo agente en VS Code"
27+
"imageAlt": "GitHub Copilot en modo agente en VS Code",
28+
"videoControls": {
29+
"play": "Reproducir video",
30+
"pause": "Pausar video"
31+
}
2832
},
2933
"logoSuiteHeading": "Logotipos de socios de GitHub Copilot",
3034
"resourceCards": {

apps/storybook/static/locales/fr/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "Vous avez déjà Visual Studio Code ?",
2525
"trailingLinkText": "Ouvrir maintenant",
2626
"peekAlt": "La mascotte de GitHub Copilot apparaît en bas de la zone quadrillée",
27-
"imageAlt": "GitHub Copilot en mode agent dans VS Code"
27+
"imageAlt": "GitHub Copilot en mode agent dans VS Code",
28+
"videoControls": {
29+
"play": "Lire la vidéo",
30+
"pause": "Mettre la vidéo en pause"
31+
}
2832
},
2933
"logoSuiteHeading": "Logos partenaires de GitHub Copilot",
3034
"resourceCards": {

apps/storybook/static/locales/ja/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "Visual Studio Code はすでにお持ちですか?",
2525
"trailingLinkText": "今すぐ開く",
2626
"peekAlt": "グリッド領域の下からのぞく GitHub Copilot のマスコット",
27-
"imageAlt": "VS Code でエージェントモードを使う GitHub Copilot"
27+
"imageAlt": "VS Code でエージェントモードを使う GitHub Copilot",
28+
"videoControls": {
29+
"play": "動画を再生",
30+
"pause": "動画を一時停止"
31+
}
2832
},
2933
"logoSuiteHeading": "GitHub Copilot のパートナーロゴ",
3034
"resourceCards": {

apps/storybook/static/locales/pt-BR/FlexSuiteOverview.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"trailingText": "Já tem o Visual Studio Code?",
2525
"trailingLinkText": "Abrir agora",
2626
"peekAlt": "Mascote do GitHub Copilot espiando a partir da parte inferior da área em grade",
27-
"imageAlt": "GitHub Copilot no modo agente no VS Code"
27+
"imageAlt": "GitHub Copilot no modo agente no VS Code",
28+
"videoControls": {
29+
"play": "Reproduzir vídeo",
30+
"pause": "Pausar vídeo"
31+
}
2832
},
2933
"logoSuiteHeading": "Logotipos de parceiros do GitHub Copilot",
3034
"resourceCards": {

0 commit comments

Comments
 (0)