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

[FE] Input, Field 컴포넌트 구현 #64

Merged
merged 11 commits into from
Jul 25, 2024
Merged

Conversation

Yoonkyoungme
Copy link
Contributor

@Yoonkyoungme Yoonkyoungme commented Jul 24, 2024

관련 이슈

작업 내용

  • Input

    • Input 컴포넌트 구현
    • Input 스토리북 작성
  • Field

    • Field 컴포넌트 구현
    • Field 스토리북 작성
  • useInput hook 구현

특이 사항

스토리북에서 한국어로 작성된 예제들을 포함하였으며, 각 컴포넌트의 다양한 상태를 확인할 수 있습니다.

리뷰 요구사항 (선택)

@Yoonkyoungme Yoonkyoungme self-assigned this Jul 24, 2024
@Yoonkyoungme Yoonkyoungme added 🐈 프론트엔드 프론트엔드 관련 이슈에요 :) 🚀 기능 기능을 개발해요 :) labels Jul 24, 2024
Copy link

github-actions bot commented Jul 24, 2024

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit de8b0a2.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@Largopie Largopie left a comment

Choose a reason for hiding this comment

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

빠르게 구현해주셨네요! 고생하셨습니다 빙봉! 역시 빙봉!

코멘트 몇개 남겨두었는데 확인 후 다시 요청해주세요! 🐫

@@ -0,0 +1,16 @@
import { ChangeEvent, useState } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

[P1] ChangeEvent는 type으로 import 명시해주어야 할 것 같아요! 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗 자동 import 하면서 놓쳤네요ㅜㅜ 꼼꼼히 확인해 주셔서 감사해요!! 반영하였습니다!

inputProps?: InputHTMLAttributes<HTMLInputElement>;
}

