Skip to content

Commit 316b05c

Browse files
committed
feat: tag 컴포넌트 제작
1 parent 1023796 commit 316b05c

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.Tag {
2+
border-radius: 0.75rem;
3+
height: 2.5rem;
4+
background-color: var(--color-white);
5+
6+
&.Selected {
7+
background-color: var(--color-gray600);
8+
}
9+
10+
&.style-primary {
11+
width: fit-content;
12+
padding: 0.5rem 0.875rem;
13+
}
14+
15+
&.style-add {
16+
width: 2.5rem;
17+
padding: 0.625rem;
18+
}
19+
20+
& > span {
21+
line-height: 1.5rem;
22+
}
23+
24+
& > svg > path {
25+
fill: var(--color-gray500);
26+
}
27+
}

src/components/ui/Tag/Tag.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { forwardRef } from "react";
2+
3+
import classNames from "classnames";
4+
5+
import Icon from "@/components/ui/Icon/Icon";
6+
import styles from "@/components/ui/Tag/Tag.module.scss";
7+
import type { TagProps } from "@/components/ui/Tag/Tag.types";
8+
import Text from "@/components/ui/Text/Text";
9+
10+
const Tag = forwardRef<HTMLDivElement, TagProps>(
11+
({ variant = "primary", text, isSelect, className, ...props }, ref) => {
12+
return (
13+
<div
14+
ref={ref}
15+
className={classNames(
16+
styles.Tag,
17+
styles[`style-${variant}`],
18+
{ [styles.Selected]: isSelect },
19+
className,
20+
)}
21+
{...props}
22+
>
23+
{variant === "primary" && (
24+
<Text variant="bodyM" color={isSelect ? "white" : "secondary"}>
25+
{text}
26+
</Text>
27+
)}
28+
29+
{variant === "add" && <Icon name="plus" />}
30+
</div>
31+
);
32+
},
33+
);
34+
35+
export default Tag;

src/components/ui/Tag/Tag.types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type TagVariant = "primary" | "add";
2+
3+
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
4+
text?: string;
5+
variant?: TagVariant;
6+
isSelect?: boolean;
7+
}

0 commit comments

Comments
 (0)