-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shared/components): Icon 컴포넌트 추가 (#96)
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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,28 @@ | ||
import { favolink, forwardRef } from '@favolink/system'; | ||
import { classNames } from '@favolink/utils'; | ||
import { type ComponentPropsWithoutRef } from 'react'; | ||
|
||
const ICON_CLASSNAME = 'favolink-icon'; | ||
|
||
export type IconProps = ComponentPropsWithoutRef<'svg'>; | ||
|
||
const Icon = forwardRef<IconProps, 'svg'>(function Icon(props, ref) { | ||
const { as: element, children, className, ...restProps } = props; | ||
|
||
const sharedProps = { | ||
ref, | ||
className: classNames(ICON_CLASSNAME, className), | ||
}; | ||
|
||
if (element && typeof element !== 'string') { | ||
return <favolink.svg as={element} {...sharedProps} {...restProps} />; | ||
} | ||
|
||
return ( | ||
<favolink.svg {...sharedProps} {...restProps}> | ||
{children} | ||
</favolink.svg> | ||
); | ||
}); | ||
|
||
export default Icon; |
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