import React from 'react' import Checkmark from './svg/Checkmark' import { COLORS, FONTS } from '../lib/constants' export default class extends React.Component { constructor(props) { super() this.state = { isVisible: false } this.select = this.select.bind(this) this.toggle = this.toggle.bind(this) } select(fontId) { if (this.props.selected !== fontId) { this.props.onChange(fontId) } } toggle() { this.setState({ isVisible: !this.state.isVisible }) } renderListItems() { return FONTS.map((font, i) => (
{font.name} {this.props.selected === font.id ? : null}
)) } render() { const selectedFont = FONTS.filter(font => font.id === this.props.selected)[0] || {} return (
Font family {selectedFont.name}
{this.renderListItems()}
) } }