MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / VolumeNode

Function VolumeNode

audio-flow/src/components/VolumeNode.tsx:12–42  ·  view source on GitHub ↗
({ id, data }: VolumeNodeProps)

Source from the content-addressed store, hash-verified

10}
11
12export function VolumeNode({ id, data }: VolumeNodeProps) {
13 const [gain, setGain] = useState(data.gain);
14
15 const changeGain: ChangeEventHandler<HTMLInputElement> = (e) => {
16 setGain(+e.target.value);
17 updateAudioNode(id, { gain: +e.target.value })
18 }
19
20 return (
21 <div className={'rounded-md bg-white shadow-xl'}>
22 <Handle type="target" className='w-[10px] h-[10px]' position={Position.Top} />
23
24 <p className={'rounded-t-md p-[4px] bg-blue-500 text-white'}>音量节点</p>
25 <div className={'flex flex-col p-[4px]'}>
26 <p>Gain</p>
27 <input
28 className="nodrag"
29 type="range"
30 min="0"
31 max="1"
32 step="0.01"
33 value={gain}
34 onChange={changeGain}
35 />
36 <p className={'text-right'}>{gain.toFixed(2)}</p>
37 </div>
38
39 <Handle type="source" className='w-[10px] h-[10px]' position={Position.Bottom} />
40 </div>
41 );
42}

Callers

nothing calls this directly

Calls 1

useStateFunction · 0.90

Tested by

no test coverage detected