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

✨ Toast & Input 컴포넌트 구현 #18

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Legitgoons
Copy link
Member

@Legitgoons Legitgoons commented Dec 1, 2024

CheckList

  • gap를 이용하여 flex 컨테이너 내 자식 요소간의 간격을 제어하였나요? (iOS 14 미지원으로 gap -> space-x, space-y 적용)

작업 이유

  • 공통 컴포넌트 중 Toast와 Input 구현

작업 사항

1️⃣ Toast 구현

  • react toastify 라이브러리를 사용해서 구현했습니다.
  • toast에 사용되는 icon과 message를 객체에 추가하고, 이를 toastHandler의 매개변수로 사용하도록 했습니다.
// 이벤트 호출 예시
<button onClick={() => toastHandler(message, icon)}>Toast</button> 
<Toast />

2️⃣ Input 구현

  • 입력받는 부분만을 shared/Input에 두고 이 외 부분은 직접 제작해서 사용하는 것을 전제로 구현하였습니다.
    • 현재 figma에 정리된 Input의 경우, style이 모두 다릅니다.
    • 그렇기에 이를 모두 shared/Input에 구현하는 것은 오히려 shared에 어울리지 않는다고 생각했습니다.

리뷰어가 중점적으로 확인해야 하는 부분

  • 이슈 1번을 인지하였는지
  • 추가적으로 구현해야할 부분이 없는지

발견한 이슈

  1. Toast의 경우 width 및 height 속성 등 일부 스타일이 의도된대로 수정되지 않음
  • 다음의 방법들을 시도해보았습니다.
    1. tailwind css로 style 적용: 의도한대로 속성이 수정되지 않음
    2. classname props들로 style 수정: 현재 적용된 방법, 일부 속성들이 정상적으로 수정되지 않음
    3. ✅ css 파일로 직접 수정: 의도된대로 수정이 이뤄지지만, 컨벤션에서 벗어나게 됨
      => 우선은 의도대로 수정이 이뤄지는것에 중점을 맞춰 3번을 선택했는데, 팀원분들의 의견은 어떠신지 궁금합니다.
  1. Input 컴포넌트에서 피드에 작성되는 commnet를 고려하지 않음
    => 여러 줄의 입력에는 TextArea가 더 적절하다고 판단되어 이를 고려해 구현하지 않았습니다.

@Legitgoons Legitgoons self-assigned this Dec 1, 2024
Copy link

github-actions bot commented Dec 1, 2024

🔍 Visual review for your branch is published 🔍

Here are the links to:

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-18.d1rrzjx2upcmxq.amplifyapp.com

@Legitgoons Legitgoons marked this pull request as ready for review December 1, 2024 17:19
Copy link
Collaborator

@BangDori BangDori left a comment

Choose a reason for hiding this comment

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

컨벤션에 어긋나는 부분이긴 하지만 직접 개발하였을때의 개발 비용을 무시하긴 어렵다고 생각되어, css 파일로 직접 수정하는 부분에 대해서 동의합니다.

고생하셨습니다! 리뷰를 너무 늦게 드려서 죄송하네욧..ㅠ


export const Toast = () => {
return (
<ToastContainer
Copy link
Collaborator

Choose a reason for hiding this comment

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

P4: 현재 Toast 컴포넌트는 범용적으로 활용될 수 있는 shared보다는 특정 요구사항에 적합한, 추상화 수준이 매우 낮은 widgets에 적합한 것 같습니다.

ToastContainer가 변경에 유연하게 대응할 수 있도록 하기 위해, Toast 컴포넌트의 Props로 react-toastify에서 제공해주는 ToastContainer의 props를 받도록 하는 건 어떨까요? 이렇게 된다면 다양한 요구사항에 맞춰 Toast 컴포넌트를 변환할 수 있을 것이며, 높은 추상화 수준을 갖출 수 있다고 생각합니다.

Copy link
Member Author

@Legitgoons Legitgoons Dec 3, 2024

Choose a reason for hiding this comment

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

Toast props로 ToastContainerProps를 사용하자
=> 동의합니다. 이에 맞게 수정하겠습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Toast 컴포넌트를 조금 더 shared하게 사용하기 위해 props로 ToastContainerProps를 적용하고 shared에 위치하도록 하자가 제 의견이였는데, 제가 정리가 잘 안되었나 봅니다ㅠㅠ.. 다음부터 제대로 정리해서 전달드릴게요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

P5: 메시지와 같은 부분은 다음과 같이 상수명으로 두는 것이 좋다고 생각되는데 혹시 이 부분에 대해서 어떻게 생각하시는지 수환님과 함께 얘기해보면 좋을 것 같습니다!

// 1. 객체명에 대해서만 적용
export const TOAST_MESSAGE = {
  reportSuccess: '신고가 접수되었어요',
  reportFail: '다시 시도해 주세요',
  networkError: '인터넷 연결이 불안정해요',
  commonDeleteSuccess: '댓글이 삭제되었어요',
};

// 2. 객체명과 필드명 모두 상수화
export const TOAST_MESSAGES = {
  REPORT_SUCCESS: '신고가 접수되었어요',
  REPORT_FAIL: '다시 시도해 주세요',
  NETWORK_ERROR: '인터넷 연결이 불안정해요',
  COMMON_DELETE_SUCCESS: '댓글이 삭제되었어요',
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

메시지가 고정되어 있다보니, 저도 key name을 상수형으로 주는 부분 좋은 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

저도 좋습니다! 반영하겠습니다


import { Input } from './Input';

export default {
Copy link
Collaborator

Choose a reason for hiding this comment

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

P4: 현재 Input 스토리에는 Docs가 누락되어 있어 argTypes의 내용이 정상적으로 반영되고 있지 않은 것 같아요. 작업 사항에 작성해주신 내용을 바탕으로 docs 내용을 추가해주시는 것도 나쁘지 않을 것 같습니다! (Toast Story도 동일)

src/shared/ui/input/ui/Input.stories.tsx Show resolved Hide resolved
Copy link
Collaborator

@suhwan2004 suhwan2004 left a comment

Choose a reason for hiding this comment

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

고생많으셨습니다! 병준님이 자세히 봐주셔서 많이 질문드릴 것이 없네요ㅎㅎ

스타일 파일에 정의해서 사용하는 부분의 경우, 저도 피드 작성 페이지 css파일에 추가 정의를 해야 적용이 되는 이슈에 대해 공감도 가고, 괜찮다고 생각합니다!

다음에는 빠른 PR Review 드리겠습니다...! 죄송하고 감사합니다

}

export const Input = (props: IInputProps) => {
return <input {...props} className="w-full h-full focus:outline-none" />;
Copy link
Collaborator

Choose a reason for hiding this comment

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

P4: 혹시, props에서 className을 받아오는건 어떻게 생각하시나요? 지금 같은 경우에는 스타일 설정 시, div와 같은 래핑 태그로 한번 덮어서 스타일을 줘야되는 것으로 보여서요

Copy link
Member Author

@Legitgoons Legitgoons Dec 3, 2024

Choose a reason for hiding this comment

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

props로 className을 주는 방식도 고려했으나, 안그래도 className이 길어지면 관리가 어려워지는 tailwind css 특성 상
더 복잡해질 우려가 있다고 생각해 래핑 태그를 사용하는 방식을 선택했습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

메시지가 고정되어 있다보니, 저도 key name을 상수형으로 주는 부분 좋은 것 같습니다!

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.

3 participants