import React, { Component, PropTypes } from 'react'; import classNames from 'classnames'; import { omit } from 'functions'; import styles from './panel.scss'; import icons from './icons.scss'; export function Panel(props) { var { title, icon } = props; if (icon) { icon = ( ); } if (title) { title = ( {icon} {title} ); } return (
{title} {props.children}
); } export function PanelHeader(props) { return (
{props.children}
); } export function PanelBody(props) { return (
{props.children}
); } export function PanelFooter(props) { return (
{props.children}
); } export class PanelBodyHeader extends Component { static displayName = 'PanelBodyHeader'; static propTypes = { type: PropTypes.oneOf(['default', 'error']), onClose: PropTypes.func }; render() { const {type = 'default', children} = this.props; let close; if (type === 'error') { close = ( ); } const className = classNames(styles[`${type}BodyHeader`], { [styles.isClosed]: this.state && this.state.isClosed }); return (
{close} {children}
); } onClose = (event) => { event.preventDefault(); this.setState({isClosed: true}); this.props.onClose(); }; }