feat(site): extract api reference from components (#464)

This commit is contained in:
Darius Cepulis
2026-02-05 19:57:54 -06:00
committed by GitHub
parent 48364f17fd
commit 0991a899b2
80 changed files with 3425 additions and 1562 deletions
@@ -1,21 +0,0 @@
import { FullscreenButton } from '@videojs/react-preview';
import { FullscreenEnterIcon, FullscreenExitIcon } from '@videojs/react-preview/icons';
import styles from './FullscreenButton.module.css';
/**
* Basic FullscreenButton example demonstrating:
* - Icon switching based on fullscreen state
* - Data attribute state selectors
* - Enter/exit fullscreen functionality
*
* Note: This component must be used within a VideoProvider context.
* See the usage example in the documentation.
*/
export function BasicFullscreenButton() {
return (
<FullscreenButton className={styles.button}>
<FullscreenEnterIcon className={styles.fullscreenEnterIcon} />
<FullscreenExitIcon className={styles.fullscreenExitIcon} />
</FullscreenButton>
);
}
@@ -1,46 +0,0 @@
.button {
position: relative;
display: grid;
padding: 0.625rem;
border-radius: 0.5rem;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(12px);
border: none;
cursor: pointer;
color: white;
transition: background 150ms ease;
}
.button:hover {
background: rgba(255, 255, 255, 0.15);
}
.button:active {
background: rgba(255, 255, 255, 0.2);
}
/* Icon positioning - both occupy same grid cell */
.fullscreenEnterIcon,
.fullscreenExitIcon {
grid-area: 1/1;
transition: opacity 200ms ease;
width: 18px;
height: 18px;
}
/* Show/hide icons based on fullscreen state using data attributes */
.button:not([data-fullscreen]) .fullscreenEnterIcon {
opacity: 1;
}
.button:not([data-fullscreen]) .fullscreenExitIcon {
opacity: 0;
}
.button[data-fullscreen] .fullscreenEnterIcon {
opacity: 0;
}
.button[data-fullscreen] .fullscreenExitIcon {
opacity: 1;
}
@@ -1,25 +0,0 @@
import { MediaContainer, Video, VideoProvider } from '@videojs/react-preview';
import { VJS8_DEMO_VIDEO } from '@/consts';
import { BasicFullscreenButton } from './BasicFullscreenButton';
/**
* Demo showing proper VideoProvider usage with FullscreenButton.
* The FullscreenButton automatically toggles fullscreen mode for
* the containing MediaContainer.
*/
export function FullscreenButtonDemo() {
return (
<VideoProvider>
<MediaContainer style={{ position: 'relative', zIndex: 10 }}>
<Video
src={VJS8_DEMO_VIDEO.mp4}
poster={VJS8_DEMO_VIDEO.poster}
muted
/>
<div style={{ position: 'absolute', bottom: '1rem', right: '1rem', zIndex: 10 }}>
<BasicFullscreenButton />
</div>
</MediaContainer>
</VideoProvider>
);
}
@@ -1,22 +0,0 @@
import { MuteButton } from '@videojs/react-preview';
import { VolumeHighIcon, VolumeLowIcon, VolumeOffIcon } from '@videojs/react-preview/icons';
import styles from './MuteButton.module.css';
/**
* Basic MuteButton example demonstrating:
* - Multi-state icon switching (high/medium/low/off)
* - Volume level data attributes
* - Smooth icon transitions
*
* Note: This component must be used within a VideoProvider context.
* See the usage example in the documentation.
*/
export function BasicMuteButton() {
return (
<MuteButton className={styles.button}>
<VolumeHighIcon className={styles.volumeHighIcon} />
<VolumeLowIcon className={styles.volumeLowIcon} />
<VolumeOffIcon className={styles.volumeOffIcon} />
</MuteButton>
);
}
@@ -1,48 +0,0 @@
.button {
position: relative;
display: grid;
padding: 0.625rem;
border-radius: 0.5rem;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(12px);
border: none;
cursor: pointer;
color: white;
transition: background 150ms ease;
}
.button:hover {
background: rgba(255, 255, 255, 0.15);
}
.button:active {
background: rgba(255, 255, 255, 0.2);
}
/* Icon positioning - all icons occupy same grid cell */
.volumeHighIcon,
.volumeLowIcon,
.volumeOffIcon {
grid-area: 1/1;
transition: opacity 200ms ease;
width: 18px;
height: 18px;
opacity: 0;
}
/* Show appropriate icon based on volume level using data attributes */
/* High volume (> 50%) */
.button[data-volume-level='high'] .volumeHighIcon {
opacity: 1;
}
/* Medium/Low volume (1-50%) */
.button[data-volume-level='medium'] .volumeLowIcon,
.button[data-volume-level='low'] .volumeLowIcon {
opacity: 1;
}
/* Muted/Off volume (0%) */
.button[data-volume-level='off'] .volumeOffIcon {
opacity: 1;
}
@@ -1,25 +0,0 @@
import { MediaContainer, Video, VideoProvider } from '@videojs/react-preview';
import { VJS8_DEMO_VIDEO } from '@/consts';
import { BasicMuteButton } from './BasicMuteButton';
/**
* Demo showing proper VideoProvider usage with MuteButton.
* The MuteButton automatically reflects the current volume state
* and toggles mute/unmute on click.
*/
export function MuteButtonDemo() {
return (
<VideoProvider>
<MediaContainer style={{ position: 'relative', zIndex: 10 }}>
<Video
src={VJS8_DEMO_VIDEO.mp4}
poster={VJS8_DEMO_VIDEO.poster}
muted
/>
<div style={{ position: 'absolute', bottom: '1rem', left: '1rem', zIndex: 10 }}>
<BasicMuteButton />
</div>
</MediaContainer>
</VideoProvider>
);
}
@@ -1,21 +0,0 @@
import { PlayButton } from '@videojs/react-preview';
import { PauseIcon, PlayIcon } from '@videojs/react-preview/icons';
import styles from './PlayButton.module.css';
/**
* Basic PlayButton example demonstrating:
* - Icon switching based on paused state
* - CSS Modules for scoped styling
* - Data attribute selectors for state-based styling
*
* Note: This component must be used within a VideoProvider context.
* See the usage example in the documentation.
*/
export function BasicPlayButton() {
return (
<PlayButton className={styles.button}>
<PlayIcon className={styles.playIcon} />
<PauseIcon className={styles.pauseIcon} />
</PlayButton>
);
}
@@ -1,46 +0,0 @@
.button {
position: relative;
display: grid;
padding: 0.625rem;
border-radius: 0.5rem;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(12px);
border: none;
cursor: pointer;
color: white;
transition: background 150ms ease;
}
.button:hover {
background: rgba(255, 255, 255, 0.15);
}
.button:active {
background: rgba(255, 255, 255, 0.2);
}
/* Icon positioning - both occupy same grid cell */
.playIcon,
.pauseIcon {
grid-area: 1/1;
transition: opacity 200ms ease;
width: 18px;
height: 18px;
}
/* Show/hide icons based on paused state using data attributes */
.button[data-paused] .playIcon {
opacity: 1;
}
.button[data-paused] .pauseIcon {
opacity: 0;
}
.button:not([data-paused]) .playIcon {
opacity: 0;
}
.button:not([data-paused]) .pauseIcon {
opacity: 1;
}
@@ -1,25 +0,0 @@
import { MediaContainer, Video, VideoProvider } from '@videojs/react-preview';
import { VJS8_DEMO_VIDEO } from '@/consts';
import { BasicPlayButton } from './BasicPlayButton';
/**
* Demo showing proper VideoProvider usage with PlayButton.
* The VideoProvider wraps the entire media experience and provides
* the necessary context for all media components.
*/
export function PlayButtonDemo() {
return (
<VideoProvider>
<MediaContainer style={{ position: 'relative', zIndex: 10 }}>
<Video
src={VJS8_DEMO_VIDEO.mp4}
poster={VJS8_DEMO_VIDEO.poster}
muted
/>
<div style={{ position: 'absolute', bottom: '1rem', left: '1rem', zIndex: 10 }}>
<BasicPlayButton />
</div>
</MediaContainer>
</VideoProvider>
);
}
@@ -1,24 +0,0 @@
import { TimeSlider } from '@videojs/react-preview';
import styles from './TimeSlider.module.css';
/**
* Basic TimeSlider example demonstrating:
* - Progress and pointer visualization
* - Horizontal orientation
* - CSS Modules for scoped styling
* - Data attribute selectors for state-based styling
*
* Note: This component must be used within a VideoProvider context.
* See the usage example in the documentation.
*/
export function BasicTimeSlider() {
return (
<TimeSlider.Root className={styles.root} orientation="horizontal">
<TimeSlider.Track className={styles.track}>
<TimeSlider.Progress className={styles.progress} />
<TimeSlider.Pointer className={styles.pointer} />
</TimeSlider.Track>
<TimeSlider.Thumb className={styles.thumb} />
</TimeSlider.Root>
);
}
@@ -1,64 +0,0 @@
.root {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
/* Horizontal orientation */
.root[data-orientation='horizontal'] {
width: 100%;
min-width: 100px;
height: 20px;
}
/* Vertical orientation */
.root[data-orientation='vertical'] {
width: 20px;
height: 100px;
flex-direction: column;
}
.track {
position: relative;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 0.25rem;
overflow: hidden;
}
/* Horizontal track */
.track[data-orientation='horizontal'] {
width: 100%;
height: 0.375rem;
}
/* Vertical track */
.track[data-orientation='vertical'] {
width: 0.375rem;
height: 100%;
}
.progress {
background-color: #007bff;
border-radius: inherit;
position: absolute;
}
.pointer {
background-color: rgba(255, 255, 255, 0.5);
position: absolute;
pointer-events: none;
}
.thumb {
width: 0.75rem;
height: 0.75rem;
background-color: #fff;
border-radius: 50%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
transition: transform 150ms ease;
}
.thumb:hover {
transform: scale(1.2);
}
@@ -1,25 +0,0 @@
import { MediaContainer, Video, VideoProvider } from '@videojs/react-preview';
import { VJS8_DEMO_VIDEO } from '@/consts';
import { BasicTimeSlider } from './BasicTimeSlider';
/**
* Demo showing proper VideoProvider usage with TimeSlider.
* The VideoProvider wraps the entire media experience and provides
* the necessary context for all media components.
*/
export function TimeSliderDemo() {
return (
<VideoProvider>
<MediaContainer style={{ position: 'relative', zIndex: 10 }}>
<Video
src={VJS8_DEMO_VIDEO.mp4}
poster={VJS8_DEMO_VIDEO.poster}
muted
/>
<div style={{ position: 'absolute', bottom: '1rem', left: '1rem', right: '1rem', zIndex: 10 }}>
<BasicTimeSlider />
</div>
</MediaContainer>
</VideoProvider>
);
}
@@ -1,23 +0,0 @@
import { VolumeSlider } from '@videojs/react-preview';
import styles from './VolumeSlider.module.css';
/**
* Basic VolumeSlider example demonstrating:
* - Volume level visualization
* - Horizontal orientation
* - CSS Modules for scoped styling
* - Data attribute selectors for state-based styling
*
* Note: This component must be used within a VideoProvider context.
* See the usage example in the documentation.
*/
export function BasicVolumeSlider() {
return (
<VolumeSlider.Root className={styles.root} orientation="horizontal">
<VolumeSlider.Track className={styles.track}>
<VolumeSlider.Progress className={styles.progress} />
</VolumeSlider.Track>
<VolumeSlider.Thumb className={styles.thumb} />
</VolumeSlider.Root>
);
}
@@ -1,58 +0,0 @@
.root {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
/* Horizontal orientation */
.root[data-orientation='horizontal'] {
width: 80px;
min-width: 80px;
height: 20px;
}
/* Vertical orientation */
.root[data-orientation='vertical'] {
width: 20px;
height: 80px;
flex-direction: column;
}
.track {
position: relative;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 0.25rem;
overflow: hidden;
}
/* Horizontal track */
.track[data-orientation='horizontal'] {
width: 100%;
height: 0.375rem;
}
/* Vertical track */
.track[data-orientation='vertical'] {
width: 0.375rem;
height: 100%;
}
.progress {
background-color: #007bff;
border-radius: inherit;
position: absolute;
}
.thumb {
width: 0.75rem;
height: 0.75rem;
background-color: #fff;
border-radius: 50%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
transition: transform 150ms ease;
}
.thumb:hover {
transform: scale(1.2);
}
@@ -1,25 +0,0 @@
import { MediaContainer, Video, VideoProvider } from '@videojs/react-preview';
import { VJS8_DEMO_VIDEO } from '@/consts';
import { BasicVolumeSlider } from './BasicVolumeSlider';
/**
* Demo showing proper VideoProvider usage with VolumeSlider.
* The VideoProvider wraps the entire media experience and provides
* the necessary context for all media components.
*/
export function VolumeSliderDemo() {
return (
<VideoProvider>
<MediaContainer style={{ position: 'relative', zIndex: 10 }}>
<Video
src={VJS8_DEMO_VIDEO.mp4}
poster={VJS8_DEMO_VIDEO.poster}
muted
/>
<div style={{ position: 'absolute', bottom: '1rem', right: '1rem', zIndex: 10 }}>
<BasicVolumeSlider />
</div>
</MediaContainer>
</VideoProvider>
);
}