diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-09 19:13:24 -0500 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-09 19:13:24 -0500 |
commit | 11134bc5ce01d0a025d311a4f83e67ff6e63ce1c (patch) | |
tree | e401d8004481b3d664c751ae2e668c72b6be7aac /src/views/EditableView.tsx | |
parent | c06745a99ed85b215d0ae48bfb2af7c955f0b016 (diff) |
Moved client code to client folder
Diffstat (limited to 'src/views/EditableView.tsx')
-rw-r--r-- | src/views/EditableView.tsx | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/views/EditableView.tsx b/src/views/EditableView.tsx deleted file mode 100644 index 2e784d3f9..000000000 --- a/src/views/EditableView.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React = require('react') -import { observer } from 'mobx-react'; -import { observable, action } from 'mobx'; - -export interface EditableProps { - GetValue(): string; - SetValue(value: string): boolean; - contents: any; -} - -@observer -export class EditableView extends React.Component<EditableProps> { - @observable - editing: boolean = false; - - @action - onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { - if (e.key == "Enter" && !e.ctrlKey) { - this.props.SetValue(e.currentTarget.value); - this.editing = false; - } else if (e.key == "Escape") { - this.editing = false; - } - } - - render() { - if (this.editing) { - return <input defaultValue={this.props.GetValue()} onKeyDown={this.onKeyDown} autoFocus onBlur={action(() => this.editing = false)} - style={{ width: "100%" }}></input> - } else { - return ( - <div> - {this.props.contents} - <button onClick={action(() => this.editing = true)}>Edit</button> - </div> - ) - } - } -}
\ No newline at end of file |