Skip to content

Commit 86ba686

Browse files
authored
fix(ui): Extend HTMLDivElement in Tag Component (#198)
* fix: Extend HTMLDivElement in Tag Component * cs
1 parent afe5e27 commit 86ba686

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

.changeset/warm-hotels-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sopt-makers/ui': patch
3+
---
4+
5+
Extend HTMLDivElement in Tag Component

packages/ui/Tag/Tag.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
import * as S from "./style.css";
2-
import createTagStyle from "./utils";
1+
import { forwardRef, type HTMLAttributes } from 'react';
2+
import * as S from './style.css';
3+
import createTagStyle from './utils';
34

4-
interface TagProps {
5+
export interface TagProps extends HTMLAttributes<HTMLDivElement> {
56
children?: React.ReactNode;
6-
size?: "sm" | "md" | "lg";
7-
shape?: "rect" | "pill";
8-
variant?: "default" | "primary" | "secondary";
9-
type?: "solid" | "line";
7+
size?: 'sm' | 'md' | 'lg';
8+
shape?: 'rect' | 'pill';
9+
variant?: 'default' | 'primary' | 'secondary';
10+
type?: 'solid' | 'line';
1011
}
1112

12-
function Tag({
13-
children,
14-
size = "sm",
15-
shape = "rect",
16-
variant = "default",
17-
type = "solid",
18-
}: TagProps) {
13+
export const Tag = forwardRef<HTMLDivElement, TagProps>((props, forwardedRef) => {
14+
const { children, size = 'sm', shape = 'rect', variant = 'default', type = 'solid' } = props;
1915
const style = createTagStyle(type, variant, shape, size);
16+
2017
return (
21-
<div className={`${S.root} ${style}`}>
18+
<div className={`${S.root} ${style}`} ref={forwardedRef}>
2219
{children}
2320
</div>
2421
);
25-
}
22+
});
2623

27-
export default Tag;
24+
Tag.displayName = 'Tag';

packages/ui/Tag/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default } from "./Tag";
1+
export * from './Tag';

packages/ui/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export type { DialogOptionType } from './Dialog';
88
export { ToastProvider, useToast, Toast } from './Toast';
99
export type { ToastOptionType } from './Toast';
1010
export { TextField, TextArea, SearchField, SelectV2, Select, UserMention } from './Input';
11-
export { default as Tag } from './Tag';
1211
export { default as Chip } from './Chip';
1312
export { default as Callout } from './Callout';
1413
export { default as Tab } from './Tab';
1514
export * from './Skeleton';
1615
export * from './FieldBox';
16+
export * from './Tag';
1717
// test component
1818
export { default as Test } from './Test';

0 commit comments

Comments
 (0)