]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/common/ZeldaIcon.js
tech title icons
[alttp.git] / resources / js / components / common / ZeldaIcon.js
index 84f2220672ce3e622031b96ea6064325df774ec8..9194cde7fc2f58b250f2e021a58c47e59bde9910 100644 (file)
@@ -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 }) =>
-<span className="zelda-icon">
-       <img
-               alt={i18n.t(`icon.zelda.${name}`)}
-               src={getIconURL(name)}
-               title={i18n.t(`icon.zelda.${name}`)}
-       />
-</span>;
+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 <span className="zelda-icon">
+               {src ?
+                       <img
+                               alt={title}
+                               src={src}
+                               title={title}
+                       />
+               : null}
+               {invert ?
+                       <span className="strike">
+                               <Icon.SLASH title="" />
+                       </span>
+               : null}
+       </span>;
+};
 
 ZeldaIcon.propTypes = {
        name: PropTypes.string,
 };
 
-export default withTranslation()(ZeldaIcon);
+export default ZeldaIcon;