UNPKG

react-mosaic-component2

Version:
31 lines (30 loc) 1.04 kB
// src/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 };