-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Extend HTMLDivElement in Tag Component (#198)
* fix: Extend HTMLDivElement in Tag Component * cs
- Loading branch information
Showing
4 changed files
with
21 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sopt-makers/ui': patch | ||
--- | ||
|
||
Extend HTMLDivElement in Tag Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default } from "./Tag"; | ||
export * from './Tag'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters