0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): support close modal on esc pressed (#2627)

This commit is contained in:
Xiao Yijun 2022-12-09 19:57:28 +08:00 committed by GitHub
parent 6c2d3daf7e
commit d65e25a10e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 67 additions and 7 deletions

View file

@ -19,9 +19,11 @@ const Contact = ({ isOpen, onCancel }: Props) => {
return (
<ReactModal
shouldCloseOnEsc
isOpen={isOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={onCancel}
>
<ModalLayout title="contact.title" subtitle="contact.description" onClose={onCancel}>
<div className={styles.main}>

View file

@ -39,9 +39,11 @@ const ConfirmModal = ({
}: ConfirmModalProps) => {
return (
<ReactModal
shouldCloseOnEsc
isOpen={isOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={onCancel}
>
<ModalLayout
title={title}

View file

@ -59,9 +59,13 @@ const ApiResources = () => {
}}
/>
<Modal
shouldCloseOnEsc
isOpen={isCreateFormOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
setIsCreateFormOpen(false);
}}
>
<CreateForm
onClose={(createdApiResource) => {

View file

@ -118,7 +118,12 @@ const CreateForm = ({ onClose }: Props) => {
</FormField>
</form>
{createdApp && (
<Modal isOpen={isGetStartedModalOpen} className={modalStyles.fullScreen}>
<Modal
shouldCloseOnEsc
isOpen={isGetStartedModalOpen}
className={modalStyles.fullScreen}
onRequestClose={closeModal}
>
<Guide app={createdApp} onClose={closeModal} />
</Modal>
)}

View file

@ -54,18 +54,23 @@ const Applications = () => {
}}
/>
<Modal
shouldCloseOnEsc
isOpen={isCreateNew}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
navigate('/applications');
}}
>
<CreateForm
onClose={(createdApp) => {
navigate('/applications');
if (createdApp) {
toast.success(t('applications.application_created', { name: createdApp.name }));
navigate(`/applications/${createdApp.id}`);
return;
}
navigate('/applications');
}}
/>
</Modal>

View file

@ -124,9 +124,13 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
return (
<Modal
shouldCloseOnEsc
isOpen={isFormOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
onClose?.();
}}
>
<ModalLayout
title={cardTitle}
@ -179,7 +183,12 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
/>
)}
{activeFactory && (
<Modal isOpen={isGetStartedModalOpen} className={modalStyles.fullScreen}>
<Modal
shouldCloseOnEsc
isOpen={isGetStartedModalOpen}
className={modalStyles.fullScreen}
onRequestClose={closeModal}
>
<Guide connector={activeFactory} onClose={closeModal} />
</Modal>
)}

View file

@ -60,9 +60,13 @@ const ChangePassword = () => {
</div>
</FormField>
<ReactModal
shouldCloseOnEsc
isOpen={isOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
setIsOpen(false);
}}
>
<ModalLayout
title="settings.change_modal_title"

View file

@ -82,7 +82,12 @@ const GuideModal = ({ isOpen, onClose }: Props) => {
};
return (
<Modal isOpen={isOpen} className={modalStyles.fullScreen}>
<Modal
shouldCloseOnEsc
isOpen={isOpen}
className={modalStyles.fullScreen}
onRequestClose={onSkip}
>
<div className={styles.container}>
<div className={styles.header}>
<IconButton size="large" disabled={isLoading} onClick={onSkip}>

View file

@ -71,7 +71,13 @@ const LanguageEditorModal = ({ isOpen, onClose }: Props) => {
};
return (
<Modal isOpen={isOpen} className={styles.modalContent} overlayClassName={styles.modalOverlay}>
<Modal
shouldCloseOnEsc
isOpen={isOpen}
className={styles.modalContent}
overlayClassName={styles.modalOverlay}
onRequestClose={onCloseModal}
>
<Card className={styles.editor}>
<div className={styles.header}>
<CardTitle

View file

@ -41,7 +41,13 @@ const CreateSuccess = ({ username, password, title, onClose, passwordLabel }: Pr
}
return (
<ReactModal isOpen className={modalStyles.content} overlayClassName={modalStyles.overlay}>
<ReactModal
isOpen
shouldCloseOnEsc
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={onClose}
>
<ModalLayout
title={title}
footer={

View file

@ -138,9 +138,13 @@ const UserDetails = () => {
</ActionMenuItem>
</ActionMenu>
<ReactModal
shouldCloseOnEsc
isOpen={isResetPasswordFormOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
setIsResetPasswordFormOpen(false);
}}
>
<ResetPasswordForm
userId={data.id}

View file

@ -61,9 +61,13 @@ const Users = () => {
}}
/>
<Modal
shouldCloseOnEsc
isOpen={isCreateFormOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onRequestClose={() => {
setIsCreateFormOpen(false);
}}
>
<CreateForm
onClose={(createdUser, password) => {

View file

@ -27,6 +27,7 @@ const AcModal = ({
return (
<ReactModal
shouldCloseOnEsc
role="dialog"
isOpen={isOpen}
className={classNames(styles.modal, className)}
@ -34,6 +35,7 @@ const AcModal = ({
onAfterOpen={() => {
contentRef.current?.focus();
}}
onRequestClose={onClose}
>
<div
ref={contentRef}

View file

@ -18,10 +18,12 @@ const MobileModal = ({
}: ModalProps) => {
return (
<ReactModal
shouldCloseOnEsc
role="dialog"
isOpen={isOpen}
className={classNames(styles.modal, className)}
overlayClassName={classNames(modalStyles.overlay, styles.overlay)}
onRequestClose={onClose}
>
<div className={styles.container}>
<div className={styles.content}>{children}</div>