fleet/frontend/components/StackedWhiteBoxes/StackedWhiteBoxes.jsx
2016-11-03 14:40:54 -05:00

63 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import classnames from 'classnames';
class StackedWhiteBoxes extends Component {
static propTypes = {
children: PropTypes.element,
headerText: PropTypes.string,
className: PropTypes.string,
leadText: PropTypes.string,
previousLocation: PropTypes.string,
};
renderBackButton = () => {
const { previousLocation } = this.props;
const baseClass = 'stack-box-back';
if (!previousLocation) return false;
return (
<div className={baseClass}>
<Link to={previousLocation} className={`${baseClass}__link`}></Link>
</div>
);
}
renderHeader = () => {
const { headerText, className } = this.props;
const baseClass = 'stacked-box-header';
const boxHeaderClass = classnames(
baseClass,
className
);
return (
<div className={boxHeaderClass}>
<p className={`${baseClass}__text`}>{headerText}</p>
</div>
);
}
render () {
const { children, leadText } = this.props;
const { renderBackButton, renderHeader } = this;
const baseClass = 'stacked-white-boxes';
return (
<div className={baseClass}>
<div className={`${baseClass}__box`}>
{renderBackButton()}
{renderHeader()}
<p className={`${baseClass}__text`}>{leadText}</p>
{children}
</div>
</div>
);
}
}
export default StackedWhiteBoxes;