import React from 'react'; import marked from 'marked'; import {WordForm} from './WordForm'; import {Button} from './Button'; const saveIcon = 💾; const editIcon = 🖉; export class Word extends React.Component { constructor(props) { super(props); this.state = { editWord: false, editName: false, editPronunciation: false, editPartOfSpeech: false, editSimpleDefinition: false, editLongDefinition: false }; } /* { name: word, pronunciation: pronunciation, partOfSpeech: ((partOfSpeech.length > 0) ? partOfSpeech : " "), simpleDefinition: simpleDefinition, longDefinition: longDefinition, wordId: currentDictionary.nextWordId++ } */ showName() { return (
{this.props.name}
); } showPronunciation() { if (this.props.pronunciation !== '') { return (
{this.props.pronunciation}
); } } showPartOfSpeech() { if (this.props.partOfSpeech !== '') { return (
{this.props.partOfSpeech}
); } } showSimpleDefinition() { if (this.props.simpleDefinition !== '') { return (
{this.props.simpleDefinition}
); } } showLongDefinition() { if (this.props.longDefinition !== '') { return (
); } } showWordOrEdit() { if (this.state.editWord) { return ( this.updateWord(wordObject)} wordValues={this.packageThisWordIntoObject()} submitLabel='Update' /> ); } else { return (
{this.showName()} {this.showPronunciation()} {this.showPartOfSpeech()}
{this.showSimpleDefinition()} {this.showLongDefinition()}
); } } showManagementArea() { if (this.props.isEditing) { if (this.state.editWord) { return (