Skip to content

Commit

Permalink
댓글 모듈 UI 구현
Browse files Browse the repository at this point in the history
commit 5e11f0c
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 18:16:20 2021 +0900

    feat: CommentArea 컴포넌트 생성 및 스토리북 작성

commit dc81e5e
Author: zereight <[email protected]>
Date:   Fri Jul 9 17:57:30 2021 +0900

    feat: CommentInput 컴포넌트 생성 및 스토리북 작성

commit 465d069
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 17:20:10 2021 +0900

    feat: CommentList 컴포넌트 생성 및 스토리북 작성

    Co-authored-by: zereight <[email protected]>

commit 49b23d0
Author: zereight <[email protected]>
Date:   Fri Jul 9 16:27:12 2021 +0900

    feat: CommentOption 컴포넌트 생성 및 스토리북 작성

    Co-authored-by: Kiyung Kim <[email protected]>

commit f235c3e
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 12:08:39 2021 +0900

    feat: Comment 컴포넌트 생성 및 스토리북 작성

commit cd48227
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 12:08:20 2021 +0900

    refactor: Comment 컴포넌트 이름을 CommentTextBox로 변경

commit 4cc09bf
Author: zereight <[email protected]>
Date:   Fri Jul 9 11:28:33 2021 +0900

    feat: Avatar 컴포넌트 생성 및 스토리북 작성

commit b537a65
Author: zereight <[email protected]>
Date:   Fri Jul 9 11:26:13 2021 +0900

    feat: Comment 컴포넌트 생성 및 스토리북 작성

commit 1760794
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 10:50:15 2021 +0900

    feat: SubmitButton 컴포넌트 생성 및 스토리북 작성

commit 766ce29
Author: yungo1846 <[email protected]>
Date:   Fri Jul 9 10:39:45 2021 +0900

    feat: GlobalStyles 적용

    Co-authored-by: zereight <[email protected]>
  • Loading branch information
yungo1846 committed Jul 9, 2021
1 parent 21b5dcb commit e8e9008
Show file tree
Hide file tree
Showing 38 changed files with 709 additions and 16 deletions.
12 changes: 3 additions & 9 deletions frontend/reply-module/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
]
}
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"]
};
4 changes: 4 additions & 0 deletions frontend/reply-module/.storybook/preview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#root {
width: 100%;
max-width: 1080px;
}
22 changes: 18 additions & 4 deletions frontend/reply-module/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import { configure, addDecorator } from "@storybook/react";
import GlobalStyles from "../src/styles/GlobalStyles";
import "./preview.css";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
layout: "centered",
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
date: /Date$/
}
}
};

addDecorator(style => (
<>
<GlobalStyles />
<>{style()}</>
</>
));

configure(require.context("../src", true, /\.stories\.js?$/), module);
2 changes: 1 addition & 1 deletion frontend/reply-module/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const App = () => {
return <>Hello World</>;
return null;
};

export default App;
3 changes: 3 additions & 0 deletions frontend/reply-module/src/assets/svg/three-dots.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Story } from "@storybook/react";
import Avatar, { Props } from ".";

export default {
title: "atoms/Avatar",
component: Avatar,
argTypes: { children: { control: "text" } }
};

const Template: Story<Props> = args => <Avatar {...args} />;

export const Default = Template.bind({});

Default.args = {
imageURL: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBUWFRgVFRUZGBgYGBgaGhgYHBgYGBkZGBgZGRgYGBgcIS4lHB4rHxgYJjgmKy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NZZE3E9eSpffxZ6anhvLiym0OF4+i2/JHROa2AkuriG+UOiXSE8BO0qoYhOhIipEAoQiHAolCFAak4IQgRLCEKgSoQgSZStSIQKQhCECQlQhAJEIQCEIQCEIQBKJQhAhK5nMswfQqPJALYJAEztJmebIQsdfF5+qBzkV6DjpIDpsY2jlIzMfQHQY0zHyQhc/wBtszJM2FT+2GneDMRE9l39FsAeyRC6cs9JEIQtoUFIEIRAhCEH/9k="
};
14 changes: 14 additions & 0 deletions frontend/reply-module/src/components/atoms/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Container } from "./styles";

