1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/add-remove-buttons/add-remove-buttons.tsx
Panu Horsmalahti dcf253e7d5
Add eslint rule padding-line-between-statements (#1593)
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
2020-12-02 09:55:52 +02:00

55 lines
1.3 KiB
TypeScript

import "./add-remove-buttons.scss";
import React from "react";
import { cssNames } from "../../utils";
import { Button } from "../button";
import { Icon } from "../icon";
export interface AddRemoveButtonsProps extends React.HTMLAttributes<any> {
onAdd?: () => void;
onRemove?: () => void;
addTooltip?: React.ReactNode;
removeTooltip?: React.ReactNode;
}
export class AddRemoveButtons extends React.PureComponent<AddRemoveButtonsProps> {
renderButtons() {
const { onRemove, onAdd, addTooltip, removeTooltip } = this.props;
const buttons = [
{
onClick: onRemove,
className: "remove-button",
icon: "remove",
tooltip: removeTooltip,
},
{
onClick: onAdd,
className: "add-button",
icon: "add",
tooltip: addTooltip,
},
];
return buttons.map(button => {
if (!button.onClick) {
return null;
}
const { onClick, className, icon, tooltip } = button;
return (
<Button key={icon} big round primary onClick={onClick} className={className} tooltip={tooltip}>
<Icon material={icon}/>
</Button>
);
});
}
render() {
return (
<div className={cssNames("AddRemoveButtons flex gaps", this.props.className)}>
{this.renderButtons()}
</div>
);
}
}