From e1ce5455beb79db88cb7a0bd4207c8a156a06c4e Mon Sep 17 00:00:00 2001 From: AmosChong Date: Thu, 10 Nov 2022 12:41:39 +0800 Subject: [PATCH 1/3] Added leave a comment component --- .../ui/components/comment/Comment.stories.tsx | 18 +++++ packages/ui/components/comment/Comment.tsx | 68 +++++++++++++++++++ packages/ui/components/comment/index.tsx | 1 + packages/ui/package.json | 5 +- yarn.lock | 10 +++ 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 packages/ui/components/comment/Comment.stories.tsx create mode 100644 packages/ui/components/comment/Comment.tsx create mode 100644 packages/ui/components/comment/index.tsx diff --git a/packages/ui/components/comment/Comment.stories.tsx b/packages/ui/components/comment/Comment.stories.tsx new file mode 100644 index 00000000..7c6eaba7 --- /dev/null +++ b/packages/ui/components/comment/Comment.stories.tsx @@ -0,0 +1,18 @@ +import React from "react"; +import { Comment } from "./Comment"; +import { ComponentStory, ComponentMeta } from "@storybook/react"; + +export default { + title: 'Components/Comment', + component: Comment, + argTypes: { + + } +} as ComponentMeta; + +const Template: ComponentStory = (args) => + +export const Default = Template.bind({}); +Default.args = { + +}; \ No newline at end of file diff --git a/packages/ui/components/comment/Comment.tsx b/packages/ui/components/comment/Comment.tsx new file mode 100644 index 00000000..29192a0e --- /dev/null +++ b/packages/ui/components/comment/Comment.tsx @@ -0,0 +1,68 @@ +import { + FormControl, + FormLabel, + Heading, + AlertIcon, + AlertDescription, + Flex, + Input, + Alert, + Textarea, + Box, + Button +} from "@chakra-ui/react"; +import { useState } from "react"; +import "@fontsource/inter"; +import "@fontsource/inder"; + +export interface CommentProps {} + +interface commentType { + name: string, + email: string, + comment: string +} + +export const Comment = (_props: CommentProps) => { + const [commentData, setCommentData] = useState({ name: '', email: '', comment: '' }) + const [showAlert, setShowAlert] = useState(false); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + setCommentData({ name: '', email: '', comment: '' }); + setShowAlert(true); + } + + return ( + + {showAlert ? ( + + The comment has been posted! + ) : } + Leave a comment + Your email address will not be published. Required fields are marked * + +
+ + + + Name * + {setCommentData({ ...commentData, name: e.target.value })}} /> + + + Email * + {setCommentData({ ...commentData, email: e.target.value })}} /> + + + Comment * +