import type { SKINS } from '@app/constants'; import { PRELOAD_VALUES, type PreloadValue } from '@app/shared/sandbox-listener'; import type { SourceId } from '@app/shared/sources'; import type { Platform, Preset, Skin, Styling } from '@app/types'; import { useEffect, useId, useRef, useState } from 'react'; type NavbarProps = { platform: Platform; onPlatformChange: (value: Platform) => void; styling: Styling; onStylingChange: (value: Styling) => void; preset: Preset; onPresetChange: (value: Preset) => void; skin: Skin; onSkinChange: (value: Skin) => void; source: SourceId; onSourceChange: (value: string) => void; autoplay: boolean; onAutoplayChange: (value: boolean) => void; muted: boolean; onMutedChange: (value: boolean) => void; loop: boolean; onLoopChange: (value: boolean) => void; preload: PreloadValue; onPreloadChange: (value: PreloadValue) => void; availableSources: readonly SourceId[]; isBackgroundVideo: boolean; isSimpleHls: boolean; isMuxVideo: boolean; isMuxAudio: boolean; isVimeoVideo: boolean; platforms: readonly Platform[]; stylings: readonly Styling[]; presets: readonly Preset[]; sources: Record; }; const SKIN_OPTIONS: readonly Skin[] = ['default', 'minimal'] satisfies readonly (typeof SKINS)[number][]; const PLATFORM_LABELS: Record = { html: 'HTML', react: 'React', cdn: 'CDN', }; const PRESET_LABELS: Record = { video: 'Video', 'hls-video': 'HLS Video', 'native-hls-video': 'Native HLS Video', 'mux-video': 'Mux Video', 'mux-audio': 'Mux Audio', 'simple-hls-video': 'Simple HLS Video', 'simple-hls-audio-only': 'Simple HLS Audio-Only', 'dash-video': 'DASH Video', audio: 'Audio', 'background-video': 'Background Video', 'vimeo-video': 'Vimeo Video', }; export function Navbar({ platform, onPlatformChange, styling, onStylingChange, preset, onPresetChange, skin, onSkinChange, source, onSourceChange, autoplay, onAutoplayChange, muted, onMutedChange, loop, onLoopChange, preload, onPreloadChange, availableSources, isBackgroundVideo, isSimpleHls, isMuxVideo, isMuxAudio, isVimeoVideo, platforms, stylings, presets, sources, }: NavbarProps) { return (
Video.js v10
onStylingChange(v as Styling)} options={stylings.map((s) => ({ value: s, label: s === 'css' ? 'CSS' : 'Tailwind', disabled: s === 'tailwind' && (isBackgroundVideo || isVimeoVideo || platform === 'cdn'), }))} /> onSkinChange(v as Skin)} options={SKIN_OPTIONS.map((s) => ({ value: s, label: capitalize(s) }))} disabled={isBackgroundVideo} /> onChange(event.target.checked)} className="justify-self-start size-3.5 rounded border-zinc-300 dark:border-zinc-700 accent-zinc-950 dark:accent-zinc-50 cursor-pointer" /> ); } type SelectItemProps = { id: string; label: string; value: string; onChange: (value: string) => void; options: SelectOption[]; }; function SelectItem({ id, label, value, onChange, options }: SelectItemProps) { return ( <>
); } type SelectOption = { value: string; label: string; disabled?: boolean; }; type SelectProps = { label: string; value: string; onChange: (value: string) => void; options: SelectOption[]; disabled?: boolean; }; function Select({ label, value, onChange, options, disabled }: SelectProps) { return (
{label}
); }