Open History to see the last commit
1import type { CSSProperties, SVGProps } from "react";
2
3import type { ProviderIcon } from "@t3tools/provider-core/client";
4
5import { cn } from "~/lib/utils";
6
7/**
8 * Draws a provider package's plain-data glyph. Theme colors travel as CSS
9 * variables so the `.dark` class switches them without a re-render.
10 */
11export function ProviderPackageIcon({
12 icon,
13 className,
14 ...props
15}: { readonly icon: ProviderIcon } & SVGProps<SVGSVGElement>) {
16 return (
17 <svg
18 {...props}
19 viewBox={icon.viewBox}
20 fill="none"
21 className={cn("fill-(--icon-light) dark:fill-(--icon-dark)", className)}
22 style={
23 {
24 "--icon-light": icon.fill.light,
25 "--icon-dark": icon.fill.dark,
26 } as CSSProperties
27 }
28 >
29 {icon.paths.map((path) => (
30 <path
31 key={path.d}
32 d={path.d}
33 fillRule={path.fillRule}
34 // Monochrome renderings (the collapsed composer) clear these detail paths.
35 data-icon-detail={path.fill ? true : undefined}
36 className={path.fill ? "fill-(--path-light) dark:fill-(--path-dark)" : undefined}
37 style={
38 path.fill
39 ? ({
40 "--path-light": path.fill.light,
41 "--path-dark": path.fill.dark,
42 } as CSSProperties)
43 : undefined
44 }
45 />
46 ))}
47 </svg>
48 );
49}