export type Size = "SM" | "MD" | "LG";

export interface Props {
imageURL: string;
size?: Size;
}

const Avatar = ({ imageURL, size = "MD" }: Props) => {
return <Container src={imageURL} size={size} />;
};

export default Avatar;
17 changes: 17 additions & 0 deletions frontend/reply-module/src/components/atoms/Avatar/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from "styled-components";

import { Size } from ".";

const avatarSizeBySize = {
SM: 30,
MD: 40,
LG: 90
};

const Container = styled.img<{ size: Size }>`
border-radius: 50%;
width: ${props => `${avatarSizeBySize[props.size]}px`};
height: ${props => `${avatarSizeBySize[props.size]}px`};
`;

export { Container };
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Story } from "@storybook/react";
import CommentOption, { Props } from ".";

export default {
title: "atoms/CommentOption",
component: CommentOption,
argTypes: { children: { control: "text" } }
};

const Template: Story<Props> = args => <CommentOption {...args} />;

export const Default = Template.bind({});

Default.args = {};
29 changes: 29 additions & 0 deletions frontend/reply-module/src/components/atoms/CommentOption/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useState } from "react";
import threeDots from "../../../assets/svg/three-dots.svg";
import { Container, DeleteButton, EditButton, OptionContainer, OptionIcon } from "./styles";

export interface Props {
onEdit?: () => void;
onDelete?: () => void;
}

const CommentOption = ({ onEdit, onDelete }: Props) => {
const [isShowOptionBox, setShowOptionBox] = useState(false);
const onShowOptionBox = () => {
setShowOptionBox(state => !state);
};

return (
<Container>
<OptionIcon src={threeDots} alt="댓글 옵션" onClick={onShowOptionBox} />
{isShowOptionBox && (
<OptionContainer>
<EditButton type="button">수정</EditButton>
<DeleteButton type="button">삭제</DeleteButton>
</OptionContainer>
)}
</Container>
);
};

export default CommentOption;
63 changes: 63 additions & 0 deletions frontend/reply-module/src/components/atoms/CommentOption/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import styled from "styled-components";
import { PALETTE } from "../../../styles/palette";

const Container = styled.div`
position: absolute;
`;

const OptionIcon = styled.img`
cursor: pointer;
`;

const OptionContainer = styled.div`
position: absolute;
right: -5px;
width: 6rem;
box-shadow: 1.04082px 1.04082px 6.24491px rgba(0, 0, 0, 0.25);
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
background-color: ${PALETTE.WHITE};
::before {
content: "";
position: absolute;
top: -5px;
right: 8px;
border-bottom: 10px solid ${PALETTE.WHITE};
border-left: 5px solid transparent;
border-right: 5px solid transparent;
}
& > button {
width: 100%;
border: none;
outline: none;
background-color: ${PALETTE.WHITE};
cursor: pointer;
font-weight: 600;
margin-bottom: 0.3rem;
:first-child {
padding-top: 0.5rem;
border-radius: 10px 10px 0 0;
}
:last-child {
margin-bottom: 0;
padding-bottom: 0.5rem;
border-radius: 0 0 10px 10px;
}
}
`;

const EditButton = styled.button`
color: ${PALETTE.BLACK_700};
`;
const DeleteButton = styled.button`
color: ${PALETTE.RED_600};
`;

export { Container, OptionIcon, OptionContainer, EditButton, DeleteButton };
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Story } from "@storybook/react";
import CommentTextBox, { Props } from ".";

export default {
title: "atoms/CommentTextBox",
component: CommentTextBox,
argTypes: { children: { control: "text" } }
};

const Template: Story<Props> = args => <CommentTextBox {...args} />;

export const Default = Template.bind({});

Default.args = {
name: "곤이",
contentEditable: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Container, Name, Text } from "./styles";

export interface Props {
name: string;
children: string;
contentEditable?: boolean;
}

