From a5e0deeec1db25c6e917f4ade253ac0bda524532 Mon Sep 17 00:00:00 2001 From: Cláudio Date: Fri, 29 Jan 2021 18:39:19 -0300 Subject: Partial commit for #158 - It´s possible to create new issue with title and first message from webui - form simple validation - Extraction from CommentForm to create a generic component for Comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next steps - Styles - Readme update about codegen usage and enforcing playground usage --- webui/src/pages/bug/CommentInput.tsx | 101 +++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 webui/src/pages/bug/CommentInput.tsx (limited to 'webui/src/pages/bug/CommentInput.tsx') diff --git a/webui/src/pages/bug/CommentInput.tsx b/webui/src/pages/bug/CommentInput.tsx new file mode 100644 index 00000000..cfe50626 --- /dev/null +++ b/webui/src/pages/bug/CommentInput.tsx @@ -0,0 +1,101 @@ +import React, { useState, useRef, useEffect } from 'react'; + +import Button from '@material-ui/core/Button'; +import Paper from '@material-ui/core/Paper'; +import Tab from '@material-ui/core/Tab'; +import Tabs from '@material-ui/core/Tabs'; +import TextField from '@material-ui/core/TextField'; +import { makeStyles, Theme } from '@material-ui/core/styles'; + +import Content from 'src/components/Content'; + +import { useAddCommentMutation } from './CommentForm.generated'; +import { TimelineDocument } from './TimelineQuery.generated'; + +const useStyles = makeStyles((theme) => ({ + container: { + margin: theme.spacing(2, 0), + padding: theme.spacing(0, 2, 2, 2), + }, + textarea: {}, + tabContent: { + margin: theme.spacing(2, 0), + }, + preview: { + borderBottom: `solid 3px ${theme.palette.grey['200']}`, + minHeight: '5rem', + }, + actions: { + display: 'flex', + justifyContent: 'flex-end', + }, +})); + +type TabPanelProps = { + children: React.ReactNode; + value: number; + index: number; +} & React.HTMLProps; +function TabPanel({ children, value, index, ...props }: TabPanelProps) { + return ( + + ); +} + +const a11yProps = (index: number) => ({ + id: `editor-tab-${index}`, + 'aria-controls': `editor-tabpanel-${index}`, +}); + +type Props = { + loading: boolean; + onChange: (comment: string) => void; +}; + +function CommentInput({ loading, onChange }: Props) { + const [input, setInput] = useState(''); + const [tab, setTab] = useState(0); + const classes = useStyles(); + + useEffect(() => { + onChange(input); + }, [input]); + + return ( +
+ setTab(t)}> + + + +
+ + setInput(e.target.value)} + disabled={loading} + /> + + + + +
+
+ ); +} + +export default CommentInput; -- cgit