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]: Tag 컴포넌트 구현 #132

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: 리뷰 반영 & changest 추가
  • Loading branch information
SeieunYoo committed Aug 12, 2024
commit 9382e93d27ee91f3ca736b49e722a67150fad9a9
7 changes: 7 additions & 0 deletions .changeset/real-gorillas-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wowds-tokens": patch
"wowds-theme": patch
"wowds-ui": patch
---

Tag 컴포넌트를 구현합니다.
1 change: 1 addition & 0 deletions packages/wow-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"clsx": "^2.1.1",
"lottie-react": "^2.4.0",
"wowds-icons": "workspace:^"
},
Expand Down
27 changes: 12 additions & 15 deletions packages/wow-ui/src/components/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { cva } from "@styled-system/css/cva";
import { styled } from "@styled-system/jsx";
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
import { clsx } from "clsx";
import type { HTMLAttributes, PropsWithChildren } from "react";
import { forwardRef } from "react";

type Variant = "outline" | "solid1" | "solid2";
Expand All @@ -17,38 +18,34 @@ type VariantColorMap = {
solid2: Solid2Colors;
};

export interface BaseTagProps extends HTMLAttributes<HTMLSpanElement> {
children: ReactNode;
style?: CSSProperties;
className?: string;
}
export interface BaseTagProps
extends HTMLAttributes<HTMLSpanElement>,
PropsWithChildren {}

/**
* @description 태그 컴포넌트의 속성을 정의합니다.
*
* @param {ReactNode} children - 태그의 자식 요소.
* @param {"outline" | "solid1" | 'solid2'} [variant] - 태그의 종류.
* @param {"red" | "blue" | "green" | "yellow" | "grey"} [color] - 태그의 색상.
* @param {CSSProperties} [style] - 태그의 커스텀 스타일.
* @param {string} [className] - 태그에 전달하는 커스텀 클래스.
* @param {ComponentPropsWithoutRef<T>} rest 렌더링된 요소 또는 컴포넌트에 전달할 추가 props.
* @param {ComponentPropsWithRef<T>["ref"]} ref 렌더링된 요소 또는 컴포넌트에 연결할 ref.
*/

type SpecificTagProps = BaseTagProps & {
type TagProps = BaseTagProps & {
variant: Variant;
color: VariantColorMap[Variant];
};

const Tag = forwardRef<HTMLSpanElement, SpecificTagProps>(
({ children, variant = "outline", color, ...rest }, ref) => {
const Tag = forwardRef<HTMLSpanElement, TagProps>(
(
{ children, variant = "outline", color = "blue", className, ...rest },
ref
) => {
return (
<styled.span
className={clsx(TagStyle({ variant, color }), className)}
ref={ref}
className={TagStyle({
variant,
color,
})}
{...rest}
>
{children}
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading