2019-08-09 10:17:04 +00:00
|
|
|
import Button from "@material-ui/core/Button";
|
|
|
|
import { Theme } from "@material-ui/core/styles";
|
|
|
|
import { fade } from "@material-ui/core/styles/colorManipulator";
|
|
|
|
import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown";
|
|
|
|
import makeStyles from "@material-ui/styles/makeStyles";
|
|
|
|
import classNames from "classnames";
|
|
|
|
import React from "react";
|
2019-08-26 21:54:03 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
|
|
|
interface ColumnPickerButtonProps {
|
|
|
|
active: boolean;
|
|
|
|
className?: string;
|
|
|
|
onClick: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const useStyles = makeStyles(
|
|
|
|
(theme: Theme) => ({
|
|
|
|
icon: {
|
|
|
|
marginLeft: theme.spacing.unit * 2,
|
|
|
|
transition: theme.transitions.duration.short + "ms"
|
|
|
|
},
|
|
|
|
root: {
|
|
|
|
"& span": {
|
|
|
|
color: theme.palette.primary.main
|
|
|
|
},
|
|
|
|
paddingRight: theme.spacing.unit
|
|
|
|
},
|
|
|
|
rootActive: {
|
|
|
|
background: fade(theme.palette.primary.main, 0.1)
|
|
|
|
},
|
|
|
|
rotate: {
|
|
|
|
transform: "rotate(180deg)"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
name: "ColumnPickerButton"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const ColumnPickerButton: React.FC<ColumnPickerButtonProps> = props => {
|
|
|
|
const { active, className, onClick } = props;
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
className={classNames(classes.root, className, {
|
|
|
|
[classes.rootActive]: active
|
|
|
|
})}
|
|
|
|
color="primary"
|
|
|
|
onClick={onClick}
|
|
|
|
variant="outlined"
|
|
|
|
>
|
2019-08-26 21:54:03 +00:00
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Columns"
|
|
|
|
description="select visible columns button"
|
|
|
|
/>
|
2019-08-09 10:17:04 +00:00
|
|
|
<ArrowDropDownIcon
|
|
|
|
color="primary"
|
|
|
|
className={classNames(classes.icon, {
|
|
|
|
[classes.rotate]: active
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ColumnPickerButton;
|