webamp/js/components/MainWindow/ClutterBar.tsx
Jordan Eldredge 0be6ff9ede Ensure ESLint is running on Travis
It used to run as part of Jest. When I moved it back to its own thing,
I guess I forgot to add it back to Travis.
2019-08-18 14:00:06 -07:00

45 lines
1.3 KiB
TypeScript

import React from "react";
import classnames from "classnames";
import * as Actions from "../../actionCreators";
import { Action, Thunk } from "../../types";
import OptionsContextMenu from "../OptionsContextMenu";
import ContextMenuTarget from "../ContextMenuTarget";
import { useActionCreator, useTypedSelector } from "../../hooks";
import * as Selectors from "../../selectors";
function setFocusDouble(): Action {
return Actions.setFocus("double");
}
function mouseUp(): Thunk {
return dispatch => {
dispatch(Actions.toggleDoubleSizeMode());
dispatch(Actions.unsetFocus());
};
}
const ClutterBar = React.memo(() => {
const handleMouseDown = useActionCreator(setFocusDouble);
const handleMouseUp = useActionCreator(mouseUp);
const doubled = useTypedSelector(Selectors.getDoubled);
return (
<div id="clutter-bar">
<ContextMenuTarget bottom handle={<div id="button-o" />}>
<OptionsContextMenu />
</ContextMenuTarget>
<div id="button-a" />
<div id="button-i" />
<div
title={"Toggle Doublesize Mode"}
id="button-d"
className={classnames({ selected: doubled })}
onMouseUp={handleMouseUp}
onMouseDown={handleMouseDown}
/>
<div id="button-v" />
</div>
);
});
export default ClutterBar;