import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames/bind'; import { Card } from 'coral-ui'; import { Checkbox, IconButton } from 'react-mdl'; import styles from './ConfigureCard.css'; const cn = classnames.bind(styles); class ConfigureCard extends PureComponent { state = { isOpen: !this.props.collapsible, }; toggle = () => this.setState({ isOpen: !this.state.isOpen }); render() { const { title, children, className, onCheckbox, checked, collapsible, ...rest } = this.props; const { isOpen } = this.state; const iconName = isOpen ? 'keyboard_arrow_up' : 'keyboard_arrow_down'; return ( {checked !== undefined && (
)}
{title}
{collapsible && ( )}
{isOpen && (
{children}
)}
); } } ConfigureCard.propTypes = { title: PropTypes.string, className: PropTypes.string, onCheckbox: PropTypes.func, checked: PropTypes.bool, children: PropTypes.node, collapsible: PropTypes.bool, }; export default ConfigureCard;