From d583311de7aeb8baf57c356638f004865c5affcc Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Thu, 26 Jan 2023 22:08:12 +0530 Subject: [PATCH] refactor: modals --- .../CameraCaptureModal/PhotoCaptureModal.tsx | 2 +- .../CameraCaptureModal/VideoCaptureModal.tsx | 2 +- .../ChallengeModal/ChallengeModal.tsx | 46 +- .../ChangeEditor/ChangeEditorMenu.tsx | 2 +- .../ChangeEditor/ChangeMultipleMenu.tsx | 2 +- .../Header/AddItemMenuButton.tsx | 2 +- .../FilePreview/FilePreviewModal.tsx | 438 +++++++++--------- .../Components/ImportModal/ImportModal.tsx | 4 +- .../{Shared => Modal}/MobileModalAction.tsx | 0 .../Components/Modal/MobileModalHeader.tsx | 13 + .../Components/{Shared => Modal}/Modal.tsx | 40 +- .../ModalAndroidBackHandler.tsx | 0 .../{Shared => Modal}/ModalDialogButtons.tsx | 17 +- .../{Shared => Modal}/ModalOverlay.tsx | 18 +- .../{Shared => Modal}/useModalAnimation.ts | 0 .../NoteView/SuperEditor/SuperEditor.tsx | 2 +- .../SuperEditor/SuperNoteImporter.tsx | 2 +- .../SuperEditor/SuperNoteMarkdownPreview.tsx | 2 +- .../PasswordWizard/PasswordWizard.tsx | 2 +- .../PermissionsModal/PermissionsModal.tsx | 16 +- .../PermissionsModalWrapper.tsx | 2 +- .../Popover/MobilePopoverContent.tsx | 9 +- .../Panes/Account/ChangeEmail/ChangeEmail.tsx | 2 +- .../Preferences/Panes/Account/Credentials.tsx | 2 +- .../SubscriptionSharing/Invite/Invite.tsx | 2 +- .../SubscriptionSharing.tsx | 2 +- .../General/SmartViews/EditSmartViewModal.tsx | 2 +- .../Panes/General/SmartViews/SmartViews.tsx | 2 +- .../TwoFactorAuthView/TwoFactorAuthView.tsx | 4 +- .../Preferences/PreferencesView.tsx | 7 +- .../Preferences/PreferencesViewWrapper.tsx | 2 +- .../HistoryModalDialogContent.tsx | 7 +- .../RevisionHistoryModal.tsx | 2 +- .../SessionsModal/SessionsModal.tsx | 4 +- .../Components/Shared/ModalDialog.tsx | 29 -- .../Shared/ModalDialogDescription.tsx | 13 - .../Components/Shared/ModalDialogLabel.tsx | 74 --- .../SmartViewBuilder/AddSmartViewModal.tsx | 2 +- .../Components/Tags/SmartViewsSection.tsx | 2 +- 39 files changed, 333 insertions(+), 446 deletions(-) rename packages/web/src/javascripts/Components/{Shared => Modal}/MobileModalAction.tsx (100%) create mode 100644 packages/web/src/javascripts/Components/Modal/MobileModalHeader.tsx rename packages/web/src/javascripts/Components/{Shared => Modal}/Modal.tsx (87%) rename packages/web/src/javascripts/Components/{Shared => Modal}/ModalAndroidBackHandler.tsx (100%) rename packages/web/src/javascripts/Components/{Shared => Modal}/ModalDialogButtons.tsx (58%) rename packages/web/src/javascripts/Components/{Shared => Modal}/ModalOverlay.tsx (54%) rename packages/web/src/javascripts/Components/{Shared => Modal}/useModalAnimation.ts (100%) delete mode 100644 packages/web/src/javascripts/Components/Shared/ModalDialog.tsx delete mode 100644 packages/web/src/javascripts/Components/Shared/ModalDialogDescription.tsx delete mode 100644 packages/web/src/javascripts/Components/Shared/ModalDialogLabel.tsx diff --git a/packages/web/src/javascripts/Components/CameraCaptureModal/PhotoCaptureModal.tsx b/packages/web/src/javascripts/Components/CameraCaptureModal/PhotoCaptureModal.tsx index 74727a017..4015c3b01 100644 --- a/packages/web/src/javascripts/Components/CameraCaptureModal/PhotoCaptureModal.tsx +++ b/packages/web/src/javascripts/Components/CameraCaptureModal/PhotoCaptureModal.tsx @@ -7,7 +7,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import Dropdown from '../Dropdown/Dropdown' import Icon from '../Icon/Icon' import DecoratedInput from '../Input/DecoratedInput' -import Modal from '../Shared/Modal' +import Modal from '../Modal/Modal' type Props = { filesController: FilesController diff --git a/packages/web/src/javascripts/Components/CameraCaptureModal/VideoCaptureModal.tsx b/packages/web/src/javascripts/Components/CameraCaptureModal/VideoCaptureModal.tsx index 45fb23795..4bcde2d6f 100644 --- a/packages/web/src/javascripts/Components/CameraCaptureModal/VideoCaptureModal.tsx +++ b/packages/web/src/javascripts/Components/CameraCaptureModal/VideoCaptureModal.tsx @@ -6,7 +6,7 @@ import { observer } from 'mobx-react-lite' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import Icon from '../Icon/Icon' import DecoratedInput from '../Input/DecoratedInput' -import Modal from '../Shared/Modal' +import Modal from '../Modal/Modal' type Props = { filesController: FilesController diff --git a/packages/web/src/javascripts/Components/ChallengeModal/ChallengeModal.tsx b/packages/web/src/javascripts/Components/ChallengeModal/ChallengeModal.tsx index 029d34fce..931b902c7 100644 --- a/packages/web/src/javascripts/Components/ChallengeModal/ChallengeModal.tsx +++ b/packages/web/src/javascripts/Components/ChallengeModal/ChallengeModal.tsx @@ -1,5 +1,4 @@ import { WebApplication } from '@/Application/Application' -import { DialogContent, DialogOverlay } from '@reach/dialog' import { ButtonType, Challenge, @@ -21,8 +20,10 @@ import { ChallengeModalValues } from './ChallengeModalValues' import { InputValue } from './InputValue' import { isIOS, isMobileScreen } from '@/Utils' import { classNames } from '@standardnotes/utils' -import MobileModalAction from '../Shared/MobileModalAction' -import { useModalAnimation } from '../Shared/useModalAnimation' +import MobileModalAction from '../Modal/MobileModalAction' +import MobileModalHeader from '../Modal/MobileModalHeader' +import ModalOverlay from '../Modal/ModalOverlay' +import Modal from '../Modal/Modal' type Props = { application: WebApplication @@ -211,38 +212,35 @@ const ChallengeModal: FunctionComponent = ({ } }, [application, cancelChallenge, challenge.cancelable]) - const [isMounted, setElement] = useModalAnimation(!!challenge.prompts.length) - - if (!isMounted) { - return null - } - const isFullScreenBlocker = challenge.reason === ChallengeReason.ApplicationUnlock const isMobileOverlay = isMobileScreen() && !isFullScreenBlocker return ( - - -
-
+ {challenge.cancelable ? ( Cancel @@ -252,8 +250,8 @@ const ChallengeModal: FunctionComponent = ({ )}
Authenticate
-
-
+ +
*/} {challenge.cancelable && ( , - ]} - ref={mergeRefs([renameInputRef, focusInputOnMount])} - /> - ) : ( - {currentFile.name} - )} - -
- +
+
+
{IconComponent}
+ {isRenaming ? ( + { + if (event.key === KeyboardKey.Enter) { + void handleRename() + } + }} + right={[ - - - - - - - - { + + , + ]} + ref={mergeRefs([renameInputRef, focusInputOnMount])} + /> + ) : ( + {currentFile.name} + )} +
+
+ + + + + + + + + + { + setShowOptionsMenu(false) + }} + side="bottom" + align="start" + className="py-2" + overrideZIndex="z-modal" + > + + { setShowOptionsMenu(false) }} - side="bottom" - align="start" - className="py-2" - overrideZIndex="z-modal" - > - - { - setShowOptionsMenu(false) - }} - shouldShowRenameOption={false} - shouldShowAttachOption={false} - /> - - - - - - -
-
- {showLinkedBubblesContainer && ( -
- -
- )} -
-
- -
- {showFileInfoPanel && } -
+ + + + + +
-
-
- ) - }), -) + + {showLinkedBubblesContainer && ( +
+ +
+ )} +
+
+ +
+ {showFileInfoPanel && } +
+ + + ) +}) FilePreviewModal.displayName = 'FilePreviewModal' const FilePreviewModalWrapper: FunctionComponent = ({ application, viewControllerManager }) => { - const [isMounted, setElement] = useModalAnimation(viewControllerManager.filePreviewModalController.isOpen) - - if (!isMounted) { - return null - } - - return + return ( + + + + ) } export default observer(FilePreviewModalWrapper) diff --git a/packages/web/src/javascripts/Components/ImportModal/ImportModal.tsx b/packages/web/src/javascripts/Components/ImportModal/ImportModal.tsx index bb19c48d7..51a531f85 100644 --- a/packages/web/src/javascripts/Components/ImportModal/ImportModal.tsx +++ b/packages/web/src/javascripts/Components/ImportModal/ImportModal.tsx @@ -8,8 +8,8 @@ import { useStateRef } from '@/Hooks/useStateRef' import { ImportModalFileItem } from './ImportModalFileItem' import ImportModalInitialPage from './InitialPage' import { ImportModalAction, ImportModalFile, ImportModalState } from './Types' -import Modal, { ModalAction } from '../Shared/Modal' -import ModalOverlay from '../Shared/ModalOverlay' +import Modal, { ModalAction } from '../Modal/Modal' +import ModalOverlay from '../Modal/ModalOverlay' const reducer = (state: ImportModalState, action: ImportModalAction): ImportModalState => { switch (action.type) { diff --git a/packages/web/src/javascripts/Components/Shared/MobileModalAction.tsx b/packages/web/src/javascripts/Components/Modal/MobileModalAction.tsx similarity index 100% rename from packages/web/src/javascripts/Components/Shared/MobileModalAction.tsx rename to packages/web/src/javascripts/Components/Modal/MobileModalAction.tsx diff --git a/packages/web/src/javascripts/Components/Modal/MobileModalHeader.tsx b/packages/web/src/javascripts/Components/Modal/MobileModalHeader.tsx new file mode 100644 index 000000000..e8bc7426d --- /dev/null +++ b/packages/web/src/javascripts/Components/Modal/MobileModalHeader.tsx @@ -0,0 +1,13 @@ +import { classNames } from '@standardnotes/utils' +import { ReactNode } from 'react' + +type Props = { + className?: string + children: ReactNode +} + +const MobileModalHeader = ({ className, children }: Props) => { + return
{children}
+} + +export default MobileModalHeader diff --git a/packages/web/src/javascripts/Components/Shared/Modal.tsx b/packages/web/src/javascripts/Components/Modal/Modal.tsx similarity index 87% rename from packages/web/src/javascripts/Components/Shared/Modal.tsx rename to packages/web/src/javascripts/Components/Modal/Modal.tsx index 7b0749b9a..459553579 100644 --- a/packages/web/src/javascripts/Components/Shared/Modal.tsx +++ b/packages/web/src/javascripts/Components/Modal/Modal.tsx @@ -1,14 +1,14 @@ import { useMediaQuery, MutuallyExclusiveMediaQueryBreakpoints } from '@/Hooks/useMediaQuery' import { isIOS } from '@/Utils' -import { AlertDialogContent, AlertDialogLabel } from '@reach/alert-dialog' +import { DialogContent } from '@reach/dialog' import { classNames } from '@standardnotes/snjs' import { ReactNode, useMemo, useRef, useState } from 'react' import Button from '../Button/Button' import Icon from '../Icon/Icon' import Popover from '../Popover/Popover' import MobileModalAction from './MobileModalAction' +import MobileModalHeader from './MobileModalHeader' import ModalAndroidBackHandler from './ModalAndroidBackHandler' -import ModalDialogDescription from './ModalDialogDescription' export type ModalAction = { label: NonNullable @@ -28,11 +28,21 @@ type Props = { description?: string } customHeader?: ReactNode + disableCustomHeader?: boolean customFooter?: ReactNode children: ReactNode } -const Modal = ({ title, close, actions = [], className = {}, customHeader, customFooter, children }: Props) => { +const Modal = ({ + title, + close, + actions = [], + className = {}, + customHeader, + disableCustomHeader = false, + customFooter, + children, +}: Props) => { const sortedActions = useMemo( () => actions @@ -75,7 +85,6 @@ const Modal = ({ title, close, actions = [], className = {}, customHeader, custo const leftSlotAction = sortedActions.find((action) => action.mobileSlot === 'left') const rightSlotAction = sortedActions.find((action) => action.mobileSlot === 'right') - const hasCancelAction = sortedActions.some((action) => action.type === 'cancel') const firstPrimaryActionIndex = sortedActions.findIndex((action) => action.type === 'primary') const extraActions = sortedActions.filter((action) => action.type !== 'primary' && action.type !== 'cancel') @@ -86,23 +95,24 @@ const Modal = ({ title, close, actions = [], className = {}, customHeader, custo return ( <> - - {customHeader ? ( + {customHeader && !disableCustomHeader ? ( customHeader ) : ( - -
+ {leftSlotAction ? ( {rightSlotAction.label} - ) : sortedActions.length === 0 || !hasCancelAction ? ( - ) : null} -
-
+ + )} - {children} +
{children}
{customFooter ? customFooter : sortedActions.length > 0 && ( @@ -207,7 +215,7 @@ const Modal = ({ title, close, actions = [], className = {}, customHeader, custo ))} )} -
+ ) } diff --git a/packages/web/src/javascripts/Components/Shared/ModalAndroidBackHandler.tsx b/packages/web/src/javascripts/Components/Modal/ModalAndroidBackHandler.tsx similarity index 100% rename from packages/web/src/javascripts/Components/Shared/ModalAndroidBackHandler.tsx rename to packages/web/src/javascripts/Components/Modal/ModalAndroidBackHandler.tsx diff --git a/packages/web/src/javascripts/Components/Shared/ModalDialogButtons.tsx b/packages/web/src/javascripts/Components/Modal/ModalDialogButtons.tsx similarity index 58% rename from packages/web/src/javascripts/Components/Shared/ModalDialogButtons.tsx rename to packages/web/src/javascripts/Components/Modal/ModalDialogButtons.tsx index 02023ba4a..fc686091b 100644 --- a/packages/web/src/javascripts/Components/Shared/ModalDialogButtons.tsx +++ b/packages/web/src/javascripts/Components/Modal/ModalDialogButtons.tsx @@ -8,14 +8,15 @@ type Props = { } const ModalDialogButtons: FunctionComponent = ({ children, className }) => ( - <> -
-
- {children} -
- +
+ {children} +
) export default ModalDialogButtons diff --git a/packages/web/src/javascripts/Components/Shared/ModalOverlay.tsx b/packages/web/src/javascripts/Components/Modal/ModalOverlay.tsx similarity index 54% rename from packages/web/src/javascripts/Components/Shared/ModalOverlay.tsx rename to packages/web/src/javascripts/Components/Modal/ModalOverlay.tsx index 1b21d7fcb..51836c494 100644 --- a/packages/web/src/javascripts/Components/Shared/ModalOverlay.tsx +++ b/packages/web/src/javascripts/Components/Modal/ModalOverlay.tsx @@ -1,18 +1,16 @@ -import { AlertDialogOverlay } from '@reach/alert-dialog' +import { DialogOverlay, DialogOverlayProps } from '@reach/dialog' import { classNames } from '@standardnotes/snjs' -import { ReactNode, useRef } from 'react' -import { useModalAnimation } from './useModalAnimation' +import { ReactNode } from 'react' +import { useModalAnimation } from '../Modal/useModalAnimation' type Props = { isOpen: boolean onDismiss?: () => void children: ReactNode className?: string -} - -const ModalOverlay = ({ isOpen, onDismiss, children, className }: Props) => { - const ldRef = useRef(null) +} & DialogOverlayProps +const ModalOverlay = ({ isOpen, onDismiss, children, className, ...props }: Props) => { const [isMounted, setElement] = useModalAnimation(isOpen) if (!isMounted) { @@ -20,14 +18,14 @@ const ModalOverlay = ({ isOpen, onDismiss, children, className }: Props) => { } return ( - {children} - + ) } diff --git a/packages/web/src/javascripts/Components/Shared/useModalAnimation.ts b/packages/web/src/javascripts/Components/Modal/useModalAnimation.ts similarity index 100% rename from packages/web/src/javascripts/Components/Shared/useModalAnimation.ts rename to packages/web/src/javascripts/Components/Modal/useModalAnimation.ts diff --git a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx index d31035b5f..ccfacd59e 100644 --- a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx +++ b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx @@ -40,7 +40,7 @@ import { getPlaintextFontSize } from '@/Utils/getPlaintextFontSize' import ReadonlyPlugin from './Plugins/ReadonlyPlugin/ReadonlyPlugin' import { SuperSearchContextProvider } from './Plugins/SearchPlugin/Context' import { SearchPlugin } from './Plugins/SearchPlugin/SearchPlugin' -import ModalOverlay from '@/Components/Shared/ModalOverlay' +import ModalOverlay from '@/Components/Modal/ModalOverlay' const NotePreviewCharLimit = 160 diff --git a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteImporter.tsx b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteImporter.tsx index af02e13e2..e66590875 100644 --- a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteImporter.tsx +++ b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteImporter.tsx @@ -6,7 +6,7 @@ import { ErrorBoundary } from '@/Utils/ErrorBoundary' import ImportPlugin from './Plugins/ImportPlugin/ImportPlugin' import { NoteViewController } from '../Controller/NoteViewController' import { spaceSeparatedStrings } from '@standardnotes/utils' -import Modal, { ModalAction } from '@/Components/Shared/Modal' +import Modal, { ModalAction } from '@/Components/Modal/Modal' const NotePreviewCharLimit = 160 diff --git a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteMarkdownPreview.tsx b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteMarkdownPreview.tsx index 006156b88..452d21312 100644 --- a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteMarkdownPreview.tsx +++ b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperNoteMarkdownPreview.tsx @@ -6,7 +6,7 @@ import MarkdownPreviewPlugin from './Plugins/MarkdownPreviewPlugin/MarkdownPrevi import { FileNode } from './Plugins/EncryptedFilePlugin/Nodes/FileNode' import { BubbleNode } from './Plugins/ItemBubblePlugin/Nodes/BubbleNode' import { copyTextToClipboard } from '../../../Utils/copyTextToClipboard' -import Modal, { ModalAction } from '@/Components/Shared/Modal' +import Modal, { ModalAction } from '@/Components/Modal/Modal' type Props = { note: SNNote diff --git a/packages/web/src/javascripts/Components/PasswordWizard/PasswordWizard.tsx b/packages/web/src/javascripts/Components/PasswordWizard/PasswordWizard.tsx index 5cf11b59f..be07739d4 100644 --- a/packages/web/src/javascripts/Components/PasswordWizard/PasswordWizard.tsx +++ b/packages/web/src/javascripts/Components/PasswordWizard/PasswordWizard.tsx @@ -2,7 +2,7 @@ import { WebApplication } from '@/Application/Application' import { createRef } from 'react' import { AbstractComponent } from '@/Components/Abstract/PureComponent' import DecoratedPasswordInput from '../Input/DecoratedPasswordInput' -import Modal from '../Shared/Modal' +import Modal from '../Modal/Modal' import { isMobileScreen } from '@/Utils' import Spinner from '../Spinner/Spinner' diff --git a/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModal.tsx b/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModal.tsx index b2c5c391e..20c1a0dce 100644 --- a/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModal.tsx +++ b/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModal.tsx @@ -1,8 +1,8 @@ import { SNComponent } from '@standardnotes/snjs' import { useCallback } from 'react' import Button from '@/Components/Button/Button' -import ModalDialogButtons from '../Shared/ModalDialogButtons' -import Modal from '../Shared/Modal' +import ModalDialogButtons from '../Modal/ModalDialogButtons' +import Modal from '../Modal/Modal' type Props = { callback: (approved: boolean) => void @@ -37,13 +37,11 @@ const PermissionsModal = ({ callback, component, dismiss, permissionsString }: P ]} className={{ content: 'md:!w-[350px]' }} customFooter={ -
- - - -
+ + + } >
diff --git a/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModalWrapper.tsx b/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModalWrapper.tsx index da64f9614..e6cc15cb5 100644 --- a/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModalWrapper.tsx +++ b/packages/web/src/javascripts/Components/PermissionsModal/PermissionsModalWrapper.tsx @@ -1,7 +1,7 @@ import { WebApplication } from '@/Application/Application' import { ApplicationEvent, PermissionDialog } from '@standardnotes/snjs' import { FunctionComponent, useCallback, useEffect, useState } from 'react' -import ModalOverlay from '../Shared/ModalOverlay' +import ModalOverlay from '../Modal/ModalOverlay' import PermissionsModal from './PermissionsModal' type Props = { diff --git a/packages/web/src/javascripts/Components/Popover/MobilePopoverContent.tsx b/packages/web/src/javascripts/Components/Popover/MobilePopoverContent.tsx index e38f82f20..40a3be454 100644 --- a/packages/web/src/javascripts/Components/Popover/MobilePopoverContent.tsx +++ b/packages/web/src/javascripts/Components/Popover/MobilePopoverContent.tsx @@ -2,8 +2,9 @@ import { useDisableBodyScrollOnMobile } from '@/Hooks/useDisableBodyScrollOnMobi import { classNames } from '@standardnotes/snjs' import { ReactNode } from 'react' import Portal from '../Portal/Portal' -import MobileModalAction from '../Shared/MobileModalAction' -import { useModalAnimation } from '../Shared/useModalAnimation' +import MobileModalAction from '../Modal/MobileModalAction' +import { useModalAnimation } from '../Modal/useModalAnimation' +import MobileModalHeader from '../Modal/MobileModalHeader' const DisableScroll = () => { useDisableBodyScrollOnMobile() @@ -41,13 +42,13 @@ const MobilePopoverContent = ({ data-popover={id} data-mobile-popover > -
+
{title}
Done -
+
{children}
diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/Account/ChangeEmail/ChangeEmail.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/Account/ChangeEmail/ChangeEmail.tsx index 7b8b368a1..8b8266fbb 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/Account/ChangeEmail/ChangeEmail.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/Account/ChangeEmail/ChangeEmail.tsx @@ -3,7 +3,7 @@ import { WebApplication } from '@/Application/Application' import { useBeforeUnload } from '@/Hooks/useBeforeUnload' import ChangeEmailForm from './ChangeEmailForm' import ChangeEmailSuccess from './ChangeEmailSuccess' -import Modal, { ModalAction } from '@/Components/Shared/Modal' +import Modal, { ModalAction } from '@/Components/Modal/Modal' enum SubmitButtonTitles { Default = 'Continue', diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/Account/Credentials.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/Account/Credentials.tsx index 7170aea70..0b476392f 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/Account/Credentials.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/Account/Credentials.tsx @@ -10,7 +10,7 @@ import { ViewControllerManager } from '@/Controllers/ViewControllerManager' import PasswordWizard from '@/Components/PasswordWizard/PasswordWizard' import PreferencesGroup from '../../PreferencesComponents/PreferencesGroup' import PreferencesSegment from '../../PreferencesComponents/PreferencesSegment' -import ModalOverlay from '@/Components/Shared/ModalOverlay' +import ModalOverlay from '@/Components/Modal/ModalOverlay' type Props = { application: WebApplication diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/Invite/Invite.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/Invite/Invite.tsx index 7666ded69..4ac1808ee 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/Invite/Invite.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/Invite/Invite.tsx @@ -6,7 +6,7 @@ import { SubscriptionController } from '@/Controllers/Subscription/SubscriptionC import InviteForm from './InviteForm' import InviteSuccess from './InviteSuccess' -import Modal, { ModalAction } from '@/Components/Shared/Modal' +import Modal, { ModalAction } from '@/Components/Modal/Modal' enum SubmitButtonTitles { Default = 'Invite', diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/SubscriptionSharing.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/SubscriptionSharing.tsx index 2088118d7..679f7b5fc 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/SubscriptionSharing.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/Account/SubscriptionSharing/SubscriptionSharing.tsx @@ -14,7 +14,7 @@ import InvitationsList from './InvitationsList' import Invite from './Invite/Invite' import Button from '@/Components/Button/Button' import SharingStatusText from './SharingStatusText' -import ModalOverlay from '@/Components/Shared/ModalOverlay' +import ModalOverlay from '@/Components/Modal/ModalOverlay' type Props = { application: WebApplication diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/EditSmartViewModal.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/EditSmartViewModal.tsx index 2a00792ee..f120a2c0a 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/EditSmartViewModal.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/EditSmartViewModal.tsx @@ -1,7 +1,7 @@ import Icon from '@/Components/Icon/Icon' import IconPicker from '@/Components/Icon/IconPicker' import Popover from '@/Components/Popover/Popover' -import Modal, { ModalAction } from '@/Components/Shared/Modal' +import Modal, { ModalAction } from '@/Components/Modal/Modal' import Spinner from '@/Components/Spinner/Spinner' import { Platform, SmartViewDefaultIconName, VectorIconNameOrEmoji } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/SmartViews.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/SmartViews.tsx index 4885a4a3e..3063412da 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/SmartViews.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/General/SmartViews/SmartViews.tsx @@ -15,7 +15,7 @@ import NoSubscriptionBanner from '@/Components/NoSubscriptionBanner/NoSubscripti import { EditSmartViewModalController } from './EditSmartViewModalController' import { STRING_DELETE_TAG } from '@/Constants/Strings' import { confirmDialog } from '@standardnotes/ui-services' -import ModalOverlay from '@/Components/Shared/ModalOverlay' +import ModalOverlay from '@/Components/Modal/ModalOverlay' type NewType = { application: WebApplication diff --git a/packages/web/src/javascripts/Components/Preferences/Panes/Security/TwoFactorAuth/TwoFactorAuthView/TwoFactorAuthView.tsx b/packages/web/src/javascripts/Components/Preferences/Panes/Security/TwoFactorAuth/TwoFactorAuthView/TwoFactorAuthView.tsx index d2f6cda0c..2cb3e794e 100644 --- a/packages/web/src/javascripts/Components/Preferences/Panes/Security/TwoFactorAuth/TwoFactorAuthView/TwoFactorAuthView.tsx +++ b/packages/web/src/javascripts/Components/Preferences/Panes/Security/TwoFactorAuth/TwoFactorAuthView/TwoFactorAuthView.tsx @@ -10,8 +10,8 @@ import PreferencesGroup from '@/Components/Preferences/PreferencesComponents/Pre import PreferencesSegment from '@/Components/Preferences/PreferencesComponents/PreferencesSegment' import { WebApplication } from '@/Application/Application' import RecoveryCodeBanner from '@/Components/RecoveryCodeBanner/RecoveryCodeBanner' -import Modal, { ModalAction } from '@/Components/Shared/Modal' -import ModalOverlay from '@/Components/Shared/ModalOverlay' +import Modal, { ModalAction } from '@/Components/Modal/Modal' +import ModalOverlay from '@/Components/Modal/ModalOverlay' type Props = { auth: TwoFactorAuth diff --git a/packages/web/src/javascripts/Components/Preferences/PreferencesView.tsx b/packages/web/src/javascripts/Components/Preferences/PreferencesView.tsx index 31dca703e..36eea2bf2 100644 --- a/packages/web/src/javascripts/Components/Preferences/PreferencesView.tsx +++ b/packages/web/src/javascripts/Components/Preferences/PreferencesView.tsx @@ -7,8 +7,7 @@ import { PreferencesProps } from './PreferencesProps' import { useDisableBodyScrollOnMobile } from '@/Hooks/useDisableBodyScrollOnMobile' import { useAndroidBackHandler } from '@/NativeMobileWeb/useAndroidBackHandler' import { ESCAPE_COMMAND } from '@standardnotes/ui-services' -import Modal from '../Shared/Modal' -import { AlertDialogLabel } from '@reach/alert-dialog' +import Modal from '../Modal/Modal' import { classNames } from '@standardnotes/snjs' import { isIOS } from '@/Utils' @@ -63,7 +62,7 @@ const PreferencesView: FunctionComponent = ({ description: 'flex flex-col', }} customHeader={ - = ({ icon="close" label="Close preferences" /> - +
} > = ({ viewControllerManager, diff --git a/packages/web/src/javascripts/Components/RevisionHistoryModal/HistoryModalDialogContent.tsx b/packages/web/src/javascripts/Components/RevisionHistoryModal/HistoryModalDialogContent.tsx index 3111d102b..0bcfe4756 100644 --- a/packages/web/src/javascripts/Components/RevisionHistoryModal/HistoryModalDialogContent.tsx +++ b/packages/web/src/javascripts/Components/RevisionHistoryModal/HistoryModalDialogContent.tsx @@ -8,8 +8,9 @@ import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryCont import Icon from '../Icon/Icon' import { classNames } from '@standardnotes/utils' import { HistoryModalMobileTab } from './utils' -import MobileModalAction from '../Shared/MobileModalAction' +import MobileModalAction from '../Modal/MobileModalAction' import Popover from '../Popover/Popover' +import MobileModalHeader from '../Modal/MobileModalHeader' const HistoryModalDialogContent = ({ application, @@ -28,7 +29,7 @@ const HistoryModalDialogContent = ({ return ( <> -
+
@@ -67,7 +68,7 @@ const HistoryModalDialogContent = ({ Done -
+
= ({ application, diff --git a/packages/web/src/javascripts/Components/SessionsModal/SessionsModal.tsx b/packages/web/src/javascripts/Components/SessionsModal/SessionsModal.tsx index e34845b76..72c8a128a 100644 --- a/packages/web/src/javascripts/Components/SessionsModal/SessionsModal.tsx +++ b/packages/web/src/javascripts/Components/SessionsModal/SessionsModal.tsx @@ -8,8 +8,8 @@ import { observer } from 'mobx-react-lite' import Spinner from '@/Components/Spinner/Spinner' import Button from '@/Components/Button/Button' import Icon from '../Icon/Icon' -import Modal, { ModalAction } from '../Shared/Modal' -import ModalOverlay from '../Shared/ModalOverlay' +import Modal, { ModalAction } from '../Modal/Modal' +import ModalOverlay from '../Modal/ModalOverlay' type Session = RemoteSession & { revoking?: true diff --git a/packages/web/src/javascripts/Components/Shared/ModalDialog.tsx b/packages/web/src/javascripts/Components/Shared/ModalDialog.tsx deleted file mode 100644 index 2ae9aab5e..000000000 --- a/packages/web/src/javascripts/Components/Shared/ModalDialog.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { useRef, ReactNode } from 'react' -import { AlertDialogContent, AlertDialogOverlay } from '@reach/alert-dialog' -import { classNames } from '@standardnotes/utils' - -type Props = { - children: ReactNode - onDismiss?: () => void - className?: string -} - -const ModalDialog = ({ children, onDismiss, className }: Props) => { - const ldRef = useRef(null) - - return ( - - - {children} - - - ) -} - -export default ModalDialog diff --git a/packages/web/src/javascripts/Components/Shared/ModalDialogDescription.tsx b/packages/web/src/javascripts/Components/Shared/ModalDialogDescription.tsx deleted file mode 100644 index 1629bd825..000000000 --- a/packages/web/src/javascripts/Components/Shared/ModalDialogDescription.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { FunctionComponent, ReactNode } from 'react' -import { AlertDialogDescription } from '@reach/alert-dialog' - -type Props = { - className?: string - children?: ReactNode -} - -const ModalDialogDescription: FunctionComponent = ({ children, className = '' }) => ( - {children} -) - -export default ModalDialogDescription diff --git a/packages/web/src/javascripts/Components/Shared/ModalDialogLabel.tsx b/packages/web/src/javascripts/Components/Shared/ModalDialogLabel.tsx deleted file mode 100644 index 0ba34155d..000000000 --- a/packages/web/src/javascripts/Components/Shared/ModalDialogLabel.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { FunctionComponent, ReactNode, useEffect } from 'react' -import { AlertDialogLabel } from '@reach/alert-dialog' -import Icon from '@/Components/Icon/Icon' -import { classNames } from '@standardnotes/utils' -import { useAndroidBackHandler } from '@/NativeMobileWeb/useAndroidBackHandler' -import { isIOS } from '@/Utils' -import MobileModalAction from './MobileModalAction' - -type Props = { - closeDialog: () => void - className?: string - headerButtons?: ReactNode - leftMobileButton?: ReactNode - rightMobileButton?: ReactNode - children?: ReactNode -} - -const ModalDialogLabel: FunctionComponent = ({ - children, - closeDialog, - className, - headerButtons, - leftMobileButton, - rightMobileButton, -}) => { - const addAndroidBackHandler = useAndroidBackHandler() - - useEffect(() => { - const removeListener = addAndroidBackHandler(() => { - closeDialog() - return true - }) - return () => { - if (removeListener) { - removeListener() - } - } - }, [addAndroidBackHandler, closeDialog]) - - return ( - -
- {leftMobileButton ? leftMobileButton :
} -
- {children} -
-
- {headerButtons} - -
- {rightMobileButton ? ( - rightMobileButton - ) : ( - - )} -
-
- - ) -} - -export default ModalDialogLabel diff --git a/packages/web/src/javascripts/Components/SmartViewBuilder/AddSmartViewModal.tsx b/packages/web/src/javascripts/Components/SmartViewBuilder/AddSmartViewModal.tsx index 1152e80d2..a0e5ca78f 100644 --- a/packages/web/src/javascripts/Components/SmartViewBuilder/AddSmartViewModal.tsx +++ b/packages/web/src/javascripts/Components/SmartViewBuilder/AddSmartViewModal.tsx @@ -13,7 +13,7 @@ import TabsContainer from '../Tabs/TabsContainer' import CopyableCodeBlock from '../Shared/CopyableCodeBlock' import { Disclosure, DisclosureButton, DisclosurePanel } from '@reach/disclosure' import { classNames } from '@standardnotes/utils' -import Modal, { ModalAction } from '../Shared/Modal' +import Modal, { ModalAction } from '../Modal/Modal' type Props = { controller: AddSmartViewModalController diff --git a/packages/web/src/javascripts/Components/Tags/SmartViewsSection.tsx b/packages/web/src/javascripts/Components/Tags/SmartViewsSection.tsx index fd3c052e0..ad2dc0e8f 100644 --- a/packages/web/src/javascripts/Components/Tags/SmartViewsSection.tsx +++ b/packages/web/src/javascripts/Components/Tags/SmartViewsSection.tsx @@ -8,7 +8,7 @@ import { FunctionComponent, useCallback, useMemo } from 'react' import IconButton from '../Button/IconButton' import EditSmartViewModal from '../Preferences/Panes/General/SmartViews/EditSmartViewModal' import { EditSmartViewModalController } from '../Preferences/Panes/General/SmartViews/EditSmartViewModalController' -import ModalOverlay from '../Shared/ModalOverlay' +import ModalOverlay from '../Modal/ModalOverlay' import AddSmartViewModal from '../SmartViewBuilder/AddSmartViewModal' import { AddSmartViewModalController } from '../SmartViewBuilder/AddSmartViewModalController' import SmartViewsList from './SmartViewsList'