This repository was archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 798
/
Copy pathbox.js
executable file
·75 lines (64 loc) · 2.57 KB
/
box.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
define(
[
'react',
'create-react-class',
'react-dom',
],
function (React, createReactClass, ReactDOM) {
var Box = createReactClass({
getDefaultProps: function() {
return {
collapsed: false,
theme: 'box-default',
loading: false,
border: true,
title: 'Default title',
content: '',
}
},
render: function() {
var boxType = '', borderClass = '', boxToolsContainer, boxTools = [], loadingState, footer;
if(this.props.border === true){
borderClass = 'box-solid';
}
if(this.props.boxTools){
var BoxTool = require('./box-tool');
this.props.boxTools.map(function(tool, index){
boxTools.push(<BoxTool key={index} toolType={tool} containerClass="box"/>)
});
boxToolsContainer = <div className="box-tools pull-right">{boxTools}</div>
}
if(this.props.loading === true){
loadingState =
<div className="overlay">
<i className="fa fa-refresh fa-spin"></i>
</div>
}
if(this.props.collapsed){
boxType = "collapsed-box"
}
if(this.props.footer){
footer = <div className="box-footer">{this.props.footer}</div>
}
return (
<div className={"col-md-"+this.props.width+" col-sm-6 col-xs-12"}>
<div className={"box "+this.props.theme+" "+borderClass+ " color-palette-box "+boxType}>
<div className="box-header with-border">
<h3 className="box-title">{this.props.headerMarkup} {this.props.title}</h3>
{boxToolsContainer}
</div>
<div className="box-body">
{this.props.content}
{this.props.children}
</div>
{footer}
{/* /.box-body */}
{loadingState}
</div>
</div>
)
}
});
return Box;
}
)