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

[Feat] Input 컴포넌트 추가 #87

Merged
merged 3 commits into from
Dec 18, 2023
Merged

[Feat] Input 컴포넌트 추가 #87

merged 3 commits into from
Dec 18, 2023

Conversation

JUNOSHON
Copy link
Member

🤔 해결하려는 문제가 무엇인가요?

🎉 변경 사항

image

  • 위 디자인처럼 Input 마다 사용하는 Icon이 다를 수 있어서 icon도 동적으로 사용할 수 있게 수정했습니다.

🙏 여기는 꼭 봐주세요!

  • description 영역은 추후로 미뤄두고, maxLength 먼저 구현해뒀습니다.
  • [Task] Input.tsx 구현 #86 에서 만든 IconComonentProps가 필요해서 export 했습니다.

사용 방법

<Input
          type="text"
          placeholder="placeholder"
          name="Input 타이틀"
          required
          iconName="icon-name"
          iconColor="icon.color"
          maxLength={number}
        />

🌄 스크린샷

image

📚 참고

iconComponentMap export
input.tsx 구현
@JUNOSHON JUNOSHON linked an issue Dec 15, 2023 that may be closed by this pull request
1 task
Copy link

vercel bot commented Dec 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
10mm-client-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2023 1:06pm

@JUNOSHON JUNOSHON self-assigned this Dec 15, 2023
Copy link
Contributor

Copy link
Member

@sumi-0011 sumi-0011 left a comment

Choose a reason for hiding this comment

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

수고하셨습니당 👍🏻


export default function Input({ iconName, iconColor, ...inputProps }: InputProps) {
const { required, name, value, maxLength } = inputProps;
const [inputValue, setInputValue] = useState(value ? String(value) : '');
Copy link
Member

Choose a reason for hiding this comment

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

input의 value값을 해당 컴포넌트에서 상태로 제어해야하는 이유가 있을까요?
따로 없다면 아예 value 값은 props로 받고, 상위에서 제어할 수 있으면 좋을 것 같아요!

해당 value를 Input 컴포넌트에선 initial State로 처음에만 설정해줘서
상위 컴포넌트에서 value값을 바꾸어도 Input 컴포넌트에서 보이는 value값은 바뀌지 않는 상황이 생길 수 있을 것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

우측 하단의 글자수세기 기능을 위해 사용했습니다..!
input의 value는 상위 컴포넌트에서 사용하는걸로 수정해보겠습니다.

import { type IconComponentMap, type IconComponentProps } from '../Icon';

interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
iconName?: keyof typeof IconComponentMap; // iconName prop 수정
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@wade3420 wade3420 Dec 18, 2023

Choose a reason for hiding this comment

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

iconName 이라는 네이밍을 좀 더 명확하게 허기위해 righIconName 은 어떨까요?

재안) 아이콘을 클릭했을 때 동작또한 onIconClick 과 같은 props로 넘겨주어야할 것 같아서 input 컴포넌트 안에서 name에따라 icon 컴포넌트를 렌더링하는 것보다는 iconComponet 와 같은 프롭으로 React.element를 받아와서 렌더링해주는 건 어떤가요?

전자는 icon 컴포넌트로 제한을 줄 수 있다는 장점이 있을거 같고 후자는 확장성이 열려있다는 장점이 있을 것 같아요 (다른분들 의견도 궁금)

</section>
);

// <section className={sectionCss}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

사용하지 않는 주석은 제거하는게 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

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

수정하겠습니다!!

미사용 주석 삭제
@JUNOSHON JUNOSHON merged commit b9d9f7f into develop Dec 18, 2023
3 checks passed
Copy link
Contributor

@sumi-0011 sumi-0011 deleted the feat/input branch December 22, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Input.tsx 구현
3 participants