import React from 'react' import Checkmark from './svg/Checkmark' import { COLORS } from '../lib/constants' class ListSetting extends React.Component { constructor(props) { super(props) this.state = { isVisible: false } this.select = this.select.bind(this) this.toggle = this.toggle.bind(this) } select(item) { if (this.props.selected !== item) { this.props.onChange(item) } } toggle() { this.setState({ isVisible: !this.state.isVisible }) } renderListItems() { return this.props.items.map(item => (
{this.props.children(item)} {this.props.selected === item.id ? : null}
)) } render() { const selectedItem = this.props.items.filter(item => item.id === this.props.selected)[0] || {} return (
{this.props.title} {this.props.children(selectedItem)}
{this.renderListItems()}
) } } export default ListSetting