143 lines
3.5 KiB
TypeScript
143 lines
3.5 KiB
TypeScript
import type { SVGProps, ReactNode } from "react";
|
|||
|
|
|
||
|
|
const PATHS: Record<string, ReactNode> = {
|
||
|
|
search: (
|
||
|
|
<>
|
||
|
|
<circle cx="11" cy="11" r="8" />
|
||
|
|
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
clipboard: (
|
||
|
|
<>
|
||
|
|
<rect x="6" y="4" width="12" height="17" rx="1" />
|
||
|
|
<rect x="9" y="2" width="6" height="4" rx="1" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
box: (
|
||
|
|
<>
|
||
|
|
<polygon points="12 2 21 7 21 17 12 22 3 17 3 7" />
|
||
|
|
<polyline points="3 7 12 12 21 7" />
|
||
|
|
<line x1="12" y1="12" x2="12" y2="22" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
edit: (
|
||
|
|
<>
|
||
|
|
<path d="M12 20h9" />
|
||
|
|
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
check: <polyline points="20 6 9 17 4 12" />,
|
||
|
|
trash: (
|
||
|
|
<>
|
||
|
|
<polyline points="3 6 5 6 21 6" />
|
||
|
|
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" />
|
||
|
|
<path d="M10 11v6" />
|
||
|
|
<path d="M14 11v6" />
|
||
|
|
<path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
close: (
|
||
|
|
<>
|
||
|
|
<line x1="18" y1="6" x2="6" y2="18" />
|
||
|
|
<line x1="6" y1="6" x2="18" y2="18" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
chart: (
|
||
|
|
<>
|
||
|
|
<line x1="6" y1="20" x2="6" y2="16" />
|
||
|
|
<line x1="12" y1="20" x2="12" y2="10" />
|
||
|
|
<line x1="18" y1="20" x2="18" y2="4" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
users: (
|
||
|
|
<>
|
||
|
|
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
|
||
|
|
<circle cx="9" cy="7" r="4" />
|
||
|
|
<path d="M23 21v-2a4 4 0 0 0-3-3.87" />
|
||
|
|
<path d="M16 3.13a4 4 0 0 1 0 7.75" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
cart: (
|
||
|
|
<>
|
||
|
|
<circle cx="9" cy="21" r="1" />
|
||
|
|
<circle cx="20" cy="21" r="1" />
|
||
|
|
<path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
briefcase: (
|
||
|
|
<>
|
||
|
|
<rect x="2" y="7" width="20" height="14" rx="2" />
|
||
|
|
<path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
tag: (
|
||
|
|
<>
|
||
|
|
<path d="M11 3H4a1 1 0 0 0-1 1v7a1 1 0 0 0 .29.71l9 9a1 1 0 0 0 1.42 0l7-7a1 1 0 0 0 0-1.42l-9-9A1 1 0 0 0 11 3z" />
|
||
|
|
<circle cx="7" cy="7" r="1.3" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
document: (
|
||
|
|
<>
|
||
|
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||
|
|
<polyline points="14 2 14 8 20 8" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
folder: <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />,
|
||
|
|
clock: (
|
||
|
|
<>
|
||
|
|
<circle cx="12" cy="12" r="10" />
|
||
|
|
<polyline points="12 6 12 12 16 14" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
lock: (
|
||
|
|
<>
|
||
|
|
<rect x="3" y="11" width="18" height="11" rx="2" />
|
||
|
|
<path d="M7 11V7a5 5 0 0 1 10 0v4" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
"check-circle": (
|
||
|
|
<>
|
||
|
|
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
|
||
|
|
<polyline points="22 4 12 14.01 9 11.01" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
"x-circle": (
|
||
|
|
<>
|
||
|
|
<circle cx="12" cy="12" r="10" />
|
||
|
|
<line x1="15" y1="9" x2="9" y2="15" />
|
||
|
|
<line x1="9" y1="9" x2="15" y2="15" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
cash: (
|
||
|
|
<>
|
||
|
|
<line x1="12" y1="1" x2="12" y2="23" />
|
||
|
|
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" />
|
||
|
|
</>
|
||
|
|
),
|
||
|
|
};
|
||
|
|
|
||
|
|
export type IconName = keyof typeof PATHS;
|
||
|
|
|
||
|
|
interface IconProps extends Omit<SVGProps<SVGSVGElement>, "name"> {
|
||
|
|
name: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default function Icon({ name, className = "w-4 h-4", ...rest }: IconProps) {
|
||
|
|
const content = PATHS[name];
|
||
|
|
if (!content) return null;
|
||
|
|
return (
|
||
|
|
<svg
|
||
|
|
viewBox="0 0 24 24"
|
||
|
|
fill="none"
|
||
|
|
stroke="currentColor"
|
||
|
|
strokeWidth={1.8}
|
||
|
|
strokeLinecap="round"
|
||
|
|
strokeLinejoin="round"
|
||
|
|
className={className}
|
||
|
|
aria-hidden="true"
|
||
|
|
{...rest}
|
||
|
|
>
|
||
|
|
{content}
|
||
|
|
</svg>
|
||
|
|
);
|
||
|
|
}
|