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

✨공통 컴포넌트 구현 #15

Merged
merged 66 commits into from
Apr 29, 2024
Merged

Conversation

Legitgoons
Copy link
Member

@Legitgoons Legitgoons commented Apr 25, 2024

작업 이유

  • 작업 속도 및 유지보수성 향상을 위해 공통 컴포넌트 구현

작업 사항

1️⃣ 컴포넌트 구현

image

BasicButton / ActiveButton

  • 복잡성 제어를 고려해 isDisabled 속성에 따라 별개의 컴포넌트로 구현
  • interface는 type.ts에서 상속받아 사용
  • 선언된 class들을 prop로 입력하도록 설정
//BasicButton.tsx
export type BasicStyle = 'defalut' | 'confirm-cancle' | 'bsm-cancle' | 'bsm-option';
interface BasicButtonProps extends ButtonProps {
  styleClass: BasicStyle;
}
<button onClick={onClick} className={styleClass}>

Modal

  • index.html에 overlays div태그를 생성
// index.html
  <body>
    <div id="root"></div>
    <div id="overlays"></div>
  </body>
  • ModalOverlay내에 createPortal을 사용해 Modal이 상위요소의 위치에 영향을 받지 않도록
  • BottomSheetModal의 경우를 고려해, styleClass prop에 따라 다른 classname이 설정되도록 함
type ModalOverlayClass = 'bottom-sheet' | 'modal';

export const ModalOverlay = ({ styleClass, children, onClose, }: ModalOverlayProps) => {
  return (
    <>
      {createPortal(<Backdrop onClick={onClose} />, portalElement)}
      {createPortal(
        <figure className={styleClass}>{children}</figure>,
        portalElement,
//...
  • 이를 다른 Modal들에서 사용
// ConfirmModal.tsx
<ModalOverlay styleClass='modal' onClose={onClose}>
  <div className='confirm-modal'>
// ... 

BottomSheetModal

{options.map((option, index) => (
  <Fragment key={index}>
    <BasicButton onClick={option.onClick} styleClass='bsm-option'>
      {option.label}
    </BasicButton>
    {index < options.length - 1 && <hr className='option-divider' />}
    // 마지막 option을 제외한 option에만 hr태그 생성
  </Fragment>
))}
.optionDivider {
  height: 1px; // 0.5px 사용시 이슈 있음
}

PageHeader

  • {page} 중앙 정렬을 위해 right padding 44px 사용

2️⃣ vite-plugin-svgr 사용

  • svg를 컴포넌트로 사용하기 위해 vite-plugin-svgr 설치 및 설정
  • 아래와 같이 사용 시 svg를 컴포넌트로 사용 가능
import {svgComponent} from '{경로}/{svgName}.svg?react';

3️⃣ 기타

  • reset.scss를 사용해 style sheet 초기화
  • icon을 담기 위해 shared/icon 폴더 생성
    • logo를 담당하던 기존의 icon.svg는 혼동의 여지가 있기에 logo.svg로 이름 변경
  • 네이밍 룰에 따라 폴더 이름 수정
    • shared/ui/FNB -> fnb로 변경
  • fonts.scss 파일 font들에 사이즈를 주석으로 작성

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

  • 컴포넌트가 적절하게 구현되었는지
  • 컴포넌트의 이름이 적절한지
  • vite-plugin-svgr를 사용해 svg를 컴포넌트로 사용하는 것을 인지하였는지
  • 아래의 이슈를 인지하였는지

발견한 이슈

  • Design팀에서 BottomModal의 구분선을 0.5px로 설정, 하지만 chrome에서 0.5px가 정상적으로 출력 되지 않음
    image

Legitgoons and others added 28 commits April 24, 2024 17:26
* feat: 반응형 레이아웃을 위한 mixin responsive-dimensions 구현

* feat: 공용 style의 쉬운 사용을 위해 _index.scss 생성
- husky install 수정
- CI 파이프라인 스크립트 및 이미지 수정
modal은 z-index 10, backdrop은 z-index 5로 구현
{page} 중앙 정렬을 위해 우측에 dummy div 태그 사용
@Legitgoons Legitgoons self-assigned this Apr 25, 2024
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.

FSD Architecture에서는 Public API를 이용하여 필요한 부분만을 외부로 추출하고, 내부 정보는 숨기는 걸로 알고있습니다.

근데 현재, shared/ui 부분에 Public API 적용 부분이 빠져있는 것 같아서 Request Changes 하였습니다.

src/shared/ui/profile/Profile.tsx Outdated Show resolved Hide resolved
src/shared/ui/modal/ConfirmReportModal.tsx Outdated Show resolved Hide resolved
src/shared/ui/button/BasicButton.tsx Outdated Show resolved Hide resolved
src/shared/ui/button/BasicButton.scss Outdated Show resolved Hide resolved
따로 style class가 없는 button을 고려했기에 class 내용을 작성하지 않았습니다.
styleClass prop를 optinal하게 두는 방안도 고려했습니다.
하지만 어떤 styleClass를 사용하는지 명시적으로 작성하는 것이 실수를 줄이기에 더 유리하다고 생각합니다.
명확한 역할을 위해 global.scss -> reset.scss로 수정
Modal이 상위요소의 위치에 따라 영향을 받지 않도록 createPortal을 사용한 ModalOverlay 컴포넌트를 구현했습니다.
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.

아래 이미지처럼 ui 폴더 자체에 대한 public api도 적용되어야 할 것 같아요!

image

참고: https://github.com/noveogroup-amorgunov/nukeapp/blob/main/src/shared/ui/index.ts

src/shared/ui/profile/Profile.tsx Outdated Show resolved Hide resolved
src/shared/ui/modal/ModalOverlay.tsx Outdated Show resolved Hide resolved
src/shared/ui/button/index.ts Outdated Show resolved Hide resolved
src/shared/styles/reset.scss Outdated Show resolved Hide resolved
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.

Profile 컴포넌트에서 제가 말한 의도가 제대로 전달되지 못한 거 같아요!

죄송해요. 마지막으로 확인 부탁드릴게요.

src/shared/ui/profile/ProfileImage.tsx Outdated Show resolved Hide resolved
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.

공통 컴포넌트에 대한 내용이 생각보다 너무 많았네요..

의찬님 코드 리뷰하면서 PR을 되도록 이면 간략하게, 하나의 기능에 집중해서 하는 것이 얼마나 중요한지에 대해 깨달을 수 있었던 시간이였던 것 같습니다 ㅎㅎ

저어어엉ㅇ~~~말 고생많으셨습니다!! 🔥🔥🔥🔥🔥

@Legitgoons Legitgoons merged commit 893a0e9 into main Apr 29, 2024
2 checks passed
@Legitgoons Legitgoons deleted the feature/PW-251-shared-components branch April 29, 2024 16:26
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