2024-05-09 15:22:48 +02:00
|
|
|
import { IconName } from "@/components/icons/IconPicker";
|
2024-02-21 21:07:32 +01:00
|
|
|
import { BsPersonWalking } from "react-icons/bs";
|
|
|
|
import {
|
|
|
|
FaAmazon,
|
2024-05-02 14:52:44 +02:00
|
|
|
FaBicycle,
|
|
|
|
FaBus,
|
2024-02-21 21:07:32 +01:00
|
|
|
FaCarSide,
|
|
|
|
FaCat,
|
2024-03-30 19:45:42 +01:00
|
|
|
FaCheckCircle,
|
2024-02-21 21:07:32 +01:00
|
|
|
FaDog,
|
|
|
|
FaFedex,
|
|
|
|
FaFire,
|
|
|
|
FaUps,
|
|
|
|
} from "react-icons/fa";
|
2024-05-29 20:06:48 +02:00
|
|
|
import { GiDeer, GiHummingbird } from "react-icons/gi";
|
2024-02-21 21:07:32 +01:00
|
|
|
import { LuBox, LuLassoSelect } from "react-icons/lu";
|
2024-05-09 15:22:48 +02:00
|
|
|
import * as LuIcons from "react-icons/lu";
|
2024-02-21 21:07:32 +01:00
|
|
|
import { MdRecordVoiceOver } from "react-icons/md";
|
|
|
|
|
2024-05-09 15:22:48 +02:00
|
|
|
export function isValidIconName(value: string): value is IconName {
|
|
|
|
return Object.keys(LuIcons).includes(value as IconName);
|
2024-03-05 00:18:30 +01:00
|
|
|
}
|
|
|
|
|
2024-02-21 21:07:32 +01:00
|
|
|
export function getIconForLabel(label: string, className?: string) {
|
2024-03-30 19:45:42 +01:00
|
|
|
if (label.endsWith("-verified")) {
|
|
|
|
return getVerifiedIcon(label, className);
|
|
|
|
}
|
|
|
|
|
2024-02-21 21:07:32 +01:00
|
|
|
switch (label) {
|
2024-05-02 14:52:44 +02:00
|
|
|
case "bicycle":
|
|
|
|
return <FaBicycle key={label} className={className} />;
|
|
|
|
case "bird":
|
|
|
|
return <GiHummingbird key={label} className={className} />;
|
|
|
|
case "bus":
|
|
|
|
return <FaBus key={label} className={className} />;
|
2024-02-21 21:07:32 +01:00
|
|
|
case "car":
|
2024-05-02 14:52:44 +02:00
|
|
|
case "vehicle":
|
2024-02-21 21:07:32 +01:00
|
|
|
return <FaCarSide key={label} className={className} />;
|
|
|
|
case "cat":
|
|
|
|
return <FaCat key={label} className={className} />;
|
2024-05-29 20:06:48 +02:00
|
|
|
case "deer":
|
|
|
|
return <GiDeer key={label} className={className} />;
|
2024-05-02 14:52:44 +02:00
|
|
|
case "animal":
|
2024-02-21 21:07:32 +01:00
|
|
|
case "bark":
|
|
|
|
case "dog":
|
|
|
|
return <FaDog key={label} className={className} />;
|
|
|
|
case "fire_alarm":
|
|
|
|
return <FaFire key={label} className={className} />;
|
|
|
|
case "package":
|
|
|
|
return <LuBox key={label} className={className} />;
|
|
|
|
case "person":
|
|
|
|
return <BsPersonWalking key={label} className={className} />;
|
2024-03-30 19:45:42 +01:00
|
|
|
// audio
|
2024-02-21 21:07:32 +01:00
|
|
|
case "crying":
|
|
|
|
case "laughter":
|
|
|
|
case "scream":
|
|
|
|
case "speech":
|
|
|
|
case "yell":
|
|
|
|
return <MdRecordVoiceOver key={label} className={className} />;
|
2024-03-30 19:45:42 +01:00
|
|
|
// sub labels
|
2024-02-21 21:07:32 +01:00
|
|
|
case "amazon":
|
|
|
|
return <FaAmazon key={label} className={className} />;
|
|
|
|
case "fedex":
|
|
|
|
return <FaFedex key={label} className={className} />;
|
|
|
|
case "ups":
|
|
|
|
return <FaUps key={label} className={className} />;
|
2024-03-30 19:45:42 +01:00
|
|
|
default:
|
|
|
|
return <LuLassoSelect key={label} className={className} />;
|
2024-02-21 21:07:32 +01:00
|
|
|
}
|
|
|
|
}
|
2024-03-30 19:45:42 +01:00
|
|
|
|
|
|
|
function getVerifiedIcon(label: string, className?: string) {
|
|
|
|
const simpleLabel = label.substring(0, label.lastIndexOf("-"));
|
|
|
|
|
|
|
|
return (
|
2024-04-01 16:20:27 +02:00
|
|
|
<div key={label} className="flex items-center">
|
2024-03-30 19:45:42 +01:00
|
|
|
{getIconForLabel(simpleLabel, className)}
|
|
|
|
<FaCheckCircle className="absolute size-2 translate-x-[80%] translate-y-3/4" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|