mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-13 06:21:21 -05:00
no dynamic import test
This commit is contained in:
parent
b9d9b8a7d8
commit
bb87ef6f2f
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useState } from "react"
|
||||
import React from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Weapon } from "../../types.js"
|
||||
import english_internal from "../../utils/english_internal.json"
|
||||
|
|
@ -26,31 +26,21 @@ const WeaponImage: React.FC<WeaponImageProps> = ({
|
|||
asInlineBlock,
|
||||
noTitle,
|
||||
}) => {
|
||||
const [src, setSrc] = useState<string | null>(null)
|
||||
const { t } = useTranslation()
|
||||
const wh = sizeWhMap[size]
|
||||
|
||||
useEffect(() => {
|
||||
if (!english_internal) return
|
||||
import(
|
||||
`../../assets/weapons/Wst_${english_internal[englishName]}.png`
|
||||
).then((img) => setSrc(img.default))
|
||||
}, [english_internal])
|
||||
|
||||
return (
|
||||
<>
|
||||
{src && (
|
||||
<img
|
||||
src={src}
|
||||
alt={t(`game;${englishName}`)}
|
||||
title={noTitle ? undefined : t(`game;${englishName}`)}
|
||||
style={{
|
||||
width: wh,
|
||||
height: wh,
|
||||
display: asInlineBlock ? "inline-block" : undefined,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<img
|
||||
src={`https://raw.githubusercontent.com/Leanny/leanny.github.io/master/splat2/weapons/Wst_${english_internal[englishName]}.png`}
|
||||
alt={t(`game;${englishName}`)}
|
||||
title={noTitle ? undefined : t(`game;${englishName}`)}
|
||||
style={{
|
||||
width: wh,
|
||||
height: wh,
|
||||
display: asInlineBlock ? "inline-block" : undefined,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user