declare var require; const React = require("react"); const {Box, Item, Dialog} = require("react-polymer-layout"); export = React.createClass({ propTypes: { color: React.PropTypes.string, type: React.PropTypes.string, text: React.PropTypes.string, cancelText: React.PropTypes.string, confirmText: React.PropTypes.string, style: React.PropTypes.object, className: React.PropTypes.object, onSubmit: React.PropTypes.func, }, getDefaultProps() { return { className: "react-lean-alert" }; }, getInitialState() { return { submitted: false }; }, show() { this.setState({submitted: false}); this.refs.dialog.show(); }, hide() { this.refs.dialog.hide(); }, _mark(mark: string, color: string) { switch (mark) { case "!": case "?": case "x": return (
{mark === "x" ? "×" : mark}
); case "v": return (
); } }, _handleSubmit(e) { this.setState({submitted: true}); if (this.props.onSubmit) this.props.onSubmit(e); }, render() { let props = this.props; let color:string = props.color; switch (color) { case "RED": color = "#e3757f"; break; case "GREEN": color = "#83ce35"; break; case "BLUE": color = "#009cff"; break; } let dialogStyle = { width: 420, color: "#333", padding: 0, borderRadius: 2, overflow: "hidden", }; for (let k in props.style) dialogStyle[k] = props.style[k]; return (
{this._mark(props.type, color)}
{props.text}
{props.cancelText && ( this.hide()}> {props.cancelText} )} {props.confirmText}
); } })