import clsx from "clsx"; import { useTranslation } from "react-i18next"; import type { TierName } from "~/features/mmr/mmr-constants"; import type { MainWeaponId, ModeShortWithSpecial, SpecialWeaponId, StageId, SubWeaponId, } from "~/modules/in-game-lists/types"; import { mainWeaponImageUrl, modeImageUrl, outlinedFiveStarMainWeaponImageUrl, outlinedMainWeaponImageUrl, specialWeaponImageUrl, stageImageUrl, subWeaponImageUrl, TIER_PLUS_URL, tierImageUrl, } from "~/utils/urls"; interface ImageProps { path: string; alt: string; title?: string; className?: string; containerClassName?: string; width?: number; height?: number; size?: number; style?: React.CSSProperties; containerStyle?: React.CSSProperties; testId?: string; onClick?: () => void; loading?: "lazy"; forcePng?: boolean; } export function Image({ path, alt, title, className, width, height, size, style, testId, containerClassName, containerStyle, onClick, loading, forcePng, }: ImageProps) { if (forcePng) { return ( // biome-ignore lint/a11y/noStaticElementInteractions: Biome v2 migration
{alt}
); } return ( // biome-ignore lint/a11y/noStaticElementInteractions: Biome v2 migration {alt} ); } type WeaponImageProps = { weaponSplId: MainWeaponId; variant: "badge" | "badge-5-star" | "build"; } & Omit; export function WeaponImage({ weaponSplId, variant, testId, title, ...rest }: WeaponImageProps) { const { t } = useTranslation(["weapons"]); return ( {title ); } type ModeImageProps = { mode: ModeShortWithSpecial; } & Omit; export function ModeImage({ mode, testId, title, ...rest }: ModeImageProps) { const { t } = useTranslation(["game-misc"]); return ( {title ); } type StageImageProps = { stageId: StageId; } & Omit; export function StageImage({ stageId, testId, ...rest }: StageImageProps) { const { t } = useTranslation(["game-misc"]); return ( {t(`game-misc:STAGE_${stageId}`)} ); } type SubWeaponImageProps = { subWeaponId: SubWeaponId; } & Omit; export function SubWeaponImage({ subWeaponId, testId, ...rest }: SubWeaponImageProps) { const { t } = useTranslation(["weapons"]); return ( {t(`weapons:SUB_${subWeaponId}`)} ); } type SpecialWeaponImageProps = { specialWeaponId: SpecialWeaponId; } & Omit; export function SpecialWeaponImage({ specialWeaponId, testId, ...rest }: SpecialWeaponImageProps) { const { t } = useTranslation(["weapons"]); return ( {t(`weapons:SPECIAL_${specialWeaponId}`)} ); } type TierImageProps = { tier: { name: TierName; isPlus: boolean }; } & Omit; export function TierImage({ tier, className, width = 200 }: TierImageProps) { const title = `${tier.name}${tier.isPlus ? "+" : ""}`; const height = width * 0.8675; return (
{title} {tier.isPlus ? ( {title} ) : null}
); }