-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #672 from IntersectMBO/feat/646-implement-a-loadin…
…g-modal-for-the-validation-of-the-metadata [#646] feat: implement a loading modal for the metadata validation
- Loading branch information
Showing
19 changed files
with
223 additions
and
17 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
@keyframes spin { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
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,15 @@ | ||
import { ICONS } from "@/consts"; | ||
import "./Loader.css"; | ||
|
||
type Props = { | ||
size: number; | ||
}; | ||
export const Loader = ({ size = 100 }: Props) => ( | ||
<div style={{ width: size, height: size, margin: "0 auto" }}> | ||
<img | ||
src={ICONS.loaderIcon} | ||
style={{ animation: `spin 2s linear infinite` }} | ||
alt="loader" | ||
/> | ||
</div> | ||
); |
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 "./Loader"; |
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
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
govtool/frontend/src/components/organisms/Modal/LoadingModal.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,36 @@ | ||
import { Typography } from "@mui/material"; | ||
|
||
import { Loader, ModalContents, ModalHeader, ModalWrapper } from "@atoms"; | ||
import { useModal } from "@context"; | ||
import { useScreenDimension } from "@/hooks"; | ||
|
||
export interface LoadingModalState { | ||
message: React.ReactNode; | ||
title: string; | ||
dataTestId: string; | ||
} | ||
|
||
export const LoadingModal = () => { | ||
const { state } = useModal<LoadingModalState>(); | ||
const { isMobile } = useScreenDimension(); | ||
|
||
return ( | ||
<ModalWrapper | ||
dataTestId={state ? state.dataTestId : "loading-modal"} | ||
hideCloseButton | ||
> | ||
<Loader size={100} /> | ||
<ModalHeader sx={{ marginTop: "34px", px: isMobile ? 0 : 3 }}> | ||
{state?.title} | ||
</ModalHeader> | ||
<ModalContents> | ||
<Typography | ||
textAlign="center" | ||
sx={{ fontSize: "16px", fontWeight: "400" }} | ||
> | ||
{state?.message}{" "} | ||
</Typography> | ||
</ModalContents> | ||
</ModalWrapper> | ||
); | ||
}; |
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
File renamed without changes.
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,5 @@ | ||
export * from "./ChooseWalletModal"; | ||
export * from "./ExternalLinkModal"; | ||
export * from "./LoadingModal"; | ||
export * from "./StatusModal"; | ||
export * from "./VotingPowerModal"; |
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
67 changes: 67 additions & 0 deletions
67
govtool/frontend/src/stories/modals/LoadingModal.stories.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,67 @@ | ||
import { useEffect } from "react"; | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
|
||
import { Modal } from "@atoms"; | ||
import { LoadingModal, LoadingModalState } from "@organisms"; | ||
import { callAll } from "@utils"; | ||
import { useModal } from "../../context/modal"; | ||
|
||
const meta = { | ||
title: "Example/Modals/LoadingModal", | ||
component: LoadingModal, | ||
} satisfies Meta<typeof LoadingModal>; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<LoadingModalState> = ({ | ||
message, | ||
title, | ||
dataTestId, | ||
}) => { | ||
const { openModal, modal, modals, closeModal } = useModal(); | ||
|
||
const open = () => { | ||
openModal({ | ||
type: "loadingModal", | ||
state: { | ||
title, | ||
message, | ||
dataTestId, | ||
}, | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
open(); | ||
}, [openModal]); | ||
|
||
return ( | ||
<> | ||
<button type="button" onClick={open} style={{ cursor: "pointer" }}> | ||
Open Modal | ||
</button> | ||
<button type="button" onClick={closeModal} style={{ cursor: "pointer" }}> | ||
Close Modal | ||
</button> | ||
|
||
{modals[modal.type]?.component && ( | ||
<Modal | ||
open={Boolean(modals[modal.type].component)} | ||
handleClose={callAll(modals[modal.type]?.onClose, () => | ||
openModal({ type: "none", state: null }), | ||
)} | ||
> | ||
{modals[modal.type].component!} | ||
</Modal> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export const Loading = Template.bind({}); | ||
Loading.args = { | ||
message: | ||
"GovTool will read the URL that you supplied and make a check to see if it’s identical with the information that you entered on the form.", | ||
title: "GovTool Is Checking Your Data", | ||
dataTestId: "loading-modal", | ||
}; |
Oops, something went wrong.