2023-10-17 21:25:54 +02:00
|
|
|
import classNames from "classnames";
|
|
|
|
import "flag-icons/css/flag-icons.min.css";
|
|
|
|
|
|
|
|
export interface FlagIconProps {
|
|
|
|
countryCode?: string;
|
|
|
|
}
|
|
|
|
|
2023-11-26 16:04:23 +01:00
|
|
|
// Country code overrides
|
|
|
|
const countryOverrides: Record<string, string> = {
|
|
|
|
en: "gb",
|
|
|
|
cs: "cz",
|
|
|
|
el: "gr",
|
|
|
|
fa: "ir",
|
|
|
|
ko: "kr",
|
|
|
|
he: "il",
|
|
|
|
ze: "cn",
|
|
|
|
ar: "sa",
|
|
|
|
ja: "jp",
|
|
|
|
bs: "ba",
|
|
|
|
vi: "vn",
|
|
|
|
zh: "cn",
|
|
|
|
sl: "si",
|
2023-12-16 18:39:59 +01:00
|
|
|
sv: "se",
|
2023-11-26 16:04:23 +01:00
|
|
|
};
|
2023-11-18 20:55:46 +01:00
|
|
|
|
2023-11-26 16:04:23 +01:00
|
|
|
export function FlagIcon(props: FlagIconProps) {
|
2023-11-18 20:55:46 +01:00
|
|
|
let countryCode =
|
|
|
|
(props.countryCode || "")?.split("-").pop()?.toLowerCase() || "";
|
|
|
|
if (countryOverrides[countryCode])
|
|
|
|
countryCode = countryOverrides[countryCode];
|
|
|
|
|
|
|
|
if (countryCode === "pirate")
|
|
|
|
return (
|
|
|
|
<div className="w-8 h-6 rounded bg-[#2E3439] flex justify-center items-center">
|
|
|
|
<img src="/skull.svg" className="w-4 h-4" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2023-12-16 01:48:26 +01:00
|
|
|
if (countryCode === "minion")
|
|
|
|
return (
|
|
|
|
<div className="w-8 h-6 rounded bg-[#ffff1a] flex justify-center items-center">
|
|
|
|
<div className="w-4 h-4 border-2 border-gray-500 rounded-full bg-white flex justify-center items-center">
|
|
|
|
<div className="w-1.5 h-1.5 rounded-full bg-gray-900 relative">
|
|
|
|
<div className="absolute top-0 left-0 w-1 h-1 bg-white rounded-full transform -translate-x-1/3 -translate-y-1/3" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2023-10-17 21:25:54 +02:00
|
|
|
return (
|
|
|
|
<span
|
|
|
|
className={classNames(
|
|
|
|
"!w-8 h-6 rounded overflow-hidden bg-video-context-flagBg bg-cover bg-center block fi",
|
2023-11-18 20:55:46 +01:00
|
|
|
props.countryCode ? `fi-${countryCode}` : undefined
|
2023-10-17 21:25:54 +02:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|