X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fcommon%2FZeldaIcon.js;h=9194cde7fc2f58b250f2e021a58c47e59bde9910;hb=6976d85a7117de53f7d42dee3de1f6b8fcb9726d;hp=84f2220672ce3e622031b96ea6064325df774ec8;hpb=2110d91bc5016fd78aec02578b09506b6d67f45e;p=alttp.git diff --git a/resources/js/components/common/ZeldaIcon.js b/resources/js/components/common/ZeldaIcon.js index 84f2220..9194cde 100644 --- a/resources/js/components/common/ZeldaIcon.js +++ b/resources/js/components/common/ZeldaIcon.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; -import i18n from '../../i18n'; +import Icon from './Icon'; const getIconURL = name => { switch (name) { @@ -27,6 +27,7 @@ const getIconURL = name => { case 'ether': case 'fairy': case 'fighter-shield': + case 'fighter-sword': case 'fire-rod': case 'fire-shield': case 'flippers': @@ -59,22 +60,55 @@ const getIconURL = name => { case 'small-key': case 'somaria': return `/item/${name}.png`; + case 'dungeon-ct': + case 'dungeon-dp': + case 'dungeon-ep': + case 'dungeon-gt': + case 'dungeon-hc': + case 'dungeon-ip': + case 'dungeon-mm': + case 'dungeon-pd': + case 'dungeon-sp': + case 'dungeon-sw': + case 'dungeon-th': + case 'dungeon-tr': + case 'dungeon-tt': + return `/dungeon/${name.substr(8)}.png`; + case 'crystal-switch': + case 'crystal-switch-blue': + case 'crystal-switch-red': + return `/icon/${name}.png`; default: return ''; } }; -const ZeldaIcon = ({ name }) => - - {i18n.t(`icon.zelda.${name}`)} -; +const ZeldaIcon = ({ name }) => { + const { t } = useTranslation(); + + const invert = name.startsWith('not-'); + const strippedName = invert ? name.substr(4) : name; + const src = getIconURL(strippedName); + const title = t(`icon.zelda.${name}`); + + return + {src ? + {title} + : null} + {invert ? + + + + : null} + ; +}; ZeldaIcon.propTypes = { name: PropTypes.string, }; -export default withTranslation()(ZeldaIcon); +export default ZeldaIcon;