Skip to content

Commit

Permalink
fix: Extend HTMLDivElement in Tag Component
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokyeom committed Nov 2, 2024
1 parent 62d2aa0 commit c820559
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
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 c820559

Please sign in to comment.