-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
42 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
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
57 changes: 57 additions & 0 deletions
57
app/scripts/components/common/map/controls/aoi/reset-aoi-control.tsx
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,57 @@ | ||
import React, { useCallback } from 'react'; | ||
import { CollecticonArrowLoop } from '@devseed-ui/collecticons'; | ||
import { Button } from '@devseed-ui/button'; | ||
import styled from 'styled-components'; | ||
import { useAtomValue, useSetAtom } from 'jotai'; | ||
import { themeVal } from '@devseed-ui/theme-provider'; | ||
import useThemedControl from '../hooks/use-themed-control'; | ||
import useMaps from '../../hooks/use-maps'; | ||
import { aoiDeleteAllAtom, aoisFeaturesAtom } from './atoms'; | ||
|
||
const SelectorButton = styled(Button)` | ||
&&& { | ||
background-color: ${themeVal('color.surface')}; | ||
&:hover { | ||
background-color: ${themeVal('color.surface')}; | ||
} | ||
} | ||
`; | ||
|
||
function ResetAoI({ map }: { map: any }) { | ||
const aoiDeleteAll = useSetAtom(aoiDeleteAllAtom); | ||
const aoisFeatures = useAtomValue(aoisFeaturesAtom); | ||
|
||
const onReset = useCallback(() => { | ||
const mbDraw = map?._drawControl; | ||
if (!mbDraw) return; | ||
mbDraw.deleteAll(); | ||
aoiDeleteAll(); | ||
}, [map, aoiDeleteAll]); | ||
|
||
return ( | ||
<> | ||
<SelectorButton | ||
fitting='skinny' | ||
variation='primary-fill' | ||
onClick={onReset} | ||
disabled={!aoisFeatures.length} | ||
> | ||
<CollecticonArrowLoop color='base' title='Upload geoJSON' meaningful /> | ||
</SelectorButton> | ||
</> | ||
); | ||
} | ||
|
||
export default function ResetAoIControl() { | ||
const { main } = useMaps(); | ||
useThemedControl( | ||
() => { | ||
return <ResetAoI map={main} />; | ||
}, | ||
{ | ||
position: 'top-left' | ||
} | ||
); | ||
return null; | ||
} |
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 |
---|---|---|
|
@@ -18,6 +18,6 @@ export default function useMaps() { | |
return { | ||
main, | ||
compared, | ||
current | ||
current, | ||
}; | ||
} |
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