-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prettier formatting * Refactor resource menu show/hide The mobile resource menu modal shown state was being handled with its own action, TOGGLE_RESOURCE_MENU. Here we retire that action, and instead use SET_TOOLBAR_MODAL, which is consistent with how other toolbar modals' shown state is being handled on both mobile and desktop. * Refactor of resource selection Consolidate behavior of CHANGE_RESOURCE_TYPE and TOGGLE_RESOURCE_TYPE actions into one new action, SET_RESOURCE_TYPE. * Remove unused past component * Reorganize resource selection components Use consistent naming for mobile and desktop resource menu components, and bring to one location. * Remove currently unnecessary isMobile condition Currently the isMobile condition occurs on the parent component, and so is not needed in DesktopChooseResource.js. * Prefer hooks over using redux connect for dispatch * Remove unused import * Minor code order change * Fix - use redux variable directly, not from props * Use strict equality comparisons * Remove no longer used component * Close choose resource modal on mobile after click On mobile, we close the choose resource modal upon resource selection to conserve screen space. * Prefer using `createAction` * Change component name to ChooseResourceType * Share common data, tweak approach Share common data between Mobile and Desktop ChooseResourceType components. And, use a more consistent approach and naming for Desktop and Mobile. * Prefer `sx` over `style` prop for mui components * Use strict equality comparison * Fixes siteInfo test to match new selector value --------- Co-authored-by: Gabriel Cardona <2278918+gcardonag@users.noreply.github.com>
- Loading branch information
1 parent
8458c40
commit 7ff0aaf
Showing
19 changed files
with
300 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ build/ | |
|
||
# Unused files | ||
Legend.js | ||
TypeToggle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { useEffect } from "react"; | ||
|
||
const useOnClickOutside = (ref, callback) => { | ||
useEffect(() => { | ||
const listener = (event) => { | ||
if (!ref.current || ref.current.contains(event.target)) { | ||
return; | ||
} | ||
callback(event); | ||
}; | ||
document.addEventListener('mousedown', listener); | ||
document.addEventListener('touchstart', listener); | ||
return () => { | ||
document.removeEventListener('mousedown', listener); | ||
document.removeEventListener('touchstart', listener); | ||
}; | ||
}, [ref, callback]); | ||
}; | ||
export default useOnClickOutside; | ||
useEffect(() => { | ||
const listener = (event) => { | ||
if (!ref.current || ref.current.contains(event.target)) { | ||
return; | ||
} | ||
|
||
callback(event); | ||
}; | ||
|
||
document.addEventListener('mousedown', listener); | ||
document.addEventListener('touchstart', listener); | ||
|
||
return () => { | ||
document.removeEventListener('mousedown', listener); | ||
document.removeEventListener('touchstart', listener); | ||
}; | ||
}, [ref, callback]); | ||
}; | ||
|
||
export default useOnClickOutside; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import useIsMobile from 'hooks/useIsMobile'; | ||
import DesktopChooseResourceType from './DesktopChooseResourceType'; | ||
import MobileChooseResourceType from './MobileChooseResourceType'; | ||
import { ReactComponent as DesktopBathroomIcon } from '../icons/BathroomIconChooseResource.svg'; | ||
import { ReactComponent as DesktopFoodIcon } from '../icons/FoodIconChooseResource.svg'; | ||
import { ReactComponent as DesktopForagingIcon } from '../icons/ForagingIconChooseResource.svg'; | ||
import { ReactComponent as DesktopWaterIcon } from '../icons/WaterIconChooseResource.svg'; | ||
import { ReactComponent as MobileWaterIcon } from '../icons/WaterIconV2.svg'; | ||
import { ReactComponent as MobileFoodIcon } from '../icons/FoodIconV2.svg'; | ||
import { ReactComponent as MobileForagingIcon } from '../icons/ForagingIconV2.svg'; | ||
import { ReactComponent as MobileBathroomIcon } from '../icons/ToiletIconV2.svg'; | ||
import { | ||
WATER_RESOURCE_TYPE, | ||
FOOD_RESOURCE_TYPE, | ||
FORAGE_RESOURCE_TYPE, | ||
BATHROOM_RESOURCE_TYPE | ||
} from '../../types/ResourceEntry'; | ||
|
||
const resourceTypeInfo = [ | ||
{ | ||
type: WATER_RESOURCE_TYPE, | ||
textLabel: 'Water', | ||
color: "#5286E9", | ||
desktopIcon: DesktopWaterIcon, | ||
mobileIcon: MobileWaterIcon, | ||
}, | ||
{ | ||
type: FOOD_RESOURCE_TYPE, | ||
textLabel: 'Food', | ||
color: "#FF9A55", | ||
desktopIcon: DesktopFoodIcon, | ||
mobileIcon: MobileFoodIcon, | ||
}, | ||
{ | ||
type: FORAGE_RESOURCE_TYPE, | ||
textLabel: 'Foraging', | ||
color: "#5DA694", | ||
desktopIcon: DesktopForagingIcon, | ||
mobileIcon: MobileForagingIcon, | ||
}, | ||
{ | ||
type: BATHROOM_RESOURCE_TYPE, | ||
textLabel: 'Bathroom', | ||
color: "#9E9E9E", | ||
desktopIcon: DesktopBathroomIcon, | ||
mobileIcon: MobileBathroomIcon, | ||
} | ||
] | ||
|
||
const ChooseResourceType = () => { | ||
|
||
const isMobile = useIsMobile(); | ||
|
||
return ( | ||
<>{!isMobile ? | ||
<DesktopChooseResourceType resourceTypeInfo={resourceTypeInfo} /> | ||
: | ||
<MobileChooseResourceType resourceTypeInfo={resourceTypeInfo} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default ChooseResourceType; |
File renamed without changes.
Oops, something went wrong.