2016-02-13 20:58:47 +05:30
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
import classNames from 'classnames';
|
2016-01-08 18:44:35 +05:30
|
|
|
|
|
|
|
import styles from './panel.scss';
|
2016-01-09 17:29:42 +05:30
|
|
|
import icons from './icons.scss';
|
2016-01-08 18:44:35 +05:30
|
|
|
|
|
|
|
export function Panel(props) {
|
2016-01-09 17:29:42 +05:30
|
|
|
var { title, icon } = props;
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
icon = (
|
|
|
|
<button className={styles.headerControl}>
|
|
|
|
<span className={icons[icon]} />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
2016-01-08 18:44:35 +05:30
|
|
|
|
|
|
|
if (title) {
|
|
|
|
title = (
|
|
|
|
<PanelHeader>
|
2016-01-09 17:29:42 +05:30
|
|
|
{icon}
|
2016-01-08 18:44:35 +05:30
|
|
|
{title}
|
|
|
|
</PanelHeader>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.panel}>
|
|
|
|
{title}
|
|
|
|
|
|
|
|
{props.children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function PanelHeader(props) {
|
|
|
|
return (
|
2016-01-10 05:34:44 +05:30
|
|
|
<div className={styles.header} {...props}>
|
2016-01-08 18:44:35 +05:30
|
|
|
{props.children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function PanelBody(props) {
|
|
|
|
return (
|
2016-01-10 05:34:44 +05:30
|
|
|
<div className={styles.body} {...props}>
|
2016-01-08 18:44:35 +05:30
|
|
|
{props.children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function PanelFooter(props) {
|
|
|
|
return (
|
2016-01-10 05:34:44 +05:30
|
|
|
<div className={styles.footer} {...props}>
|
2016-01-08 18:44:35 +05:30
|
|
|
{props.children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-01-09 19:21:55 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
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;
|
2016-01-09 19:21:55 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
let close;
|
|
|
|
if (type === 'error') {
|
|
|
|
close = (
|
|
|
|
<span className={styles.close} onClick={this.onClose} />
|
|
|
|
);
|
|
|
|
}
|
2016-01-09 21:17:21 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
const className = classNames(styles[`${type}BodyHeader`], {
|
|
|
|
[styles.isClosed]: this.state && this.state.isClosed
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={className} {...this.props}>
|
|
|
|
{close}
|
|
|
|
{children}
|
|
|
|
</div>
|
2016-01-09 21:17:21 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
onClose = (event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
this.setState({isClosed: true});
|
|
|
|
|
|
|
|
this.props.onClose();
|
|
|
|
};
|
2016-01-09 19:21:55 +05:30
|
|
|
}
|