-
Notifications
You must be signed in to change notification settings - Fork 34
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
14 changed files
with
191 additions
and
107 deletions.
There are no files selected for viewing
14 changes: 10 additions & 4 deletions
14
packages/geoview-core/src/core/components/common/layer-title.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
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
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
86 changes: 86 additions & 0 deletions
86
packages/geoview-core/src/core/components/layers/left-panel/delete-undo-button.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,86 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { Box, CircularProgressBase, DeleteOutlineIcon, IconButton, UndoIcon } from '@/ui'; | ||
import { TypeLegendLayer } from '../types'; | ||
import { useLayerStoreActions } from '@/core/stores/store-interface-and-intial-values/layer-state'; | ||
|
||
interface DeleteUndoButtonProps { | ||
layer: TypeLegendLayer; | ||
} | ||
|
||
interface UndoButtonProps { | ||
progressValue: number; | ||
onUndo: () => void; | ||
} | ||
|
||
function UndoButtonWithProgress(props: UndoButtonProps): JSX.Element { | ||
const { progressValue, onUndo } = props; | ||
return ( | ||
<Box sx={{ position: 'relative', display: 'inline-flex' }} onClick={onUndo}> | ||
<CircularProgressBase variant="determinate" size={40} value={progressValue} /> | ||
<Box | ||
style={{ | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0, | ||
position: 'absolute', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<IconButton> | ||
<UndoIcon /> | ||
</IconButton> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
export function DeleteUndoButton(props: DeleteUndoButtonProps): JSX.Element { | ||
const { layer } = props; | ||
|
||
const [progress, setProgress] = useState(10); | ||
const [inUndoState, setInUndoState] = useState(false); | ||
|
||
// get store actions | ||
const { deleteLayer } = useLayerStoreActions(); | ||
|
||
const handleDeleteClick = () => { | ||
setInUndoState(true); | ||
}; | ||
|
||
const handleUndoClick = () => { | ||
setInUndoState(false); | ||
}; | ||
|
||
useEffect(() => { | ||
if (progress === 100) { | ||
deleteLayer(layer.layerPath); | ||
setInUndoState(false); | ||
} | ||
return undefined; | ||
}, [progress]); | ||
Check warning on line 63 in packages/geoview-core/src/core/components/layers/left-panel/delete-undo-button.tsx GitHub Actions / Build demo files / build-geoview
|
||
|
||
useEffect(() => { | ||
if (inUndoState) { | ||
const timer = setInterval(() => { | ||
setProgress((prevProgress) => (prevProgress >= 100 ? 0 : prevProgress + 10)); | ||
}, 800); | ||
return () => { | ||
clearInterval(timer); | ||
}; | ||
} | ||
setProgress(0); | ||
return undefined; | ||
}, [inUndoState]); | ||
|
||
if (!inUndoState) { | ||
return ( | ||
<IconButton onClick={handleDeleteClick}> | ||
<DeleteOutlineIcon style={{ fill: '#c51e3a' }} /> | ||
</IconButton> | ||
); | ||
} | ||
return <UndoButtonWithProgress progressValue={progress} onUndo={handleUndoClick} />; | ||
} |
Oops, something went wrong.