From d07b86a98df472959054a1f74e1cb2a0fba66f46 Mon Sep 17 00:00:00 2001 From: Glen Wider Date: Tue, 18 May 2021 16:24:49 +0200 Subject: [PATCH] remove onSubmit from CodeLine.tsx --- src/components/CodeLine.tsx | 111 +++++++++++++++----------------- src/components/CodeReview.tsx | 6 +- src/components/ShortcutMenu.tsx | 7 +- 3 files changed, 57 insertions(+), 67 deletions(-) diff --git a/src/components/CodeLine.tsx b/src/components/CodeLine.tsx index 24dc24b..2b605f3 100644 --- a/src/components/CodeLine.tsx +++ b/src/components/CodeLine.tsx @@ -1,4 +1,4 @@ -import React, {CSSProperties, useEffect, useState} from 'react' +import React, { CSSProperties, useEffect, useState } from 'react' import { Line, LineContent, LineNo } from './styles' import { Button } from 'antd' import { @@ -21,7 +21,19 @@ import ReplyEditor from './ReplyEditor' import BorderWrapper from './BorderWrapper' const annotationStyle: CSSProperties = { - paddingLeft: "0.15em" + paddingLeft: '0.15em' +} + +const newCommentStyle: CSSProperties = { + display: 'flex', + flexDirection: 'column', + paddingTop: '0.5em', + paddingBottom: '0.5em', + border: '1px solid #d9d9d9', + borderRadius: '0 2px 15px 0', + paddingLeft: '1.1em', + paddingRight: '0.5em', + marginLeft: 0 } export interface CodeLineProps { @@ -29,9 +41,8 @@ export interface CodeLineProps { lineNo: number getLineProps: (input: LineInputProps) => LineOutputProps getTokenProps: (input: TokenInputProps) => TokenOutputProps - onSubmit: (value: string) => void comments: CustomComment[] - onReplyCreated: (value: string) => void + onCommentCreated: (value: string) => void onCommentEdited: ( oldComment: CustomComment, newComment: CustomComment @@ -49,9 +60,8 @@ export const CodeLine: React.FC = ({ lineNo, getLineProps, getTokenProps, - onSubmit, comments, - onReplyCreated, + onCommentCreated, showComments, active, onToggle, @@ -60,14 +70,11 @@ export const CodeLine: React.FC = ({ onCommentDeleted, role }) => { - // isAddButtonShown manages visibility of addButton const [isAddButtonShown, setIsAddButtonShown] = useState(false) const lineNoRef = React.createRef() const [isEditorShown, setIsEditorShown] = useState(false) const [commentThread, setCommentThread] = useState() - const [mildInfo, setMildInfo] = useState( - comments.map(element => element.type).includes('mildInfo') - ) + const [mildInfo, setMildInfo] = useState() // check what kind of comments are present to manage annotations useEffect(() => { @@ -86,7 +93,7 @@ export const CodeLine: React.FC = ({ // prevent awkward border placements when showComments gets toggled useEffect(() => { - if(!showComments) { + if (!showComments) { handleMouseLeave() } }, [showComments]) @@ -102,18 +109,17 @@ export const CodeLine: React.FC = ({ if (commentThread && mildInfo) { return 0.2 } - return 2.8 } // show addButton and adjust padding accordingly const handleMouseEnter = () => { if ( - !commentThread && - !mildInfo && - lineNoRef.current && - showComments && - !isEditorShown + !commentThread && + !mildInfo && + lineNoRef.current && + showComments && + !isEditorShown ) { lineNoRef.current.style.paddingLeft = getPaddingLeft() - 1.3 + getPaddingLeftOffset() + 'em' @@ -159,8 +165,8 @@ export const CodeLine: React.FC = ({ return (
handleMouseEnter()} - onMouseLeave={() => handleMouseLeave()} + onMouseEnter={() => handleMouseEnter()} + onMouseLeave={() => handleMouseLeave()} > = ({ display: 'table-row' }} > - {isAddButtonShown && showComments && ( - <> -