const CommentTextBox = ({ name, children, contentEditable = false }: Props) => {
return (
<Container>
<Name>{name}</Name>
<Text contentEditable={contentEditable}>{children}</Text>
</Container>
);
};

export default CommentTextBox;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import styled from "styled-components";
import { PALETTE } from "../../../styles/palette";

const Container = styled.div`
width: 100%;
background-color: ${PALETTE.GRAY_200};
border-radius: 10px;
padding: 0.8rem 1rem;
display: flex;
flex-direction: column;
`;

const Name = styled.span`
font-weight: 700;
font-size: 1.4rem;
margin-bottom: 0.7rem;
`;

const Text = styled.div`
outline-color: ${PALETTE.BLACK_700};
background-color: ${props => (props.contentEditable ? PALETTE.WHITE : PALETTE.GRAY_200)};
border-radius: 10px;
min-width: 10rem;
max-width: 20rem;
`;

export { Container, Name, Text };
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Story } from "@storybook/react";
import SubmitButton, { Props } from ".";

export default {
title: "atoms/SubmitButton",
component: SubmitButton,
argTypes: { children: { control: "text" } }
};

const Template: Story<Props> = args => <SubmitButton {...args} />;

export const Default = Template.bind({});

Default.args = {};
12 changes: 12 additions & 0 deletions frontend/reply-module/src/components/atoms/SubmitButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Button } from "./styles";

export interface Props {
children: string;
onClick: () => void;
}

const SubmitButton = ({ children, onClick }: Props) => {
return <Button onClick={onClick}>{children}</Button>;
};

export default SubmitButton;
15 changes: 15 additions & 0 deletions frontend/reply-module/src/components/atoms/SubmitButton/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PALETTE } from "./../../../styles/palette";
import styled from "styled-components";

const Button = styled.button`
width: 6rem;
height: 3.6rem;
background-color: ${PALETTE.PRIMARY};
color: ${PALETTE.WHITE};
font-size: 1.6rem;
font-weight: 500;
border: none;
border-radius: 10px;
`;

export { Button };
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Story } from "@storybook/react";
import Comment, { Props } from ".";

export default {
title: "molecules/Comment",
component: Comment,
argTypes: { children: { control: "text" } }
};

const Template: Story<Props> = args => <Comment {...args} />;

export const Default = Template.bind({});

Default.args = {
comment: {
id: 1,
content: "Donec accumsan neque enim sodales. Neque eget vulputate viverra convallis pharetra.",
user: {
id: 1,
imageURL:
"https://static.independent.co.uk/s3fs-public/thumbnails/image/2015/06/06/15/Chris-Pratt.jpg?width=982&height=726&auto=webp&quality=75",
nickName: "Robert Hill",
type: "Authorized"
},
createdAt: "1시간 전"
},
shouldShowOption: true
};
33 changes: 33 additions & 0 deletions frontend/reply-module/src/components/molecules/Comment/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Comment as CommentType } from "../../../types";
import Avatar from "../../atoms/Avatar";
import CommentOption from "../../atoms/CommentOption";
import CommentTextBox from "../../atoms/CommentTextBox";
import { Container, CommentTextBoxWrapper, Time, CommentOptionWrapper } from "./styles";

export interface Props {
comment: CommentType;
align?: "left" | "right";

shouldShowOption?: boolean;
onEdit?: () => void;
onDelete?: () => void;
}

const Comment = ({ comment, align = "left", shouldShowOption, onEdit, onDelete }: Props) => {
return (
<Container align={align}>
<Avatar imageURL={comment.user.imageURL} />
<CommentTextBoxWrapper align={align}>
<CommentTextBox name="Dobi">{comment.content}</CommentTextBox>
<Time>{comment.createdAt}</Time>
{shouldShowOption && (
<CommentOptionWrapper>
<CommentOption onEdit={onEdit} onDelete={onDelete} />
</CommentOptionWrapper>
)}
</CommentTextBoxWrapper>
</Container>
);
};

export default Comment;
Loading

0 comments on commit e8e9008

Please sign in to comment.