-
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
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
import React, { useCallback, useContext, useEffect } from 'react'; | ||
import { CollecticonArrowLoop } from '@devseed-ui/collecticons'; | ||
import { Button, createButtonStyles } from '@devseed-ui/button'; | ||
import styled from 'styled-components'; | ||
import { themeVal } from '@devseed-ui/theme-provider'; | ||
import useThemedControl from '../hooks/use-themed-control'; | ||
import useMaps from '../../hooks/use-maps'; | ||
|
||
const SelectorButton = styled(Button)` | ||
&&& { | ||
${createButtonStyles({ variation: 'primary-fill', fitting: 'skinny' })} | ||
background-color: ${themeVal('color.surface')}; | ||
&:hover { | ||
background-color: ${themeVal('color.surface')}; | ||
} | ||
& path { | ||
fill: ${themeVal('color.base')}; | ||
} | ||
} | ||
`; | ||
|
||
function ResetAoI() { | ||
// This doesn't work as this Context is not reachable frome here :() | ||
const { main } = useMaps(); | ||
|
||
const onReset = useCallback(() => { | ||
const mbDraw = (main as any)?.instance?._drawControl; | ||
if (!mbDraw) return; | ||
mbDraw.trash(); | ||
}, [main]); | ||
|
||
return ( | ||
<> | ||
<SelectorButton onClick={onReset}> | ||
<CollecticonArrowLoop title='Upload geoJSON' meaningful /> | ||
</SelectorButton> | ||
</> | ||
); | ||
} | ||
|
||
export default function ResetAoIControl() { | ||
useThemedControl( | ||
() => { | ||
return <ResetAoI />; | ||
}, | ||
{ | ||
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