disallow empty comments

This commit is contained in:
Isaac Visintainer 2019-06-25 16:55:41 -07:00
parent 553f1f4afa
commit 2a26757a98
2 changed files with 43 additions and 42 deletions

View File

@ -83,6 +83,7 @@ export class Comments extends Component {
<CommentBox our={our} <CommentBox our={our}
action={this.commentChange} action={this.commentChange}
enabled={!(Boolean(this.state.awaiting))} enabled={!(Boolean(this.state.awaiting))}
content={this.state.commentBody}
post={this.postComment}/> post={this.postComment}/>

View File

@ -2,6 +2,24 @@ import React, { Component } from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import { Sigil } from '/components/lib/icons/sigil'; import { Sigil } from '/components/lib/icons/sigil';
class PostButton extends Component {
render() {
if (this.props.enabled) {
return (
<p className="body-regular pointer" onClick={this.props.post}>
-> Post
</p>
);
} else {
return (
<p className="body-regular gray-30">
-> Post
</p>
);
}
}
}
export class CommentBox extends Component { export class CommentBox extends Component {
constructor(props){ constructor(props){
super(props); super(props);
@ -16,49 +34,31 @@ export class CommentBox extends Component {
} }
render() { render() {
if (this.props.enabled) { let textClass = (this.props.enabled)
return ( ? "body-regular-400 w-100"
<div className="cb w-100 flex" : "body-regular-400 w-100 gray-30";
style={{paddingBottom: 8, marginTop: 32}}> return (
<div className="fl" style={{marginRight: 10}}> <div className="cb w-100 flex"
<Sigil ship={this.props.our} size={36}/> style={{paddingBottom: 8, marginTop: 32}}>
</div> <div className="fl" style={{marginRight: 10}}>
<div className="flex-col w-100"> <Sigil ship={this.props.our} size={36}/>
<textarea className="body-regular-400 w-100"
ref={(el) => {this.textarea = el}}
style={{resize: "none"}}
type="text"
name="commentBody"
defaultValue=''
onChange={this.props.action}>
</textarea>
<p className="body-regular pointer" onClick={this.props.post}>
-> Post
</p>
</div>
</div> </div>
); <div className="flex-col w-100">
} else { <textarea className={textClass}
return ( ref={(el) => {this.textarea = el}}
<div className="cb w-100 flex" style={{resize: "none"}}
style={{paddingBottom: 8, marginTop: 32}}> type="text"
<div className="fl" style={{marginRight: 10}}> name="commentBody"
<Sigil ship={this.props.our} size={36}/> defaultValue=''
</div> onChange={this.props.action}
<div className="flex-col w-100"> disabled={(!this.props.enabled)}>
<textarea className="body-regular-400 w-100" </textarea>
ref={(el) => {this.textarea = el}} <PostButton
style={{resize: "none"}} post={this.props.post}
type="text" enabled={(Boolean(this.props.content) && this.props.enabled)}
name="commentBody" />
disabled={true}>
</textarea>
<p className="body-regular gray-50">
-> Post
</p>
</div>
</div> </div>
); </div>
} );
} }
} }