import Inferno from 'inferno'; import Component from 'inferno-component'; import PropTypes from 'prop-types'; import { LeftColumn } from './structure/LeftColumn'; import { RightColumn } from './structure/RightColumn'; import { WordForm } from './management/WordForm'; import { DictionaryDetails } from './display/DictionaryDetails'; import { WordsList } from './display/WordsList'; export class MainDisplay extends Component { constructor (props) { super(props); PropTypes.checkPropTypes({ dictionaryInfo: PropTypes.object.isRequired, wordsToDisplay: PropTypes.array.isRequired, wordsAreFiltered: PropTypes.bool, updateDisplay: PropTypes.func.isRequired, updater: PropTypes.object.isRequired, }, props, 'prop', 'MainDisplay'); this.state = { isMobile: false, wordFormIsOpen: true, }; } openWordForm () { this.setState({ wordFormIsOpen: true }); } closeWordForm () { this.setState({ wordFormIsOpen: false }); } checkIsMobile () { this.setState({ isMobile: window.innerWidth < 769 }); } componentDidMount () { window.addEventListener('resize', this.checkIsMobile.bind(this)); } componentWillUnmount () { window.removeEventListener('resize'); } render () { const { dictionaryInfo, wordsToDisplay, wordsAreFiltered, updateDisplay, updater, } = this.props; const { isMobile, wordFormIsOpen } = this.state; const wordFormIsDisabled = dictionaryInfo.settings.isComplete; return (
{wordsAreFiltered && (
Words are filtered—displaying {wordsToDisplay.length} word{wordsToDisplay.length !== 1 && 's'}
)}
); } }