-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontent-box.jsx
More file actions
47 lines (41 loc) · 1.04 KB
/
content-box.jsx
File metadata and controls
47 lines (41 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* @flow */
// libs
import { isEmpty } from 'lodash';
import classNames from 'classnames';
import React, { Element } from 'react';
// styles
import s from './content-box.css';
type Props = {
id: string,
title: string | Element<any>,
className: string,
bodyClassName: string,
actionBlock: Element<any>,
children: Element<any>,
footer: Element<any>,
indentContent: boolean,
renderContent: Function,
viewContent: Element<any>,
}
export default (props: Props) => {
let body = props.children;
if (isEmpty(body)) {
if (props.renderContent) {
body = props.renderContent();
} else if (props.viewContent) {
body = props.viewContent;
}
}
return (
<div id={props.id} className={classNames(s.box, props.className)}>
<header className={s.header}>
<div className={s.title}>{props.title}</div>
<div className={s.controls}>{props.actionBlock}</div>
</header>
<div className={classNames(s.body, props.bodyClassName)}>
{body}
</div>
{props.footer}
</div>
);
};