mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
26 lines
715 B
TypeScript
26 lines
715 B
TypeScript
import type { HTMLChakraProps } from '@chakra-ui/react';
|
|
import { Skeleton, chakra } from '@chakra-ui/react';
|
|
import { type IconName } from 'public/icons/name';
|
|
import React from 'react';
|
|
|
|
export const href = '/icons/sprite.svg';
|
|
|
|
export { IconName };
|
|
|
|
interface Props extends HTMLChakraProps<'div'> {
|
|
name: IconName;
|
|
isLoading?: boolean;
|
|
}
|
|
|
|
const IconSvg = ({ name, isLoading, ...props }: Props, ref: React.ForwardedRef<HTMLDivElement>) => {
|
|
return (
|
|
<Skeleton isLoaded={ !isLoading } display="inline-block" { ...props } ref={ ref }>
|
|
<chakra.svg w="100%" h="100%">
|
|
<use href={ `${ href }#${ name }` }/>
|
|
</chakra.svg>
|
|
</Skeleton>
|
|
);
|
|
};
|
|
|
|
export default React.forwardRef(IconSvg);
|