Skip to content
Source
Sign inSign up

EnvironmentMachineIcon.tsx

73 lines1.9 KB

1import type { EnvironmentMachineKind } from "@t3tools/contracts";
2import { CloudIcon, LaptopIcon, MonitorIcon, ServerIcon, type LucideProps } from "lucide-react";
3import type { FunctionComponent, SVGProps } from "react";
4import { LinuxIcon } from "./Icons";
5​
6function LucideLike(props: SVGProps<SVGSVGElement>) {
7 return (
8 <svg
9 xmlns="http://www.w3.org/2000/svg"
10 width="24"
11 height="24"
12 viewBox="0 0 24 24"
13 fill="none"
14 stroke="currentColor"
15 strokeWidth="1.75"
16 strokeLinecap="round"
17 strokeLinejoin="round"
18 {...props}
19 />
20 );
22​
23function MacMiniIcon(props: SVGProps<SVGSVGElement>) {
24 return (
25 <LucideLike {...props}>
26 <rect width="18" height="12" x="3" y="6" rx="2.5" />
27 <circle cx="7.5" cy="12" r="1" fill="currentColor" stroke="none" />
28 </LucideLike>
29 );
31​
32function MacStudioIcon(props: SVGProps<SVGSVGElement>) {
33 return (
34 <LucideLike {...props}>
35 <rect width="18" height="14" x="3" y="5" rx="2" />
36 <path d="M7 15h.01M11 15h.01M15 15h.01" />
37 </LucideLike>
38 );
40​
41const ICON_BY_KIND: Record<EnvironmentMachineKind, FunctionComponent<LucideProps>> = {
42 server: ServerIcon,
43 cloud: CloudIcon,
44 linux: LinuxIcon,
45 desktop: MonitorIcon,
46 laptop: LaptopIcon,
47 "mac-mini": MacMiniIcon,
48 "mac-studio": MacStudioIcon,
49};
50​
51export const ENVIRONMENT_MACHINE_KIND_LABELS: Record<EnvironmentMachineKind, string> = {
52 server: "Server",
53 cloud: "Cloud VM",
54 linux: "Linux/WSL",
55 desktop: "Desktop",
56 laptop: "Laptop",
57 "mac-mini": "Mini PC",
58 "mac-studio": "Workstation",
59};
60​
61export function environmentMachineIcon(
62 kind: EnvironmentMachineKind,
63): FunctionComponent<LucideProps> {
64 return ICON_BY_KIND[kind];
66​
67export function EnvironmentMachineIcon({
68 kind,
69 ...props
70}: LucideProps & { readonly kind: EnvironmentMachineKind }) {
71 const Icon = ICON_BY_KIND[kind];
72 return <Icon {...props} />;