Skip to content

Conversation

@pakxe
Copy link
Collaborator

@pakxe pakxe commented Jan 23, 2026

close #70

작업 내용

➊ button으로 사용될 때도 있고 그냥 꾸미는 요소로만 사용될 때도 있다

as prop으로 "span", "button"만 노출하여 적절한 태그를 골라 쓸 수 있게 했다.
기본 값은 "button"이다.

➋ 아이콘이 있는 경우가 있다.

leftSlot으로 넣을 수 있다. 이때 Icon의 컬러를 지정해주지 않는다면, text 컬러를 자동으로 사용한다.



결과

image

@pakxe pakxe linked an issue Jan 23, 2026 that may be closed by this pull request
4 tasks
@pakxe pakxe self-assigned this Jan 23, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @pakxe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 프론트엔드에 재사용 가능한 Chip 컴포넌트를 도입합니다. 이 컴포넌트는 유연한 태그 선택(button 또는 span), 다양한 시각적 변형 및 크기 옵션, 그리고 아이콘을 포함할 수 있는 기능을 제공하여 UI의 일관성과 개발 효율성을 향상시키는 것을 목표로 합니다.

Highlights

  • 새로운 Chip 컴포넌트 추가: frontend/src/shared/components/chip/Chip.tsx 경로에 재사용 가능한 Chip 컴포넌트가 새로 추가되었습니다.
  • 유연한 태그 선택: as prop을 통해 Chip 컴포넌트가 button 또는 span 태그로 렌더링될 수 있도록 하여, 사용 목적에 따라 적절한 HTML 요소를 선택할 수 있습니다. 기본값은 button입니다.
  • 다양한 스타일 및 크기: cva를 활용하여 variant (primary, secondary 등 7가지) 및 size (md, sm) prop을 통해 다양한 시각적 스타일과 크기를 쉽게 적용할 수 있습니다.
  • 아이콘 슬롯 지원: leftSlot prop을 사용하여 Chip 내부에 아이콘과 같은 요소를 왼쪽에 배치할 수 있도록 지원하며, 아이콘 색상을 지정하지 않으면 텍스트 색상을 자동으로 따릅니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 재사용 가능한 Chip 컴포넌트를 구현한 점이 좋습니다. cva를 사용하여 변형(variant)을 관리하고 as prop을 통해 다형성(polymorphism)을 지원하는 접근 방식은 훌륭합니다.
다만, 현재 다형성 컴포넌트의 타입 정의에 심각한 버그가 있어 런타임 오류를 유발할 수 있습니다. 또한, 코드 가독성과 모범 사례 측면에서 개선할 수 있는 몇 가지 사항을 발견하여 리뷰에 포함했습니다. 제안된 변경 사항들을 확인해 보시고 반영해 주시면 감사하겠습니다.

Comment on lines +5 to +21
type AllowedElementType = "button" | "span";

type Props<T extends AllowedElementType> = ComponentPropsWithoutRef<T> &
VariantProps<typeof variants> & {
as?: T;
leftSlot?: ReactNode;
};

const Chip = <T extends AllowedElementType = "button">({
variant = "primary",
size = "md",
leftSlot,
children,
as,
...rest
}: Props<T>) => {
const Component = as ? as : "button";

Choose a reason for hiding this comment

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

critical

현재 Chip 컴포넌트의 타입 정의는 안전하지 않습니다. 제네릭 타입 Tas prop이 동기화되지 않아 타입 불일치 및 런타임 오류가 발생할 수 있습니다.

예를 들어, <Chip<"span"> />과 같이 컴포넌트를 호출하면, T"span"이 되지만 as prop은 undefined이므로 실제 렌더링되는 요소는 <button>이 됩니다. 이 경우 <span>에만 유효한 props가 <button>에 전달되어 React에서 오류를 발생시킬 수 있습니다.

이 문제를 해결하기 위해, 식별 가능한 유니온 타입(discriminated union type)을 사용하여 as prop의 값에 따라 props 타입이 결정되도록 수정하는 것을 강력히 권장합니다. 이렇게 하면 타입 안정성이 보장됩니다.

type ChipBaseProps = VariantProps<typeof variants> & {
    leftSlot?: ReactNode;
};

type ChipProps =
    | (ChipBaseProps &
            ComponentPropsWithoutRef<"button"> & {
                as?: "button";
            })
    | (ChipBaseProps &
            ComponentPropsWithoutRef<"span"> & {
                as: "span";
            });

const Chip = ({
    variant = "primary",
    size = "md",
    leftSlot,
    children,
    as,
    ...rest
}: ChipProps) => {
    const Component = as === "span" ? "span" : "button";


return (
<Component className={variants({ variant, size })} {...rest}>
{leftSlot ? leftSlot : null}

Choose a reason for hiding this comment

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

medium

leftSlot을 렌더링할 때 삼항 연산자를 사용하고 계십니다. React (JSX)에서는 null, undefined, false 값을 렌더링하지 않으므로, {leftSlot}과 같이 더 간결하게 작성할 수 있습니다. 이렇게 하면 코드가 더 깔끔해지고 읽기 쉬워집니다.

            {leftSlot}

Comment on lines +35 to +41
primary: [COLOR_SET.primary],
secondary: [COLOR_SET.secondary],
tertiary_outlined: [COLOR_SET.tertiary_outlined],
quaternary: [COLOR_SET.quaternary],
quaternary_accent_outlined: [COLOR_SET.quaternary_accent_outlined],
basic: [COLOR_SET.basic],
notification: [COLOR_SET.notification],

Choose a reason for hiding this comment

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

medium

cvavariants 객체에서 각 값은 COLOR_SET에서 가져온 문자열입니다. 이 값들을 불필요하게 배열로 감싸고 있습니다. cva는 문자열 값을 직접 받을 수 있으므로, 가독성을 높이고 코드를 간결하게 만들기 위해 배열을 제거하는 것이 좋습니다.

            primary: COLOR_SET.primary,
            secondary: COLOR_SET.secondary,
            tertiary_outlined: COLOR_SET.tertiary_outlined,
            quaternary: COLOR_SET.quaternary,
            quaternary_accent_outlined: COLOR_SET.quaternary_accent_outlined,
            basic: COLOR_SET.basic,
            notification: COLOR_SET.notification,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FE] Chip 컴포넌트 구현

2 participants