Files
optolith-client/js/components/Collapse.js
T
Lukas Obermann e1927227bf Changed data objects to ES6 classes
Additionally changed folder structure to components and views
2016-11-14 00:18:09 +01:00

38 lines
839 B
JavaScript

import React, { Component, PropTypes } from 'react';
import classNames from 'classnames';
class Collapse extends Component {
static propTypes = {
className: PropTypes.any,
expanded: PropTypes.bool.isRequired,
height: PropTypes.any,
switch: PropTypes.func.isRequired,
title: PropTypes.string.isRequired
};
static defaultProps = {
height: 'auto'
};
render() {
const className = classNames('collapse', this.props.expanded && 'expanded', this.props.className);
const style = this.props.expanded ? { height: this.props.height } : null;
return (
<div className={className} style={style}>
<div className="collapse-header" onClick={this.props.switch}>
{this.props.title}
</div>
<div className="collapse-content">
{this.props.children}
</div>
</div>
);
}
}
export default Collapse;