From 098a2ab3d3d50977bc385ea861890c8e4c11da0b Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 14 Feb 2019 14:35:58 -0800 Subject: [PATCH] get rid of the keypress charcode 13 stuff --- index.html | 1 + step2-02/README.md | 13 ++--- step2-02/src/components/TodoHeader.tsx | 48 +++++++++--------- step2-02/src/components/TodoListItem.tsx | 63 +++++++++++++----------- 4 files changed, 65 insertions(+), 60 deletions(-) diff --git a/index.html b/index.html index 2c4ace3..d855a4e 100644 --- a/index.html +++ b/index.html @@ -11,5 +11,6 @@ Step 9

Day 2

Step 1 + Step 2 Playground diff --git a/step2-02/README.md b/step2-02/README.md index e775930..430fbea 100644 --- a/step2-02/README.md +++ b/step2-02/README.md @@ -1,8 +1,9 @@ -# Step 2.1 +# Step 2.2 -Typescript +Integrates Fabric -- modules -- a look at types -- defining interfaces -- +Learn about Basic Components + +- Stack +- Text +- Show case some components diff --git a/step2-02/src/components/TodoHeader.tsx b/step2-02/src/components/TodoHeader.tsx index 923d29b..fb6aef3 100644 --- a/step2-02/src/components/TodoHeader.tsx +++ b/step2-02/src/components/TodoHeader.tsx @@ -19,7 +19,30 @@ export class TodoHeader extends React.Component) => { + render() { + return ( + + + todos + + + + + + + Add + + + + + + + + + ); + } + + private onAdd = () => { this.props.addTodo(this.state.labelInput); this.setState({ labelInput: undefined }); }; @@ -31,27 +54,4 @@ export class TodoHeader extends React.Component { this.props.setFilter(item.props.headerText as FilterTypes); }; - - render() { - return ( - - - todos - - - - - - Add - - - - - - - - - - ); - } } diff --git a/step2-02/src/components/TodoListItem.tsx b/step2-02/src/components/TodoListItem.tsx index 42face0..e2d7909 100644 --- a/step2-02/src/components/TodoListItem.tsx +++ b/step2-02/src/components/TodoListItem.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Stack } from '@uifabric/experiments'; -import { Checkbox, IconButton, TextField } from 'office-ui-fabric-react'; +import { Checkbox, IconButton, TextField, DefaultButton } from 'office-ui-fabric-react'; import { mergeStyles } from '@uifabric/styling'; import { Store } from '../store'; @@ -37,34 +37,6 @@ export class TodoListItem extends React.Component { - const { todos, id } = this.props; - const { label } = todos[id]; - - this.setState(prevState => ({ - editing: true, - editLabel: prevState.editLabel || label - })); - }; - - onDoneEdit = () => { - this.props.edit(this.props.id, this.state.editLabel); - this.setState(prevState => ({ - editing: false, - editLabel: undefined - })); - }; - - onKeyDown = (evt: React.KeyboardEvent) => { - if (evt.which === 13) { - this.onDoneEdit(); - } - }; - - onChange = (evt: React.FormEvent, newValue: string) => { - this.setState({ editLabel: newValue }); - }; - render() { const { todos, id, complete, remove } = this.props; const item = todos[id]; @@ -81,8 +53,39 @@ export class TodoListItem extends React.Component )} - {this.state.editing && } + {this.state.editing && ( + + + + + + Save + + + )} ); } + + private onEdit = () => { + const { todos, id } = this.props; + const { label } = todos[id]; + + this.setState({ + editing: true, + editLabel: this.state.editLabel || label + }); + }; + + private onDoneEdit = () => { + this.props.edit(this.props.id, this.state.editLabel); + this.setState({ + editing: false, + editLabel: undefined + }); + }; + + private onChange = (evt: React.FormEvent, newValue: string) => { + this.setState({ editLabel: newValue }); + }; }