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,7 +34,9 @@ export class CommentBox extends Component {
} }
render() { render() {
if (this.props.enabled) { let textClass = (this.props.enabled)
? "body-regular-400 w-100"
: "body-regular-400 w-100 gray-30";
return ( return (
<div className="cb w-100 flex" <div className="cb w-100 flex"
style={{paddingBottom: 8, marginTop: 32}}> style={{paddingBottom: 8, marginTop: 32}}>
@ -24,41 +44,21 @@ export class CommentBox extends Component {
<Sigil ship={this.props.our} size={36}/> <Sigil ship={this.props.our} size={36}/>
</div> </div>
<div className="flex-col w-100"> <div className="flex-col w-100">
<textarea className="body-regular-400 w-100" <textarea className={textClass}
ref={(el) => {this.textarea = el}} ref={(el) => {this.textarea = el}}
style={{resize: "none"}} style={{resize: "none"}}
type="text" type="text"
name="commentBody" name="commentBody"
defaultValue='' defaultValue=''
onChange={this.props.action}> onChange={this.props.action}
disabled={(!this.props.enabled)}>
</textarea> </textarea>
<p className="body-regular pointer" onClick={this.props.post}> <PostButton
-> Post post={this.props.post}
</p> enabled={(Boolean(this.props.content) && this.props.enabled)}
/>
</div> </div>
</div> </div>
); );
} else {
return (
<div className="cb w-100 flex"
style={{paddingBottom: 8, marginTop: 32}}>
<div className="fl" style={{marginRight: 10}}>
<Sigil ship={this.props.our} size={36}/>
</div>
<div className="flex-col w-100">
<textarea className="body-regular-400 w-100"
ref={(el) => {this.textarea = el}}
style={{resize: "none"}}
type="text"
name="commentBody"
disabled={true}>
</textarea>
<p className="body-regular gray-50">
-> Post
</p>
</div>
</div>
);
}
} }
} }