diff --git a/app/scripts/components/analysis/define/aoi-selector.tsx b/app/scripts/components/analysis/define/aoi-selector.tsx index 816b86a66..9bacd34b9 100644 --- a/app/scripts/components/analysis/define/aoi-selector.tsx +++ b/app/scripts/components/analysis/define/aoi-selector.tsx @@ -42,6 +42,7 @@ import { AoiChangeListenerOverload, AoiState } from '$components/common/aoi/types'; +import DropMenuItemButton from '$styles/drop-menu-item-button'; const MapContainer = styled.div` position: relative; @@ -75,15 +76,24 @@ export default function AoiSelector({ : null; }, [qsFeature]); - const setFeature = useCallback((feature: Feature) => { - onAoiEvent('aoi.set-feature', { feature }); - const featureBbox = bbox(feature) as [number, number, number, number]; - mapRef.current?.instance?.fitBounds(featureBbox, { padding: 32 }); - }, [onAoiEvent]); + const setFeature = useCallback( + (feature: Feature) => { + onAoiEvent('aoi.set-feature', { feature }); + const featureBbox = bbox(feature) as [number, number, number, number]; + mapRef.current?.instance?.fitBounds(featureBbox, { padding: 32 }); + }, + [onAoiEvent] + ); - const onRegionPresetClick = useCallback((preset: RegionPreset) => { - setFeature({ ...FeatureByRegionPreset[preset], id: 'region-preset-feature' }); - }, [setFeature]); + const onRegionPresetClick = useCallback( + (preset: RegionPreset) => { + setFeature({ + ...FeatureByRegionPreset[preset], + id: 'region-preset-feature' + }); + }, + [setFeature] + ); // Use the feature from the url qs or the region preset as the initial state to center the map. useEffect(() => { @@ -136,12 +146,11 @@ export default function AoiSelector({ Select a region
  • - onRegionPresetClick('world')} > World - +
  • diff --git a/app/scripts/components/analysis/define/index.tsx b/app/scripts/components/analysis/define/index.tsx index 02c735dba..12f34b0d3 100644 --- a/app/scripts/components/analysis/define/index.tsx +++ b/app/scripts/components/analysis/define/index.tsx @@ -48,6 +48,7 @@ import { getRangeFromPreset, inputFormatToDate } from '$utils/date'; +import DropMenuItemButton from '$styles/drop-menu-item-button'; const FormBlock = styled.div` display: flex; @@ -268,40 +269,32 @@ export default function Analysis() { Select a date preset
  • - onDatePresetClick(e, 'yearToDate')} > This year - +
  • - onDatePresetClick(e, 'last30Days')} > Last 30 days - +
  • - onDatePresetClick(e, 'lastYear')} > Last year - +
  • - onDatePresetClick(e, 'last10Years')} > Last 10 years - +
  • diff --git a/app/scripts/styles/drop-menu-item-button.tsx b/app/scripts/styles/drop-menu-item-button.tsx new file mode 100644 index 000000000..9f43bd8e7 --- /dev/null +++ b/app/scripts/styles/drop-menu-item-button.tsx @@ -0,0 +1,14 @@ +import styled from 'styled-components'; +import { DropMenuItem } from '@devseed-ui/dropdown'; + +const DropMenuItemButton = styled(DropMenuItem).attrs({ + as: 'button', + 'data-dropdown': 'click.close' +})` + background: none; + border: none; + width: 100%; + cursor: pointer; +`; + +export default DropMenuItemButton;