2020-04-27 00:07:43 +08:00

50 lines
803 B
TypeScript

import { ReactNode } from 'react';
const SizePresets: any = {
xsmall: 8,
small: 12,
medium: 16,
large: 20,
xlarge: 30,
};
export interface IconProps {
className?: string;
fill?: string;
size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | number;
children?: ReactNode;
style?: object;
}
export function SVGIcon({
fill,
size = 'medium',
viewBox,
style,
children,
...props
}: IconProps & {
viewBox: string;
}) {
if (SizePresets.hasOwnProperty(size)) {
size = SizePresets[size];
}
return (
<svg
fill="currentColor"
preserveAspectRatio="xMidYMid meet"
width={size}
height={size}
viewBox={viewBox}
{...props}
style={{
color: fill,
...style,
}}
>
{children}
</svg>
);
}