-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce discard changes modal (#400)
- Loading branch information
Showing
6 changed files
with
153 additions
and
26 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
50 changes: 50 additions & 0 deletions
50
...io/src/features/editing-experience/components/DiscardChangesModal/DiscardChangesModal.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,50 @@ | ||
import { | ||
HStack, | ||
Modal, | ||
ModalBody, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
Text, | ||
} from "@chakra-ui/react" | ||
import { Button, ModalCloseButton } from "@opengovsg/design-system-react" | ||
|
||
interface DiscardChangesModalProps { | ||
isOpen: boolean | ||
onClose: () => void | ||
onDiscard: () => void | ||
} | ||
|
||
export const DiscardChangesModal = ({ | ||
isOpen, | ||
onClose, | ||
onDiscard, | ||
}: DiscardChangesModalProps): JSX.Element => { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader> | ||
Are you sure you want to discard your changes? | ||
</ModalHeader> | ||
<ModalCloseButton /> | ||
|
||
<ModalBody> | ||
<Text textStyle="body-2">All edits will be lost.</Text> | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<HStack spacing="1rem"> | ||
<Button variant="clear" colorScheme="neutral" onClick={onClose}> | ||
Go back to editing | ||
</Button> | ||
<Button variant="solid" colorScheme="critical" onClick={onDiscard}> | ||
Yes, discard changes | ||
</Button> | ||
</HStack> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
apps/studio/src/features/editing-experience/components/DiscardChangesModal/index.ts
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 @@ | ||
export * from "./DiscardChangesModal" |
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