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 className={path.fill ? "fill-(--path-light) dark:fill-(--path-dark)" : undefined}
35 style={
36 path.fill
37 ? ({
38 "--path-light": path.fill.light,
39 "--path-dark": path.fill.dark,
40 } as CSSProperties)
41 : undefined
42 }
43 />
44 ))}
45 </svg>
46 );
47}