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

[1단계 - 페이먼츠] - 버건디(전태헌) 미션 제출합니다. #343

Merged
merged 40 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
eac1107
style: prettier 설정
Largopie Apr 16, 2024
a2eaf72
docs: 기능 요구사항 작성
Largopie Apr 16, 2024
bcd9c7d
chore: styled-components, styled-reset 설치
Largopie Apr 16, 2024
cded571
feat: 공용 인풋 컴포넌트 생성
Largopie Apr 16, 2024
6dcf8e2
feat: sr-only 라벨 컴포넌트 생성
Largopie Apr 16, 2024
b5f8195
feat: 글로벌 스타일 설정
Largopie Apr 16, 2024
7173e07
feat(storybook): 인풋 공용 컴포넌트 스토리북 작성
Largopie Apr 16, 2024
4552764
feat: 인풋 섹션 컴포넌트 생성
Largopie Apr 16, 2024
2ea7df5
feat: useCardNumber 커스텀 훅 생성
Largopie Apr 17, 2024
3b17e49
feat: useInput 커스텀 훅 생성
Largopie Apr 17, 2024
7f0e7d1
feat(validate): 숫자 범위 유효성 검사 메서드 구현
Largopie Apr 17, 2024
152e9be
feat: CreditCard 컴포넌트 구현
Largopie Apr 18, 2024
f3b9ee0
refactor(InputSection): description 분기 처리
Largopie Apr 18, 2024
ac06ece
docs: 카드 브랜드 조건 추가
Largopie Apr 18, 2024
17fabd6
feat(validate): 유효성 검사 추가
Largopie Apr 18, 2024
3f86c2a
refactor: useInput 로직 수정
Largopie Apr 18, 2024
4c06f2f
feat: useCardNumber 유효성 검사 로직 추가
Largopie Apr 18, 2024
b323507
refactor: Input 컴포넌트 로직 수정
Largopie Apr 18, 2024
11aeaf6
chore: cardNumbers 타입 수정
Largopie Apr 18, 2024
2185961
feat(App): 컴포넌트 및 상태 바인딩
Largopie Apr 18, 2024
8bd4982
feat: 상수 분리
Largopie Apr 18, 2024
c843b8a
feat: 인풋 컴포넌트 관련 스토리북 작성
Largopie Apr 18, 2024
76a8058
feat: CreditCard 관련 스토리북 작성
Largopie Apr 18, 2024
fecb622
feat: InputSection 관련 스토리북 작성
Largopie Apr 18, 2024
a9f5148
chore: App 컴포넌트 스토리북 중앙 정렬
Largopie Apr 18, 2024
f60738d
feat: useCardImageBrand hook 선언
brgndyy Apr 19, 2024
10a9308
refactor: 공용 컴포넌트 props 타입 변경
brgndyy Apr 19, 2024
420baad
refactor: useInput 커스텀훅 수정
brgndyy Apr 19, 2024
c1d5ea5
refactor: InitialCardNumberState 타입 하위에서 정의로 변경
brgndyy Apr 19, 2024
208b14d
refactor: 변경된 useInput에 맞게 useEffect 선언들 삭제
brgndyy Apr 19, 2024
3f03f3a
refactor: InputSection 컨테이너 스타일 수정
brgndyy Apr 19, 2024
422de20
refactor: 스토리북 layout centered 속성 전역 설정
brgndyy Apr 19, 2024
1c7a8f9
refactor: 스토리북 전역 스타일로 설정
brgndyy Apr 19, 2024
394d204
chore: .nvmrc 및 eslint 설정
brgndyy Apr 19, 2024
456e349
fix: useInput 유효성검사 아예 못받게 설정, App import 변경
brgndyy Apr 19, 2024
edf45ea
fix: CreditCard 스토리북 옵션 수정
brgndyy Apr 19, 2024
a1ff303
refactor: 카드 브랜드 이미지 상태 관리 속성값 변경
brgndyy Apr 19, 2024
10f0b0c
refactor: 스타일 파일 분리
brgndyy Apr 20, 2024
f9ae286
refactor: useCardNumber 핸들러 함수 내 중복 제거
brgndyy Apr 20, 2024
b63c30a
refactor: 카드 브랜드 이미지 로직 useCardNumber로 이동
brgndyy Apr 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"semi": true,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 100,
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "auto"
}
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# react-payments
# 💳 페이먼츠

