@blueprintjs/core
Version:
Core styles & components
33 lines • 1.57 kB
JavaScript
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the terms of the LICENSE file distributed with this project.
*/
import * as React from "react";
import { Classes } from "../../common";
import { Button } from "../button/buttons";
import { Text } from "../text/text";
export class PanelView extends React.PureComponent {
constructor() {
super(...arguments);
this.handleClose = () => this.props.onClose(this.props.panel);
}
render() {
const { panel, onOpen } = this.props;
// two <span> tags in header ensure title is centered as long as
// possible, due to `flex: 1` magic.
return (React.createElement("div", { className: Classes.PANEL_STACK_VIEW },
React.createElement("div", { className: Classes.PANEL_STACK_HEADER },
React.createElement("span", null, this.maybeRenderBack()),
React.createElement(Text, { className: Classes.HEADING, ellipsize: true }, panel.title),
React.createElement("span", null)),
React.createElement(panel.component, Object.assign({ openPanel: onOpen, closePanel: this.handleClose }, panel.props))));
}
maybeRenderBack() {
if (this.props.previousPanel === undefined) {
return null;
}
return (React.createElement(Button, { className: Classes.PANEL_STACK_HEADER_BACK, icon: "chevron-left", minimal: true, onClick: this.handleClose, small: true, text: this.props.previousPanel.title }));
}
}
//# sourceMappingURL=panelView.js.map