preact-material-design
Version:
A set of material components for Preact.
80 lines • 3.18 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { h, Component } from 'preact';
import Portal from 'preact-portal';
var Dialog = (function (_super) {
__extends(Dialog, _super);
function Dialog() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.hideIfContainer = function (evt) {
if (evt.target === _this.container) {
_this.hide();
}
};
return _this;
}
Dialog.prototype.show = function () {
this.setState({ visible: true });
};
Dialog.prototype.hide = function () {
this.setState({ visible: false });
};
Dialog.prototype.render = function () {
var _this = this;
var children = this.props.children;
var visible = this.state.visible;
return (h(Portal, { into: "body" }, visible && h("div", { ref: function (container) { return _this.container = container; }, class: "pmd-dialog-container", onClick: this.hideIfContainer },
h("div", { class: "pmd-dialog" }, children))));
};
return Dialog;
}(Component));
export { Dialog };
var DialogTitle = (function (_super) {
__extends(DialogTitle, _super);
function DialogTitle() {
return _super !== null && _super.apply(this, arguments) || this;
}
DialogTitle.prototype.render = function () {
var children = this.props.children;
return h("div", { class: "pmd-dialog-title pmd-dialog--includes-padding" }, children);
};
return DialogTitle;
}(Component));
export { DialogTitle };
var DialogContent = (function (_super) {
__extends(DialogContent, _super);
function DialogContent() {
return _super !== null && _super.apply(this, arguments) || this;
}
DialogContent.prototype.render = function () {
var children = this.props.children;
return h("div", { class: "pmd-dialog-content pmd-dialog--includes-padding" }, children);
};
return DialogContent;
}(Component));
export { DialogContent };
var DialogActions = (function (_super) {
__extends(DialogActions, _super);
function DialogActions() {
return _super !== null && _super.apply(this, arguments) || this;
}
DialogActions.prototype.render = function () {
var _a = this.props, children = _a.children, vertical = _a.vertical;
var classes = ['pmd-dialog-actions'];
if (vertical) {
classes.push('pmd-dialog-actions--vertical');
}
return h("div", { class: classes.join(' ') }, children);
};
return DialogActions;
}(Component));
export { DialogActions };
//# sourceMappingURL=Dialog.js.map