Files

76 lines
2.6 KiB
TypeScript

import type React from 'react';
import { cloneElement } from 'react';
import type { IconSize } from '../icon-config.js';
import { ICON_SIZE_MAP, STROKE_WIDTH_MAP } from '../icon-config.js';
export interface IconProps extends React.SVGProps<SVGSVGElement> {
size?: IconSize | number;
strokeWidth?: number;
className?: string;
}
const SvgNut = ({
color = 'currentColor',
size,
strokeWidth,
className,
...props
}: IconProps): React.ReactElement => {
const element = (
<svg width={16} height={16} fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
<g clipPath="url(#nut_svg__a)">
<path
d="M8 2.667V1.333m0 1.334C5.333 2.667 3 4 2.666 5.333c-.162.647-.612 1.302-1.333 2 .873-.054 1.315-.193 2-.666m4.667-4c2.666 0 5 1.333 5.333 2.666.161.647.469 1.31 1.333 2-.878.105-1.312-.056-2-.666m-9.333 0v2.666a4.669 4.669 0 0 0 3.518 4.525c.275.07.535.195.735.395l.414.414.414-.414c.2-.2.46-.326.734-.395a4.668 4.668 0 0 0 3.518-4.525V6.667m-9.333 0c.36.613.655.904 1.333 1.333.968-.431 1.303-.732 1.667-1.333C6.73 7.33 7.1 7.618 8 8c.873-.414 1.241-.705 1.666-1.333.42.651.775.948 1.667 1.333.806-.365 1.12-.645 1.333-1.333"
stroke="#2A2E37"
strokeWidth={1.33}
strokeLinecap="round"
strokeLinejoin="round"
/>
</g>
<defs>
<clipPath id="nut_svg__a">
<path fill="#fff" d="M0 0h16v16H0z" />
</clipPath>
</defs>
</svg>
);
const hasViewBox = element.props.viewBox != null;
const isCustomIcon = element.props['data-custom-icon'] === 'true';
const defaultSize = isCustomIcon ? element.props.width : ICON_SIZE_MAP.xs;
const resolvedSize =
size != null ? (typeof size === 'number' ? size : ICON_SIZE_MAP[size]) : defaultSize;
const resolvedStrokeWidth =
strokeWidth != null
? strokeWidth
: typeof size === 'string' && size in STROKE_WIDTH_MAP
? STROKE_WIDTH_MAP[size]
: size == null
? STROKE_WIDTH_MAP.xs
: 2;
const w = element.props.width != null ? Number(element.props.width) : 24;
const h = element.props.height != null ? Number(element.props.height) : 24;
const viewBoxWhenMissing = `0 0 ${w} ${h}`;
const elementProps = {
...props,
className: className ? `signoz-icon ${className}` : 'signoz-icon',
...(!isCustomIcon && {
stroke: color,
strokeWidth: resolvedStrokeWidth,
}),
...(!isCustomIcon &&
!hasViewBox && {
viewBox: viewBoxWhenMissing,
}),
...(isCustomIcon && {
style: {
color,
...props.style,
},
viewBox: viewBoxWhenMissing,
}),
width: resolvedSize,
height: resolvedSize,
};
return cloneElement(element, elementProps);
};
SvgNut.displayName = 'SvgNut';
export default SvgNut;