Skip to content

Commit

Permalink
feat(components): add Icon component that loads icon from svg sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
Callenowy committed Jan 21, 2024
2 parents 3f647eb + 485830c commit 4b8eca5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { forwardRef } from 'react';

import { cn } from '@/utils/cn';

export interface IconProps extends React.SVGProps<SVGSVGElement> {
id: string;
sprite?: string;
}

const Icon = forwardRef<SVGSVGElement, IconProps>(
({ className, id, sprite, ...props }, ref) => {
return (
<svg viewBox="0 0 64 48" className={cn(className)} ref={ref} {...props}>
<use href={`${sprite}#${id}`} />
</svg>
);
}
);

Icon.displayName = 'Icon';

export { Icon };

0 comments on commit 4b8eca5

Please sign in to comment.