]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tracker/ToggleIcon.js
remove some useless svg groups
[alttp.git] / resources / js / components / tracker / ToggleIcon.js
index 6de9f63632652dea775d0eca42259e5f15d0425d..6dee8180f7be7bfdb3a80dc5819c26b68776f1ee 100644 (file)
@@ -8,6 +8,7 @@ import {
        getDungeonBoss,
        getDungeonRemainingItems,
        getDungeonPrize,
+       getGTBoss,
        hasDungeonBoss,
        hasDungeonPrize,
        highestActive,
@@ -18,11 +19,12 @@ import {
 } from '../../helpers/tracker';
 import { useTracker } from '../../hooks/tracker';
 
-const ToggleIcon = ({ controller, className, icons, svg }) => {
+const ToggleIcon = ({ controller, className, icons, svg, transform }) => {
        const { setManualState, state } = useTracker();
        const activeController = controller || ToggleIcon.nullController;
        const active = activeController.getActive(state, icons);
        const defaultIcon = activeController.getDefault(state, icons);
+       const icon = active || defaultIcon || icons[0];
        const classNames = ['toggle-icon'];
        if (active) {
                classNames.push('active');
@@ -35,6 +37,7 @@ const ToggleIcon = ({ controller, className, icons, svg }) => {
        if (svg) {
                return <g
                        className={classNames.join(' ')}
+                       data-icon={icon}
                        onClick={(e) => {
                                activeController.handlePrimary(state, setManualState, icons);
                                e.preventDefault();
@@ -45,8 +48,9 @@ const ToggleIcon = ({ controller, className, icons, svg }) => {
                                e.preventDefault();
                                e.stopPropagation();
                        }}
+                       transform={transform}
                >
-                       <ZeldaIcon name={active || defaultIcon || icons[0]} svg />
+                       <ZeldaIcon name={icon} svg />
                </g>;
        }
        return <span
@@ -201,6 +205,13 @@ ToggleIcon.dungeonPrizeController = (dungeon) => ({
        handleSecondary: previousString(`${dungeon.id}-prize`),
 });
 
+ToggleIcon.gtBossController = (which) => ({
+       getActive: (state) => getGTBoss(state, which),
+       getDefault: (state) => getGTBoss(state, which),
+       handlePrimary: nextString(`gt-${which}-boss`),
+       handleSecondary: previousString(`gt-${which}-boss`),
+});
+
 ToggleIcon.medallionController = {
        getActive: highestActive,
        getDefault: firstIcon,
@@ -257,6 +268,13 @@ ToggleIcon.nullController = {
        handleSecondary: doNothing,
 };
 
+ToggleIcon.pinController = (pin, removePin) => ({
+       getActive: firstIcon,
+       getDefault: firstIcon,
+       handlePrimary: doNothing,
+       handleSecondary: () => removePin(pin),
+});
+
 ToggleIcon.simpleController = {
        getActive: highestActive,
        getDefault: firstIcon,
@@ -287,6 +305,7 @@ ToggleIcon.propTypes = {
        }),
        icons: PropTypes.arrayOf(PropTypes.string),
        svg: PropTypes.bool,
+       transform: PropTypes.string,
 };
 
 export default ToggleIcon;