Skip to content

Commit

Permalink
feat(shared/components): Icon 컴포넌트 추가 (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukvvon authored Mar 17, 2024
1 parent 104f249 commit 79ed75b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/shared/components/src/Icon.tsx
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;
1 change: 1 addition & 0 deletions packages/shared/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from '@favolink/system';
export { default as Box } from './Box';
export { default as Button, type ButtonProps } from './Button';
export { default as Heading, type HeadingProps } from './Heading';
export { default as Icon, type IconProps } from './Icon';
export { default as Link, type LinkProps } from './Link';
export {
default as Modal,
Expand Down

0 comments on commit 79ed75b

Please sign in to comment.