export default function Field({ label, description = '', inputProps }: FieldProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[P3] label이라는 prop 이름이 htmlFor과 input의 id를 명시한다는 것이 제가 느끼기엔 이해하기 조금 어려운 것 같아요!
label보다는 직접적으로 id라고 명시하는 것은 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

[C]

아니면 현재 label props를 지우고 InputHTMLAttributes<HTMLInputElement>의 타입을 활용해서 id를 직접 내려준 다음 필요한 곳에 할당하는 것은 어떨까요~?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

확실히 그러네요 label을 id, htmlFor 값으로 같이 사용하고 있어서 어색하게 느껴지는 것 같습니다🥹
낙타와 해리 코멘트를 확인하고 변경해 보았어요.

변경 사항

  • label prop을 labelText로 변경 (해당 prop의 네이밍을 명확하게 하기 위함)
  • Field 컴포넌트에서 labelTextid를 명시적으로 받아서 labelInputid에 적용하도록 수정

반영 커밋: ace237b

import { css } from '@emotion/react';

export const s_input = css`
box-sizing: border-box;
Copy link
Contributor

Choose a reason for hiding this comment

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

[P2]
해당 속성도 전역 GlobalStyle에 정의되어 있어서 제외하셔도 좋을 것 같습니다!

Comment on lines 6 to 12
interface FieldProps {
label: string;
description?: string;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
}

export default function Field({ label, description = '', inputProps }: FieldProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[P3]

Suggested change
interface FieldProps {
label: string;
description?: string;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
}
export default function Field({ label, description = '', inputProps }: FieldProps) {
interface FieldProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
description?: string;
}
export default function Field({ label, description = '', ...props }: FieldProps) {

이렇게 표현해볼 수도 있을 것 같습니다! 가벼운 제안입니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오옷!!! 낙타🐫 좋은 의견이네요! InputHTMLAttributes를 확장하는 것이 훨씬 깔끔한 것 같습니다. 반영하였습니다~

Copy link
Contributor

@hwinkr hwinkr left a comment

Choose a reason for hiding this comment

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

빙봉 소소한 코멘트 남깁니다~


export const s_input = css`
box-sizing: border-box;
width: 20rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

[p2]

피그마 시안이랑 width가 다른 것 같아요! rem으로 정의해두는 것 보다 디바이스 크기에 따라 Input 컴포넌트가 차지하는 공간의 비율이 달리지게 될 것 같은데 100%으로 설정해두는게 어떨까요~?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋은 의견이네요~!~! 반영하였습니다!

const useInput = (initialValue = '') => {
const [value, setValue] = useState(initialValue);

const handleValueChange = (event: ChangeEvent<HTMLInputElement>) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

이벤트 핸들러 함수 컨벤션 잊지 않고 잘 챙기고 있군요~ 좋습니다!

inputProps?: InputHTMLAttributes<HTMLInputElement>;
}

export default function Field({ label, description = '', inputProps }: FieldProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[C]

아니면 현재 label props를 지우고 InputHTMLAttributes<HTMLInputElement>의 타입을 활용해서 id를 직접 내려준 다음 필요한 곳에 할당하는 것은 어떨까요~?

Copy link
Contributor Author

@Yoonkyoungme Yoonkyoungme left a comment

Choose a reason for hiding this comment

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

@Largopie @hwinkr
낙타, 해리! 남겨주신 코멘트를 반영하였습니다🐫🍀 좋은 의견 공유 감사해요!

@@ -0,0 +1,16 @@
import { ChangeEvent, useState } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗 자동 import 하면서 놓쳤네요ㅜㅜ 꼼꼼히 확인해 주셔서 감사해요!! 반영하였습니다!


export const s_input = css`
box-sizing: border-box;
width: 20rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋은 의견이네요~!~! 반영하였습니다!

Comment on lines 6 to 12
interface FieldProps {
label: string;
description?: string;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
}

export default function Field({ label, description = '', inputProps }: FieldProps) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

오옷!!! 낙타🐫 좋은 의견이네요! InputHTMLAttributes를 확장하는 것이 훨씬 깔끔한 것 같습니다. 반영하였습니다~

inputProps?: InputHTMLAttributes<HTMLInputElement>;
}

export default function Field({ label, description = '', inputProps }: FieldProps) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

확실히 그러네요 label을 id, htmlFor 값으로 같이 사용하고 있어서 어색하게 느껴지는 것 같습니다🥹
낙타와 해리 코멘트를 확인하고 변경해 보았어요.

변경 사항

  • label prop을 labelText로 변경 (해당 prop의 네이밍을 명확하게 하기 위함)
  • Field 컴포넌트에서 labelTextid를 명시적으로 받아서 labelInputid에 적용하도록 수정

반영 커밋: ace237b

Copy link
Contributor

@hwinkr hwinkr left a comment

Choose a reason for hiding this comment

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

뱅뱅봉봉빙빙방방, 리뷰 반영하느라 고생했어요~ 🔮

Copy link
Contributor

@Largopie Largopie left a comment

Choose a reason for hiding this comment

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

의견 반영 감사합니다 👍👍👍 💯💯💯

- `width` 속성을 `100%`로 변경하여 입력 필드가 부모 요소의 너비에 맞추어 반응하도록 조정
- 전역 스타일에서 정의된 속성(`box-sizing: border-box;`)를 중복하여 정의하지 않도록 수정
- `label` prop을 `labelText`로 변경
- `Field` 컴포넌트에서 `labelText`와 `id`를 명시적으로 받아서 `label`과 `Input`의 `id`에 적용하도록 수정
-`InputHTMLAttributes<HTMLInputElement>`를 상속받아 추가적인 `input` 속성을 직접 전달할 수 있도록 개선
@Yoonkyoungme Yoonkyoungme force-pushed the feat/61-input-and-field branch from ace237b to de8b0a2 Compare July 25, 2024 01:51
@Yoonkyoungme Yoonkyoungme merged commit 73b8c14 into develop Jul 25, 2024
5 checks passed
@Yoonkyoungme Yoonkyoungme deleted the feat/61-input-and-field branch July 25, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐈 프론트엔드 프론트엔드 관련 이슈에요 :) 🚀 기능 기능을 개발해요 :)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] Input, Field 컴포넌트를 구현해요 :)
3 participants