Spaces:
Configuration error
Configuration error
Download web/libs/editor/src/components/Timeline/SideControls/VolumeControl.tsx from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/Timeline/SideControls/VolumeControl.tsx
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/libs/editor/src/components/Timeline/SideControls/VolumeControl.tsx
-
curl -L -o VolumeControl.tsx https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/components/Timeline/SideControls/VolumeControl.tsx
1.2 kB
| import { type CSSProperties, type FC, useMemo, useRef } from "react"; | |
| import { IconVolumeFull, IconVolumeHalf, IconVolumeMute } from "@humansignal/icons"; | |
| import { Range } from "../../../common/Range/Range"; | |
| import { WS_VOLUME } from "../../../tags/object/Audio/constants"; | |
| import type { TimelineSideControlProps } from "../Types"; | |
| export const AudioVolumeControl: FC<TimelineSideControlProps> = ({ volume = 0.5, onVolumeChange }) => { | |
| const storedVolume = useRef(volume); | |
| const style: CSSProperties = { color: "#99A0AE" }; | |
| const icon = useMemo(() => { | |
| if (volume > 0.5) return <IconVolumeFull style={style} />; | |
| if (volume > 0) return <IconVolumeHalf style={style} />; | |
| return <IconVolumeMute style={style} />; | |
| }, [volume]); | |
| return ( | |
| <Range | |
| continuous | |
| min={WS_VOLUME.min} | |
| max={WS_VOLUME.max} | |
| step={WS_VOLUME.step} | |
| value={volume} | |
| minIcon={icon} | |
| onChange={(volume) => onVolumeChange?.(Number(volume))} | |
| onMinIconClick={() => { | |
| if (volume === 0) { | |
| onVolumeChange?.(storedVolume.current); | |
| } else { | |
| storedVolume.current = volume; | |
| onVolumeChange?.(0); | |
| } | |
| }} | |
| /> | |
| ); | |
| }; | |