From 838fe784f184d14741d21924195ed373714fb09a Mon Sep 17 00:00:00 2001 From: James Morris Date: Thu, 7 Jul 2022 15:24:10 +0200 Subject: [PATCH] Little tweaks for better add and reply forms --- apps/comments-ui/src/components/AddForm.js | 4 +-- apps/comments-ui/src/components/Comment.js | 17 +++++++--- apps/comments-ui/src/components/ReplyForm.js | 34 ++++++++------------ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/apps/comments-ui/src/components/AddForm.js b/apps/comments-ui/src/components/AddForm.js index 286d8bb789..8aacd9ae09 100644 --- a/apps/comments-ui/src/components/AddForm.js +++ b/apps/comments-ui/src/components/AddForm.js @@ -1,6 +1,5 @@ -// import React, {useState} from 'react'; -import {Transition} from '@headlessui/react'; import React, {useContext, useState} from 'react'; +import {Transition} from '@headlessui/react'; import AppContext from '../AppContext'; import Avatar from './Avatar'; @@ -18,7 +17,6 @@ const AddForm = (props) => { event.preventDefault(); if (message.length === 0) { - // alert('Please enter a message'); TODO: Check, but don't think we really need this return; } diff --git a/apps/comments-ui/src/components/Comment.js b/apps/comments-ui/src/components/Comment.js index 46cd5f6de5..baf4f2794b 100644 --- a/apps/comments-ui/src/components/Comment.js +++ b/apps/comments-ui/src/components/Comment.js @@ -1,5 +1,5 @@ -import {formatRelativeTime} from '../utils/helpers'; import React, {useContext, useState} from 'react'; +import {Transition} from '@headlessui/react'; import Avatar from './Avatar'; import Like from './Like'; import Reply from './Reply'; @@ -8,6 +8,7 @@ import EditForm from './EditForm'; import Replies from './Replies'; import ReplyForm from './ReplyForm'; import AppContext from '../AppContext'; +import {formatRelativeTime} from '../utils/helpers'; const Comment = (props) => { const [isInEditMode, setIsInEditMode] = useState(false); @@ -63,11 +64,19 @@ const Comment = (props) => { - {isInReplyMode && -
+ +
- } +
{hasReplies &&
diff --git a/apps/comments-ui/src/components/ReplyForm.js b/apps/comments-ui/src/components/ReplyForm.js index a3b49aed84..0da6b75988 100644 --- a/apps/comments-ui/src/components/ReplyForm.js +++ b/apps/comments-ui/src/components/ReplyForm.js @@ -5,7 +5,7 @@ import Avatar from './Avatar'; const ReplyForm = (props) => { const [message, setMessage] = useState(''); const [focused, setFocused] = useState(false); - const {member, postId, dispatchAction} = useContext(AppContext); + const {postId, dispatchAction} = useContext(AppContext); const getHTML = () => { // Convert newlines to
for now (until we add a real editor) @@ -47,7 +47,7 @@ const ReplyForm = (props) => { const handleBlur = (event) => { if (message === '') { - setFocused(false); + props.toggle(); } }; @@ -56,37 +56,29 @@ const ReplyForm = (props) => { }; return ( -
-
-
- -
-

{member.name}

-
Now
-
-
+ +