diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-08 11:11:01 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-08 11:11:01 -0400 |
commit | 6145a7ef060aeb1b815b2da7acba4d8f9d2e2bdc (patch) | |
tree | b63ceff150fe9e5f7383402a99da8d8f8f31cb05 /src/client/views/ScriptBox.tsx | |
parent | 5ce2d59b4544a7473a910c121daf0c34d1546214 (diff) | |
parent | 400c525875af607dd76d7ec46949fedc418caabf (diff) |
merged with master
Diffstat (limited to 'src/client/views/ScriptBox.tsx')
-rw-r--r-- | src/client/views/ScriptBox.tsx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx new file mode 100644 index 000000000..fa236c2da --- /dev/null +++ b/src/client/views/ScriptBox.tsx @@ -0,0 +1,44 @@ +import * as React from "react"; +import { observer } from "mobx-react"; +import { observable, action } from "mobx"; + +import "./ScriptBox.scss"; + +export interface ScriptBoxProps { + onSave: (text: string, onError: (error: string) => void) => void; + onCancel?: () => void; + initialText?: string; +} + +@observer +export class ScriptBox extends React.Component<ScriptBoxProps> { + @observable + private _scriptText: string; + + constructor(props: ScriptBoxProps) { + super(props); + this._scriptText = props.initialText || ""; + } + + @action + onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { + this._scriptText = e.target.value; + } + + @action + onError = (error: string) => { + console.log(error); + } + + render() { + return ( + <div className="scriptBox-outerDiv"> + <div className="scriptBox-toolbar"> + <button onClick={e => { this.props.onSave(this._scriptText, this.onError); e.stopPropagation(); }}>Save</button> + <button onClick={e => { this.props.onCancel && this.props.onCancel(); e.stopPropagation(); }}>Cancel</button> + </div> + <textarea className="scriptBox-textarea" onChange={this.onChange} value={this._scriptText}></textarea> + </div> + ); + } +}
\ No newline at end of file |