Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textarea 컴포넌트 추가 #31

Merged
merged 8 commits into from
Feb 12, 2022
4 changes: 4 additions & 0 deletions src/components/common/Input/Input.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const Input = styled.input<StyledInputProps>`
border-radius: 0.9rem;
outline: none;

&::placeholder {
color: ${theme.colors.gray50};
}

&:hover {
border: 0.1rem solid ${theme.colors.purple40};
}
Expand Down
23 changes: 23 additions & 0 deletions src/components/common/Textarea/Textarea.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
HaJunRyu marked this conversation as resolved.
Show resolved Hide resolved
import * as Styled from './Textarea.styled';

export interface TextareaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {
id: string;
label: string;
errorMessage?: string;
}

const Textarea = ({ id, required, label, errorMessage = '', ...restProps }: TextareaProps) => {
return (
<Styled.TextareaWrapper>
<Styled.TextareaLabel htmlFor={id}>
<span>{label}</span>
{required && <Styled.RequiredDot />}
</Styled.TextareaLabel>
<Styled.Textarea {...restProps} />
{errorMessage && <Styled.TextareaErrorMessage>{errorMessage}</Styled.TextareaErrorMessage>}
</Styled.TextareaWrapper>
);
};

export default Textarea;
18 changes: 18 additions & 0 deletions src/components/common/Textarea/Textarea.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import Textarea, { TextareaProps } from './Textarea.component';

export default {
title: 'Textarea',
component: Textarea,
} as ComponentMeta<typeof Textarea>;

const Template: ComponentStory<typeof Textarea> = (args: TextareaProps) => <Textarea {...args} />;

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

textarea.args = {
label: '지원서 내용입니다. 최소 200자 이내',
required: true,
placeholder: '내용을 입력해주세요',
};
65 changes: 65 additions & 0 deletions src/components/common/Textarea/Textarea.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';

export const TextareaWrapper = styled.div`
display: flex;
flex-direction: column;
`;

export const TextareaLabel = styled.label`
${({ theme }) => css`
${theme.fonts.medium15};
display: flex;
align-items: center;
margin-bottom: 0.6rem;
color: ${theme.colors.gray70};
`}
`;

export const RequiredDot = styled.span`
width: 0.6rem;
height: 0.6rem;
margin-left: 0.6rem;
background-color: #eb6963;
border-radius: 50%;
`;

export const Textarea = styled.textarea`
${({ theme }) => css`
${theme.fonts.regular15};

min-height: 20rem;
padding: 1.2rem 1.4rem;
background-color: ${theme.colors.white};
border: 0.1rem solid ${theme.colors.gray30};
border-radius: 1.2rem;
outline: none;
resize: none;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextArea를 common한 컴포넌트로 사용할거라면 resize는 props로 받게끔 해주는것도 좋은것 같아요. 근데 현재 디자인에서 resize되는 textArea가 없다고 한다면 굳이 넣을 필요도 없다고 생각합니다! 디자인쪽이랑 얘기해보고 결정하면 될것 같아요 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아직까진 크게 필요할거 같지않아서, 만약 쓸 상황이 생긴다면 허용해놓도록 하겠습니다!


&::placeholder {
color: ${theme.colors.gray50};
}

&:hover {
border: 0.1rem solid ${theme.colors.purple40};
}

&:focus {
border: 0.1rem solid ${theme.colors.purple70};
}

&:disabled {
background-color: ${theme.colors.gray5};
border: 0.1rem solid ${theme.colors.gray30};
}
`}
`;

export const TextareaErrorMessage = styled.span`
${({ theme }) => css`
${theme.fonts.regular15};
HaJunRyu marked this conversation as resolved.
Show resolved Hide resolved

margin-top: 0.6rem;
color: ${theme.colors.gray60};
`}
`;
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Input } from './Input/Input.component';
export { default as Textarea } from './Textarea/Textarea.component';
export { default as BackButton } from './BackButton/BackButton.component';
export { default as Button } from './Button/Button.component';
export { default as Checkbox } from './Checkbox/Checkbox.component';
Expand Down