mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
34 lines
903 B
TypeScript
34 lines
903 B
TypeScript
import React from "react";
|
|
import * as Actions from "../actionCreators";
|
|
import * as Selectors from "../selectors";
|
|
import { useTypedSelector, useActionCreator } from "../hooks";
|
|
|
|
interface Props {
|
|
id?: string;
|
|
style?: React.CSSProperties;
|
|
className?: string;
|
|
}
|
|
|
|
export default function Volume({ id, style, className }: Props) {
|
|
const volume = useTypedSelector(Selectors.getVolume);
|
|
const setFocus = useActionCreator(Actions.setFocus);
|
|
const unsetFocus = useActionCreator(Actions.unsetFocus);
|
|
const setVolume = useActionCreator(Actions.setVolume);
|
|
|
|
return (
|
|
<input
|
|
id={id}
|
|
type="range"
|
|
min="0"
|
|
max="100"
|
|
step="1"
|
|
value={volume}
|
|
style={style}
|
|
className={className}
|
|
onChange={(e) => setVolume(Number(e.target.value))}
|
|
onMouseDown={() => setFocus("volume")}
|
|
onMouseUp={unsetFocus}
|
|
title="Volume Bar"
|
|
/>
|
|
);
|
|
}
|