Skip to content

Commit c570803

Browse files
samejrmatt-aitken
authored andcommitted
New icon + name combo label for the machine preset
1 parent fa8c893 commit c570803

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { type MachinePresetName } from "@trigger.dev/core/v3";
2+
import { MachineIcon } from "~/assets/icons/MachineIcon";
3+
import { cn } from "~/utils/cn";
4+
5+
export function MachineLabelCombo({
6+
preset,
7+
className,
8+
iconClassName,
9+
labelClassName,
10+
}: {
11+
preset?: MachinePresetName | null;
12+
className?: string;
13+
iconClassName?: string;
14+
labelClassName?: string;
15+
}) {
16+
return (
17+
<span className={cn("flex items-center gap-1", className)}>
18+
<MachineIcon preset={preset ?? undefined} className={cn("size-5", iconClassName)} />
19+
<MachineLabel preset={preset} className={labelClassName} />
20+
</span>
21+
);
22+
}
23+
24+
export function MachineLabel({
25+
preset,
26+
className,
27+
}: {
28+
preset?: MachinePresetName | null;
29+
className?: string;
30+
}) {
31+
return (
32+
<span className={cn("text-text-dimmed", className)}>{formatMachinePresetName(preset)}</span>
33+
);
34+
}
35+
36+
export function formatMachinePresetName(preset?: MachinePresetName | null): string {
37+
if (!preset) {
38+
return "No machine yet";
39+
}
40+
41+
switch (preset) {
42+
case "micro":
43+
return "Micro";
44+
case "small-1x":
45+
return "Small 1x";
46+
case "small-2x":
47+
return "Small 2x";
48+
case "medium-1x":
49+
return "Medium 1x";
50+
case "medium-2x":
51+
return "Medium 2x";
52+
case "large-1x":
53+
return "Large 1x";
54+
case "large-2x":
55+
return "Large 2x";
56+
default:
57+
// Fallback for any unknown presets - capitalize first letter and replace hyphens with spaces
58+
return (preset as string)
59+
.split("-")
60+
.map((word: string) => word.charAt(0).toUpperCase() + word.slice(1))
61+
.join(" ");
62+
}
63+
}

0 commit comments

Comments
 (0)