From 5a9e14a7df23cbdd369100bd75eb61e3d29459f8 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 3 Nov 2016 12:49:38 -0600 Subject: [PATCH] More comments and comma-first notation. Slowly but surely... --- src/components/Checkbox.jsx | 8 +++----- src/components/Dictionary.jsx | 21 ++++++++++++--------- src/components/EditDictionaryForm.jsx | 21 ++++++++++++--------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/components/Checkbox.jsx b/src/components/Checkbox.jsx index 4858351..c1d16c8 100644 --- a/src/components/Checkbox.jsx +++ b/src/components/Checkbox.jsx @@ -1,19 +1,17 @@ import React from 'react'; import {Input} from './Input'; -import {Button} from './Button'; - export class Checkbox extends Input { constructor(props) { super(props); this.state = { - value: props.value || false, - isDisabled: props.isDisabled || false + value: props.value || false + , isDisabled: props.isDisabled || false }; } - // Whenever the input changes we update the value state of this component + // Whenever the input changes, update the value state of this component handleOnChange(event) { this.setState({ value: event.target.checked diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index 0408465..755cfed 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -1,24 +1,27 @@ import React from 'react'; import {Word} from './Word'; -import {Button} from './Button'; +// A component for showing just the list of words provided to it as a prop. export class Dictionary extends React.Component { constructor(props) { super(props); } + // Take the word list, given as a component prop, map its values to a Word component, and return it in a div tag. showWords() { if (this.props.words.length > 0) { let words = this.props.words.map((word) => { - return this.props.updateWord(wordId, wordObject)} />; + return ( + this.props.updateWord(wordId, wordObject)} /> + ); }); return
{words}
; diff --git a/src/components/EditDictionaryForm.jsx b/src/components/EditDictionaryForm.jsx index c730089..868f30f 100644 --- a/src/components/EditDictionaryForm.jsx +++ b/src/components/EditDictionaryForm.jsx @@ -6,6 +6,7 @@ import {Checkbox} from './Checkbox'; import {Button} from './Button'; import {FixedPage} from './FixedPage'; +// A component that allows you to edit the dictionary's details and settings. export class EditDictionaryForm extends React.Component { constructor(props) { super(props); @@ -21,20 +22,22 @@ export class EditDictionaryForm extends React.Component { this.isPublicField = null; } + // Pass the changes to the saveChanges function provided in the component props. saveOnClose() { this.props.saveChanges({ - name: this.nameField.state.value, - listTypeName: this.listTypeNameField.state.value, - description: this.descriptionField.state.value, - partsOfSpeech: this.partsOfSpeechField.state.value, - allowDuplicates: this.allowDuplicatesField.state.value, - caseSensitive: this.caseSensitiveField.state.value, - sortByEquivalent: this.sortByEquivalentField.state.value, - isComplete: this.isCompleteField.state.value, - isPublic: this.isPublicField.state.value + name: this.nameField.state.value + , listTypeName: this.listTypeNameField.state.value + , description: this.descriptionField.state.value + , partsOfSpeech: this.partsOfSpeechField.state.value + , allowDuplicates: this.allowDuplicatesField.state.value + , caseSensitive: this.caseSensitiveField.state.value + , sortByEquivalent: this.sortByEquivalentField.state.value + , isComplete: this.isCompleteField.state.value + , isPublic: this.isPublicField.state.value }); } + // Displays the form inside of a FixedPage component, which provides a button to click before displaying its contents. render() { return ( this.saveOnClose()}>