mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-18 21:20:55 -05:00
* fix for firefox * There is no need in placeholder - we can just don't render img if there is no weapon * early return Co-authored-by: Kalle (Sendou) <38327916+Sendouc@users.noreply.github.com>
37 lines
782 B
TypeScript
37 lines
782 B
TypeScript
import { t } from "@lingui/macro";
|
|
import { useLingui } from "@lingui/react";
|
|
import Image from "next/image";
|
|
import React from "react";
|
|
|
|
interface WeaponImageProps {
|
|
name: string;
|
|
size: 32 | 64 | 128;
|
|
noTitle?: boolean;
|
|
}
|
|
|
|
const WeaponImage: React.FC<WeaponImageProps> = ({ name, size, noTitle }) => {
|
|
const { i18n } = useLingui();
|
|
|
|
if (!name) return <></>;
|
|
|
|
return (
|
|
<Image
|
|
src={`/weapons/${name.replace(".", "").trim()}.png`}
|
|
alt={i18n._(name)}
|
|
title={getTitle()}
|
|
width={size}
|
|
height={size}
|
|
/>
|
|
);
|
|
|
|
function getTitle() {
|
|
if (noTitle) return undefined;
|
|
if (name === "RANDOM") return t`Random`;
|
|
if (name === "RANDOM_GRIZZCO") return t`Random (Grizzco)`;
|
|
|
|
return i18n._(name);
|
|
}
|
|
};
|
|
|
|
export default WeaponImage;
|