@lonli-lokli/react-mosaic-component
Version:
A React Tiling Window Manager
37 lines (36 loc) • 1.11 kB
JavaScript
// libs/react-mosaic-component/src/lib/buttons/RemoveButton.tsx
import classNames from "classnames";
import React from "react";
import {
MosaicContext,
MosaicWindowContext
} from "../contextTypes.mjs";
import { OptionalBlueprint } from "../util/OptionalBlueprint.mjs";
import { DefaultToolbarButton } from "./MosaicButton.mjs";
var RemoveButton = class extends React.PureComponent {
static contextType = MosaicWindowContext;
render() {
return /* @__PURE__ */ React.createElement(MosaicContext.Consumer, null, ({ mosaicActions, blueprintNamespace }) => /* @__PURE__ */ React.createElement(
DefaultToolbarButton,
{
title: "Close Window",
className: classNames(
"close-button",
OptionalBlueprint.getIconClass(blueprintNamespace, "CROSS")
),
onClick: this.createRemove(mosaicActions)
}
));
}
createRemove(mosaicActions) {
return () => {
mosaicActions.remove(this.context.mosaicWindowActions.getPath());
if (this.props.onClick) {
this.props.onClick();
}
};
}
};
export {
RemoveButton
};