X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fcommon%2FZeldaIcon.js;h=ef07b9207f3ecbc5bc0d9b28f76889b5be0a8495;hb=1e725fef6dc440aaeea8c30e1e0598dc5d24ad86;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..ef07b92 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,57 @@ 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 }) =>
-
-
-;
+const ZeldaIcon = ({ name, title }) => {
+ const { t } = useTranslation();
+
+ const invert = name.startsWith('not-');
+ const strippedName = invert ? name.substr(4) : name;
+ const src = getIconURL(strippedName);
+ const alt = t(`icon.zelda.${name}`);
+ const realTitle = title !== '' ? title || alt : null;
+
+ return
+ {src ?
+
+ : null}
+ {invert ?
+
+
+
+ : null}
+ ;
+};
ZeldaIcon.propTypes = {
name: PropTypes.string,
+ title: PropTypes.string,
};
-export default withTranslation()(ZeldaIcon);
+export default ZeldaIcon;