-
Notifications
You must be signed in to change notification settings - Fork 4
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
[feat/CK-147] 골룸 생성 페이지 고도화 및 유효성 검사를 구현한다 #114
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9a5bad7
feat: 입력받은 날짜가 현재를 기준으로 유효한지 판별하는 함수 구현
jw-r 135104a
Merge branch 'develop-client' of https://github.com/woowacourse-teams…
jw-r f9cf402
feat: onChange가 발생했을 때, onSubmit이 발생했을 때 유효성 검사를 수행하도록 Hook 확장
jw-r 175df49
chore: handleSubmit 함수에 대한 주석 추가
jw-r ca66909
feat: 코끼리끼리 InputField 구현
jw-r dd05190
design: number 타입일 떄의 스타일 추가
jw-r 6d27e76
design: form을 section 별로 분리 및 스타일 재조정
jw-r 84cb937
feat: 객체 내부의 yyyy-mm-dd 형식의 문자열을 yyyymmdd 형태로 변환하는 함수 구현
jw-r 3678e9b
refactor: 외부에서 handleInputChange 함수의 타입과 에러 객체의 타입에 접근할 수 있도록 변경
jw-r 8c02fa9
refactor: 각 Input의 validation을 하나의 함수로 작성하도록 리펙토링
jw-r 06a12b8
refactor: useFormInput 중복 로직 제거 리펙토링
jw-r fffff00
refactor: validation 객체의 메서드 내부에서 모든 유효성 검사 로직을 수행하도록 변경
jw-r 36e7bfc
design: 에러 메시지가 잘리지 않도록 스타일 수정
jw-r a765fb1
feat: any 타입을 최소화하도록 타입 리펙토링
jw-r 419ffde
refactor: validation utils 함수 분리 및 테스트 코드 작성
jw-r 7759c78
feat: isValidMaxValue 함수 구현 및 테스트 코드 작성
jw-r d5728d4
feat: 인원수에 대한 Input 추가
jw-r 5d864ce
refactor: validation의 매직넘버와 에러 메시지를 상수화
jw-r cfec4a6
feat: InputField에 textarea 태그를 조건 분기로 추가
jw-r 7292a5a
refactor: 로드맵 Info 맵핑
jw-r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
client/src/components/_common/InputField/InputField.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const InputField = styled.div` | ||
box-sizing: content-box; | ||
`; | ||
|
||
export const FieldHeader = styled.div<{ size?: 'small' | 'normal' }>` | ||
margin-bottom: ${({ size }) => (size === 'small' ? '0.8rem' : '1.8rem')}; | ||
`; | ||
|
||
export const Label = styled.label<{ size?: 'small' | 'normal' }>` | ||
${({ theme, size }) => | ||
size === 'small' ? theme.fonts.nav_text : theme.fonts.nav_title}; | ||
& > span { | ||
color: ${({ theme }) => theme.colors.red}; | ||
} | ||
`; | ||
|
||
export const Description = styled.p` | ||
${({ theme }) => theme.fonts.nav_text}; | ||
color: ${({ theme }) => theme.colors.gray300}; | ||
`; | ||
|
||
export const InputBox = styled.div<{ | ||
size?: 'small' | 'normal'; | ||
type?: 'text' | 'date' | 'textarea' | 'number'; | ||
}>` | ||
& > input { | ||
${({ theme, size }) => (size === 'small' ? theme.fonts.button1 : theme.fonts.h2)}; | ||
width: ${({ size, type }) => | ||
type === 'number' ? '7rem' : size === 'small' ? '' : '100%'}; | ||
padding: ${({ size, type }) => | ||
type === 'number' ? '0.4rem' : size === 'small' ? '0.1rem' : '0.4rem'}; | ||
|
||
text-align: ${({ size }) => (size === 'small' ? 'center' : '')}; | ||
|
||
border: ${({ theme, type }) => | ||
type === 'number' ? `0.1rem solid ${theme.colors.black}` : 'none'}; | ||
border-bottom: ${({ theme }) => `0.1rem solid ${theme.colors.black}`}; | ||
border-radius: ${({ type }) => (type === 'number' ? '4px' : '')}; | ||
} | ||
|
||
& > textarea { | ||
${({ theme, size }) => (size === 'small' ? theme.fonts.button1 : theme.fonts.h2)}; | ||
width: 100%; | ||
height: 15rem; | ||
padding: 1.5rem 1rem; | ||
|
||
border: ${({ theme }) => `3px solid ${theme.colors.main_dark}`}; | ||
border-radius: 8px; | ||
} | ||
`; | ||
|
||
export const ErrorMessage = styled.p<{ size?: 'small' | 'normal' }>` | ||
${({ theme }) => theme.fonts.button1}; | ||
position: absolute; | ||
color: ${({ theme }) => theme.colors.red}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { HandleInputChangeType } from '@hooks/_common/useFormInput'; | ||
import * as S from './InputField.styles'; | ||
|
||
type InputFieldProps = { | ||
name: string; | ||
value: string; | ||
onChange: HandleInputChangeType; | ||
label?: string; | ||
type?: 'text' | 'date' | 'textarea' | 'number'; | ||
size?: 'small' | 'normal'; | ||
isRequired?: boolean; | ||
description?: string; | ||
placeholder?: string; | ||
errorMessage?: string; | ||
style?: { [key: string]: string }; | ||
}; | ||
|
||
const InputField = ({ ...props }: InputFieldProps) => { | ||
return ( | ||
<S.InputField style={props.style}> | ||
<S.FieldHeader size={props.size}> | ||
<S.Label htmlFor={props.name} size={props.size}> | ||
{props.label} | ||
{props.isRequired && <span>*</span>} | ||
</S.Label> | ||
{props.description && <S.Description>{props.description}</S.Description>} | ||
</S.FieldHeader> | ||
<S.InputBox size={props.size} type={props.type}> | ||
{props.type === 'textarea' ? ( | ||
<textarea | ||
id={props.name} | ||
name={props.name} | ||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id는 왜 지정해준건지 궁금해요!! |
||
placeholder={props.placeholder} | ||
value={props.value} | ||
onChange={props.onChange} | ||
/> | ||
) : ( | ||
<input | ||
id={props.name} | ||
name={props.name} | ||
placeholder={props.placeholder} | ||
value={props.value} | ||
type={props.type === 'number' ? 'text' : props.type || 'text'} | ||
onChange={props.onChange} | ||
/> | ||
)} | ||
{props.errorMessage && ( | ||
<S.ErrorMessage size={props.size}>{props.errorMessage}</S.ErrorMessage> | ||
)} | ||
</S.InputBox> | ||
</S.InputField> | ||
); | ||
}; | ||
|
||
export default InputField; |
92 changes: 11 additions & 81 deletions
92
client/src/components/goalRoomCreatePage/createGoalRoomForm/CreateGoalRoomForm.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,18 @@ | ||
import media from '@/styles/media'; | ||
import { styled } from 'styled-components'; | ||
|
||
export const Form = styled.form``; | ||
|
||
export const RoadmapInfo = styled.div` | ||
${({ theme }) => theme.fonts.description4} | ||
`; | ||
|
||
export const InputField = styled.label` | ||
width: 80%; | ||
height: 80%; | ||
color: ${({ theme }) => theme.colors.gray300}; | ||
&::placeholder { | ||
${({ theme }) => theme.fonts.description4}; | ||
color: ${({ theme }) => theme.colors.gray200}; | ||
} | ||
`; | ||
|
||
export const Input = styled.input` | ||
${({ theme }) => theme.fonts.nav_title} | ||
width: 70%; | ||
padding: 1rem 0.5rem; | ||
color: ${({ theme }) => theme.colors.gray300}; | ||
border-bottom: ${({ theme }) => `0.1rem solid ${theme.colors.black}`}; | ||
&::placeholder { | ||
${({ theme }) => theme.fonts.description4}; | ||
color: ${({ theme }) => theme.colors.gray200}; | ||
} | ||
|
||
${media.mobile` | ||
width:100%; | ||
`} | ||
`; | ||
|
||
export const NodeSectionWrapper = styled.div` | ||
display: flex; | ||
column-gap: 2rem; | ||
`; | ||
|
||
export const NodeList = styled.form<{ nodeCount: number }>` | ||
display: grid; | ||
grid-template-rows: ${({ nodeCount }) => `repeat(${nodeCount}, 1fr)`}; | ||
row-gap: 2.4rem; | ||
export const Form = styled.form` | ||
margin: 6rem 0; | ||
`; | ||
|
||
export const NodeWrapper = styled.div` | ||
export const SubmitButtonWrapper = styled.div` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
export const NodeInfo = styled.div` | ||
width: 18rem; | ||
height: 18rem; | ||
margin-right: 2rem; | ||
padding: 2rem; | ||
|
||
background-color: ${({ theme }) => theme.colors.gray100}; | ||
border-radius: 8px; | ||
`; | ||
|
||
export const NodeConfigs = styled.div` | ||
display: flex; | ||
|
||
& > *:not(:last-child) { | ||
margin-right: 2rem; | ||
justify-content: end; | ||
margin-top: 3rem; | ||
|
||
& > button { | ||
padding: 1.8rem 3rem; | ||
color: ${({ theme }) => theme.colors.white}; | ||
background-color: ${({ theme }) => theme.colors.main_dark}; | ||
border-radius: 8px; | ||
} | ||
`; | ||
|
||
export const DateInput = styled.input` | ||
padding: 0.7rem 0; | ||
text-align: center; | ||
background-color: ${({ theme }) => theme.colors.gray100}; | ||
border-radius: 4px; | ||
`; | ||
|
||
export const Textarea = styled.textarea` | ||
width: 70%; | ||
height: 16rem; | ||
padding: 1rem 0.5rem; | ||
|
||
border: ${({ theme }) => `0.1rem solid ${theme.colors.black}`}; | ||
border-radius: 8px; | ||
|
||
${media.mobile` | ||
width:100%; | ||
`} | ||
`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여러 props를 받아서 Input을 사용할 수 있게 한거 너무 좋은 것 같아요!! 우디 고민한 티가 많이나고 너무 수고많았어요ㅠㅠ 조금 더 다듬어서 서비스 내 모든 input에 적용해켜봅시당!!
지금 당장은 아니고 리팩토링할 때 했으면 하는 부분들 여기에 정리해놨습니다!
https://www.notion.so/d0b3ea6e9cf44703ab9c3a10bb6e1b96