Skip to content

Commit

Permalink
fix(ui): Extend HTMLDivElement in Tag Component (#198)
Browse files Browse the repository at this point in the history
* fix: Extend HTMLDivElement in Tag Component

* cs
  • Loading branch information
Brokyeom authored Nov 2, 2024
1 parent afe5e27 commit 86ba686
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-hotels-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sopt-makers/ui': patch
---

Extend HTMLDivElement in Tag Component
31 changes: 14 additions & 17 deletions packages/ui/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import * as S from "./style.css";
import createTagStyle from "./utils";
import { forwardRef, type HTMLAttributes } from 'react';
import * as S from './style.css';
import createTagStyle from './utils';

interface TagProps {
export interface TagProps extends HTMLAttributes<HTMLDivElement> {
children?: React.ReactNode;
size?: "sm" | "md" | "lg";
shape?: "rect" | "pill";
variant?: "default" | "primary" | "secondary";
type?: "solid" | "line";
size?: 'sm' | 'md' | 'lg';
shape?: 'rect' | 'pill';
variant?: 'default' | 'primary' | 'secondary';
type?: 'solid' | 'line';
}

function Tag({
children,
size = "sm",
shape = "rect",
variant = "default",
type = "solid",
}: TagProps) {
export const Tag = forwardRef<HTMLDivElement, TagProps>((props, forwardedRef) => {
const { children, size = 'sm', shape = 'rect', variant = 'default', type = 'solid' } = props;
const style = createTagStyle(type, variant, shape, size);

return (
<div className={`${S.root} ${style}`}>
<div className={`${S.root} ${style}`} ref={forwardedRef}>
{children}
</div>
);
}
});

export default Tag;
Tag.displayName = 'Tag';
2 changes: 1 addition & 1 deletion packages/ui/Tag/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from "./Tag";
export * from './Tag';
2 changes: 1 addition & 1 deletion packages/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export type { DialogOptionType } from './Dialog';
export { ToastProvider, useToast, Toast } from './Toast';
export type { ToastOptionType } from './Toast';
export { TextField, TextArea, SearchField, SelectV2, Select, UserMention } from './Input';
export { default as Tag } from './Tag';
export { default as Chip } from './Chip';
export { default as Callout } from './Callout';
export { default as Tab } from './Tab';
export * from './Skeleton';
export * from './FieldBox';
export * from './Tag';
// test component
export { default as Test } from './Test';

0 comments on commit 86ba686

Please sign in to comment.