페이먼츠 사용자의 카드 정보를 입력하고 해당 카드를 어플리케이션에 등록한다.

### 카드 번호 입력 및 식별

- 사용자가 입력하는 카드 번호를 실시간으로 파악하여, Visa나 MasterCard에 해당하면 해당 브랜드의 로고를 UI에 표시한다.
- 입력은 숫자만 가능하며, 유효하지 않은 번호 입력 시 피드백을 제공한다.

### 카드 유효기간 입력

- 월과 년도를 범위 내에서만 입력할 수 있어야 하며, 입력 제한을 두어 사용자가 숫자만 입력할 수 있도록 한다.

### 카드 소유자 이름 입력

- 영문자 대문자만 입력 가능한 폼을 구현한다.

### 실시간 프리뷰 업데이트

- 사용자의 카드 정보 입력에 따라 카드 프리뷰를 동시에 업데이트한다.

### ⚠️ 주의 사항

- 사용자의 입력 input에 포커스를 자동으로 이동하는 부분을 1단계에서 고려하지 않는다. **'기능' 자체에 집중해서 구현**한다. 만약 리뷰어가 사용자 경험 측면에서 피드백을 준다면, 피드백을 반영하는 시점에서 사용자 경험도 함께 고려하여 개선한다.
- 기본적인 기능 요구사항을 만족하지 못한 코드는 코드 리뷰 대상이 아니다.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"styled-components": "^6.1.8",
Copy link

Choose a reason for hiding this comment

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

스타일링에는 CSS Module, styled-components, emotion 중 한 가지를 선택하여 사용한다.

여러 후보 중 버건디가 styled-components 를 선택해주신 이유가 궁금합니다 :)

Copy link
Author

Choose a reason for hiding this comment

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

일단 저 같은 경우는 styled-components를 사용해본적이 없습니다!

지금까지 css modulesvanilla extract를 사용해왔는데요!

배우는 과정에서 단순히 익숙하지 않다는 이유로 새로운 스택을 시도해보지 않는건 회피 밖에 안되겠다.라고 생각이 들었어요!

만약 얼른 배포를 해야하는 상황이고, 여러가지 현실적인 문제가 있다면 익숙한 기술을 채택해야겠지만..

이번에는 페어와 함께하다보니 페어를 믿고 진행해보았습니다!

페어 같은 경우는 styled-components를 사용해본 경험이 있다고 해서, 이번에 미션 진행해보면서 배울겸, 그리고 한번 겪어볼겸 시도해보았습니다!

근데 이번에 이 styled-components를 사용하면서, 장점보다는 단점이 더 많다고 저는 느껴졌어요.

1. 컴포넌트 레이아웃과 스타일링이 한곳에서 작성 된다.

이부분 같은 경우 따로 스타일 파일로 분리해서 관리를 해줄수도 있겠지만, 결국 스타일링을 적용한 컴포넌트 그 자체로 사용을 해주어야 하다보니 그냥 한 컴포넌트에서 작성하는 것이 최선이다라고 판단했습니다.

근데 전 스타일과 레이아웃이 아예 분리되는 걸 더 선호하는것 같아요.. 🥲 (css 파일로 따로 만들어서 className으로 주입해주는 것)

2. 높은 재사용성을 보장받을 수 없고, 가독성이 떨어진다.

이는 익숙하지 않아서 그런거일수도 있지만, 스타일 재사용성이 그렇게 높지 않다고 느꼈습니다.

