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

컴포넌트 스타일 일관성 리팩토링 #98

Conversation

vi-wolhwa
Copy link
Contributor

@vi-wolhwa vi-wolhwa commented Jul 21, 2024

⚡️ 관련 이슈

close #92

📍주요 변경 사항

1. 변경 컴포넌트

  • Button
  • Flex
  • Header
  • Input
  • Layout
  • SelectList
  • SnippetEditor
  • TemplateItem
  • TemplateTitleInput
  • Text

2. 리팩토링 기준 (컨벤션)

  • Emotion CSS
    • css 객체 스타일링 제거
    • Styled-component 사용
      • Input, Flex, Button 컴포넌트 우선 사용
  • Props 인터페이스
    • 네이밍
      • 컴포넌트 : Props로 네이밍한다.
      • 스타일 : StyleProps로 네이밍 한다.
    • 선언/정의
      • 컴포넌트 : children prop 대신 PropsWithChildren을 사용한다.
      • 스타일 : 컴포넌트의 Props를 import하여 사용한다.
      • 스타일 : default가 명확하지 않은 prop를 optional로 정의하지 않는다.
  • Props 기본값
    • 컴포넌트
      • 기본값은 컴포넌트의 매개변수에 정의한다.
      • Styled-component에서 스타일 기본값을 사용하는 속성은 기본값을 정의하지 않는다.
      const Button = ({ children, onClick, type, variant, size, width, disabled }: Props) => (
      <S.Button type={type || 'button'} variant={variant} size={size} width={width} disabled={disabled} onClick={onClick}>
        {children}
      </S.Button>
      );
  • Etc
    • 반드시 필요하지 않은 import React 생략
    • 스타일
      • CSS 기본값과 동일할 경우, 기본값을 입력하지 않는다.
      • 기본값 입력이 필요할 경우, props에 입력한다.
      export const TextWrapper = styled.span<StyleProps>`
        font-size: ${({ size }) => `${size}rem`};
        font-weight: ${({ weight = 'regular' }) => weights[weight]};
        color: ${({ color = 'white' }) => color};
      `;

🎸기타

Stylelint 적용 관련 트러블슈팅 (바로가기)

@vi-wolhwa vi-wolhwa added FE 프론트엔드 refactor 요구사항이 바뀌지 않은 변경사항 labels Jul 21, 2024
@vi-wolhwa vi-wolhwa added this to the 2차 스프린트 🐣 milestone Jul 21, 2024
@vi-wolhwa vi-wolhwa self-assigned this Jul 21, 2024
@vi-wolhwa vi-wolhwa linked an issue Jul 21, 2024 that may be closed by this pull request
Copy link
Contributor

@Jaymyong66 Jaymyong66 left a comment

Choose a reason for hiding this comment

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

기본값 관련 이야기를 해봐야할 것 같아요~!
undefined로 둘지에 대해서도요!

frontend/src/components/Button/Button.tsx Outdated Show resolved Hide resolved
frontend/src/components/Button/style.ts Show resolved Hide resolved
frontend/src/components/Button/style.ts Outdated Show resolved Hide resolved
frontend/src/components/Flex/style.ts Outdated Show resolved Hide resolved
frontend/src/components/Header/Header.tsx Show resolved Hide resolved
frontend/src/components/Input/Input.tsx Outdated Show resolved Hide resolved
frontend/src/components/SelectList/SelectList.tsx Outdated Show resolved Hide resolved
frontend/src/components/SelectList/style.ts Outdated Show resolved Hide resolved
frontend/src/components/Text/style.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Hain-tain Hain-tain left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍👍

(+) 우리 해커톤 끝났으니까 이제 슬슬 색상과 font-size 등에 대한 토큰을 상수로 빼서 사용하는 작업을 시작해야 할 것 같아요!!

frontend/src/components/Header/Header.tsx Outdated Show resolved Hide resolved
frontend/src/components/SelectList/style.ts Outdated Show resolved Hide resolved
frontend/src/components/Input/Input.tsx Outdated Show resolved Hide resolved
frontend/src/components/SnippetEditor/SnippetEditor.tsx Outdated Show resolved Hide resolved
frontend/src/components/Text/Text.tsx Outdated Show resolved Hide resolved
vi-wolhwa and others added 21 commits July 22, 2024 16:42
@Hain-tain Hain-tain merged commit 500a453 into woowacourse-teams:dev/fe Jul 24, 2024
1 check passed
@vi-wolhwa vi-wolhwa deleted the refactor/component_style_consistency branch July 24, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FE 프론트엔드 refactor 요구사항이 바뀌지 않은 변경사항
Projects
Status: Weekend Done
Development

Successfully merging this pull request may close these issues.

[REFACTOR] 컴포넌트 JSX/CSS 스타일 일관성 리팩토링
3 participants