0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 04:22:40 +00:00
This commit is contained in:
Scott Tolksdorf
2016-05-16 22:42:22 -04:00
parent daa3b096b3
commit 22a480871b
17 changed files with 484 additions and 8 deletions

View File

@@ -0,0 +1,54 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var utils = require('../utils');
var Box = React.createClass({
mixins : [utils],
getDefaultProps: function() {
return {
//name : 'box',
defaultData : {},
id : '',
title : '',
label : '',
shadow : false,
border : false
};
},
handleChange : function(newData){
this.updateData(newData);
},
renderChildren : function(){
return React.Children.map(this.props.children, (child)=>{
if(!React.isValidElement(child)) return null;
return React.cloneElement(child, {
onChange : this.handleChange,
data : this.data()
})
})
},
renderTitle : function(){
if(this.props.title) return <h5 className='title'>{this.props.title}</h5>
},
renderLabel : function(){
if(this.props.label) return <h5 className='label'>{this.props.label}</h5>
},
render : function(){
return <div className={cx('box', this.props.className, {
shadow : this.props.shadow,
border : this.props.border
})}>
{this.renderTitle()}
{this.renderChildren()}
{this.renderLabel()}
</div>
}
});
module.exports = Box;

View File

@@ -0,0 +1,30 @@
.box{
position : relative;
padding : 10px;
margin: 10px;
&.border{
border: 1px solid black;
}
&.shadow{
background-color: #ddd;
}
h5{
text-transform: uppercase;
font-size : 0.6em;
text-align: center;
width : 100%;
font-weight: 800;
&.title{
margin-top: -5px;
margin-bottom: 10px;
}
&.label{
margin-bottom: -5px;
margin-top: 10px;
}
}
}