webamp/js/components/MainWindow/Repeat.tsx
2019-08-20 07:43:23 -07:00

33 lines
894 B
TypeScript

import React from "react";
import classnames from "classnames";
import * as Actions from "../../actionCreators";
import * as Selectors from "../../selectors";
import ContextMenuWraper from "../ContextMenuWrapper";
import { Node } from "../ContextMenu";
import { useTypedSelector, useActionCreator } from "../../hooks";
const Repeat = React.memo(() => {
const repeat = useTypedSelector(Selectors.getRepeat);
const handleClick = useActionCreator(Actions.toggleRepeat);
return (
<ContextMenuWraper
renderContents={() => (
<Node
checked={repeat}
label="Repeat"
onClick={handleClick}
hotkey="(R)"
/>
)}
>
<div
id="repeat"
className={classnames({ selected: repeat })}
onClick={handleClick}
title="Toggle Repeat"
/>
</ContextMenuWraper>
);
});
export default Repeat;