가령 한 2~3개의 동일한 속성을 가진 스타일링 컴포넌트가 있다고 가정하고 이를 재사용해주고 싶다고 한다면,

재사용을 위해 스타일 컴포넌트 명이 애매모호 해질수 밖에 없겠다고 생각했습니다.

결국 명확한 컴포넌트 명을 위해 동일한 속성이더라도, 각각의 스타일 컴포넌트로 만들어주어야하지 않나? 라는 의구심이 들었어요!

또 결국 UI 구분을 위한 컴포넌트를 만드는데, 스타일링을 위한 컴포넌트를 또 만든다는것 자체가 아직 와닿지는 않네요..!

3. 런타임시 스타일 적용

styled-component 같은 경우 런타임시에 css를 만들어서 적용시켜주는 거로 알고 있는데요..!

이럴때 무거운 애니메이션 같은 작업이 있을 경우 성능 문제가 발생할수 있다고 알고 있습니다.

그래서 이러한 문제점을 해결 하기 위해서 나온것이 제로 런타임인 vanilla-extractpanda-css로 알고 있어요!

그렇다면 자연스럽게 저런 제로 런타임 스타일링 기술들로 생태계 흐름이 변화하지 않을까? 라는 생각이 들어요!


하지만 이번에 페어 덕분에 그래도 수월하게 새로운 기술을 접해보았다는 것이 좋았던 점입니다.

하루의 styled-components에 대한 의견 한번 여쭤보고 싶어요!

Copy link

Choose a reason for hiding this comment

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

  1. 컴포넌트 레이아웃과 스타일링이 한곳에서 작성 된다.

이것은 이번에 스타일 파일을 분리해주셔서 해결이 된 것 같군요 :)

  1. 높은 재사용성을 보장받을 수 없고, 가독성이 떨어진다.

FlexCenter Caption과 같은 유틸 성격의 컴포넌트를 작성해두고 재사용해볼 수는 있을 것 같아요.

런타임시 스타일 적용

저도 버건디의 의견에 동의합니다. panda-css 는 저도 처음들어보는데 엄청 귀여운 이름이네요 🐼 사실 저는 CSS-in-JS를 사용했을 경우 DX가 더 좋았다고 느꼈어요. 그렇지만 앞으로 새로운 프로젝트를 한다면 비슷한 이유로 vanilla-extract 나 sass 를 선택할 것 같습니다 :)

"styled-reset": "^4.5.2"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.3",
Expand Down
23 changes: 23 additions & 0 deletions src/components/composables/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import styled from 'styled-components';

type InputProps = {
Copy link

Choose a reason for hiding this comment

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

React.InputHTMLAttributes<HTMLInputElement>와 같이 제공되는 타입을 활용해서 타이핑하면 어떨까요? 혹은 의도해주신 걸까요?

Copy link
Author

Choose a reason for hiding this comment

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

오호 아뇨 생각해보지 못한 부분입니다!

짚어주셔서 감사합니다 하루 🙇

한번 적용시켜보겠습니다~!

value: string;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
type: 'text' | 'number' | 'email' | 'password';
placeholder: string;
id: string;
};

const StyledInput = styled.input`
Copy link

Choose a reason for hiding this comment

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

Styled-*를 컨벤션으로 잡아주신거군용~!

Copy link
Author

@brgndyy brgndyy Apr 19, 2024

Choose a reason for hiding this comment

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

앗 처음에 아마 이렇게 작성하고 컨벤션을 놓친 컴포넌트들이 많을거 같은데요..!

한번 검토해보면서 수정해보겠습니다!

짚어주셔서 감사해요 하루~!

border: 1px solid rgba(172, 172, 172, 1);
padding: 8px;
font-size: 0.6875rem;
border-radius: 2px;
height: 32px;
`;

export default function Input({ value, onChange, type, placeholder, id }: InputProps) {
return (
<StyledInput value={value} onChange={onChange} type={type} placeholder={placeholder} id={id} />
);
}