]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/common/ZeldaIcon.js
snes settings
[alttp.git] / resources / js / components / common / ZeldaIcon.js
index c5da0b554cbc242322ea3f8c2ab0a2510c50a23f..ef07b9207f3ecbc5bc0d9b28f76889b5be0a8495 100644 (file)
@@ -74,24 +74,32 @@ const getIconURL = name => {
                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 title = t(`icon.zelda.${name}`);
+       const src = getIconURL(strippedName);
+       const alt = t(`icon.zelda.${name}`);
+       const realTitle = title !== '' ? title || alt : null;
 
        return <span className="zelda-icon">
-               <img
-                       alt={title}
-                       src={getIconURL(strippedName)}
-                       title={title}
-               />
+               {src ?
+                       <img
+                               alt={alt}
+                               src={src}
+                               title={realTitle}
+                       />
+               : null}
                {invert ?
                        <span className="strike">
                                <Icon.SLASH title="" />
@@ -102,6 +110,7 @@ const ZeldaIcon = ({ name }) => {
 
 ZeldaIcon.propTypes = {
        name: PropTypes.string,
+       title: PropTypes.string,
 };
 
 export default ZeldaIcon;