react-components-library
Version:
replace 'onBrowserComplete' on karma-coverage with
77 lines (62 loc) • 1.93 kB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
;
var React = require('react');
var classNames = require('classnames');
var Card = React.createClass({
displayName: 'Card',
propTypes: {
depth: React.PropTypes.oneOf([0, 1, 2, 3]),
headerContent: React.PropTypes.node,
footerContent: React.PropTypes.node
},
getDefaultProps: function getDefaultProps() {
return {
depth: 0
};
},
render: function render() {
return React.createElement(
'div',
{ className: this.getClass() },
this.renderCardHeader(),
this.renderCardContent(),
this.renderCardFooter()
);
},
renderCardHeader: function renderCardHeader() {
return React.createElement(
'div',
{ className: 'card--header' },
this.props.headerContent
);
},
renderCardContent: function renderCardContent() {
return React.createElement(
'div',
{ className: 'card--content' },
this.props.children
);
},
renderCardFooter: function renderCardFooter() {
return React.createElement(
'div',
{ className: 'card--footer' },
this.props.footerContent
);
},
getClass: function getClass() {
var depth = this.props.depth;
var classes = {
'card': true,
'card_depth-0': depth === 0,
'card_depth-1': depth === 1,
'card_depth-2': depth === 2,
'card_depth-3': depth === 3
};
classes[this.props.className] = this.props.className;
return classNames(classes);
}
});
module.exports = Card;