diff --git a/client/app/components/editor/editor.scss b/client/app/components/editor/editor.scss index 1d362ef..ee73fa1 100644 --- a/client/app/components/editor/editor.scss +++ b/client/app/components/editor/editor.scss @@ -1,4 +1,4 @@ -.editor-container { +.editor-background { z-index: 1; top: 0; left: 0; @@ -6,43 +6,48 @@ width: 100%; position: fixed; background-color: rgba(0, 0, 0, .9); - padding-top: 50px; + display: flex; + align-items: center; +} + +.editor-container { + height: 100%; + width: 100%; + max-height: 800px; + max-width: 1000px; + padding: 20px 40px 40px; + margin-bottom: 0; } .editor { - height: 80%; - display: flex; - flex-direction: column; - padding-bottom: 40px; - - &__character-count { - align-self: flex-end; - } + overflow-y: auto; + height: 100%; + margin-bottom: 0; &__title { height: 25px; + margin-bottom: 10px; } &__text-area { min-height: 100px; - resize: none; + max-height: 300px; + max-width: 100%; overflow-wrap: break-word; } &__preview { - min-height: 100px; - border-radius: 2px; - padding: 5px 10px; - overflow-y: auto; - overflow-wrap: break-word; + padding: 10px; } &__submit { - padding: 20px 0; + padding: 10px 0; + display: flex; + justify-content: space-between; } &__error-message { - margin-left: 10px; + margin-bottom: 10px; color: red; } } diff --git a/client/app/components/editor/editor.tsx b/client/app/components/editor/editor.tsx index fae057c..95ff3ca 100644 --- a/client/app/components/editor/editor.tsx +++ b/client/app/components/editor/editor.tsx @@ -1,12 +1,15 @@ import React from 'react'; import marked from 'marked'; +import { get } from 'lodash'; import axios from '../../axios/axios'; import { ContentContainer } from '../content-container/content-container'; +import { ReplyModel } from '../../model'; import './editor.scss'; interface Props { categoryId?: string; onClose: (cancel: boolean) => any; + quotedReply?: ReplyModel; threadId?: string; } @@ -15,11 +18,14 @@ interface State { content: string; contentPreview: string; contentCharacterCount: number; - titleCharacterCount: number; errorMessage?: string; } export class Editor extends React.Component { + + private titleRef: any; + private contentRef: any; + constructor(props: any) { super(props); this.state = { @@ -27,10 +33,24 @@ export class Editor extends React.Component { content: '', contentPreview: '', contentCharacterCount: 0, - titleCharacterCount: 0, }; } + // disable scrolling in the background + componentDidMount() { + document.body.style.overflow = 'hidden'; + + if (this.titleRef) { + this.titleRef.focus(); + } else { + this.contentRef.focus(); + } + } + + componentWillUnmount() { + document.body.style.removeProperty('overflow'); + } + onContentChange(event: any) { this.setState({ content: event.target.value, @@ -42,7 +62,6 @@ export class Editor extends React.Component { onTitleChange(event: any) { this.setState({ title: event.target.value, - titleCharacterCount: event.target.value.length, }); } @@ -66,6 +85,7 @@ export class Editor extends React.Component { const data = { content, thread_id: this.props.threadId, + quote_id: get(this.props, 'quotedReply.id') || undefined, }; try { @@ -98,46 +118,61 @@ export class Editor extends React.Component { } } - renderThreadPortion() { + private renderTopicInput(): any { return ( -
-

New Topic

- +
+
this.titleRef = ref} className="input editor__title" onChange={event => this.onTitleChange(event)} maxLength={300}/> -
{this.state.contentCharacterCount}/2000
); } - // TODO: quote - renderReplyPortion() { - return ( -

New Reply

+ renderQuotedReply() { + return (this.props.quotedReply && +
+ Q u o t e: + +
); } render() { - return ( -
-
this.onSubmit(event)} onReset={() => this.props.onClose(true)}> - - {this.props.threadId ? this.renderReplyPortion() : this.renderThreadPortion()} - -