1 import React from 'react';
2 import { Helmet } from 'react-helmet';
4 import ZeldaIcon from '../components/common/ZeldaIcon';
38 const ITEM_CLASSES = {
39 'compass': 'dungeon-item',
40 'map': 'dungeon-item',
41 'big-key': 'dungeon-item',
48 'fighter-sword': 'item',
54 const nextCSwitch = cur => {
65 const prevCSwitch = cur => nextCSwitch(nextCSwitch(cur));
67 export const Component = () => {
68 const [state, setState] = React.useState(DUNGEONS.reduce((state, dungeon) => ({
70 [dungeon]: ITEMS.reduce((items, item) => ({
80 const handleItemClick = React.useCallback((dungeon, item) => e => {
85 [item]: !state[dungeon][item],
92 const handleCSwitchClick = React.useCallback(dungeon => e => {
97 cswitch: nextCSwitch(state[dungeon].cswitch),
104 const handleCSwitchRightClick = React.useCallback(dungeon => e => {
109 cswitch: prevCSwitch(state[dungeon].cswitch),
116 const handleKeysClick = React.useCallback(dungeon => e => {
121 keys: state[dungeon].keys + 1,
128 const handleKeysRightClick = React.useCallback(dungeon => e => {
133 keys: Math.max(state[dungeon].keys - 1, 0),
142 <title>Doors Tracker</title>
143 <meta name="description" content="Doors Tracker" />
145 <div className="doors-tracker d-flex flex-column">
146 {DUNGEONS.map(dungeon =>
147 <div className="d-flex flex-row" key={dungeon}>
149 className={`cell ${state[dungeon].boss ? 'on' : 'off'} dungeon`}
150 onClick={handleItemClick(dungeon, 'boss')}
152 <ZeldaIcon name={`dungeon-${dungeon}`} />
155 className={`cell ${state[dungeon].keys ? 'on' : 'off'} keys`}
156 onClick={handleKeysClick(dungeon)}
157 onContextMenu={handleKeysRightClick(dungeon)}
159 {state[dungeon].keys}
162 className={`cell ${state[dungeon].cswitch ? 'on' : 'off'} cswitch`}
163 onClick={handleCSwitchClick(dungeon)}
164 onContextMenu={handleCSwitchRightClick(dungeon)}
166 <ZeldaIcon name={state[dungeon].cswitch
167 ? `crystal-switch-${state[dungeon].cswitch}`
174 `cell ${state[dungeon][item] ? 'on' : 'off'} ${ITEM_CLASSES[item]}`
177 onClick={handleItemClick(dungeon, item)}
179 <ZeldaIcon name={item} />