From de0b24bd1ac58269addf957345134b0f47e6c902 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 11 Apr 2024 10:57:27 -0700 Subject: [PATCH] Update close button --- .../src/components/FatalError.tsx | 2 +- .../src/components/common/Modal.tsx | 36 ++++++++++++------- .../components/gocardless/GoCardlessLink.tsx | 2 +- .../modals/AccountAutocompleteModal.tsx | 5 ++- .../modals/CategoryAutocompleteModal.tsx | 5 ++- .../modals/PayeeAutocompleteModal.tsx | 5 ++- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/packages/desktop-client/src/components/FatalError.tsx b/packages/desktop-client/src/components/FatalError.tsx index 6613cd536a3..e8e6f45fd42 100644 --- a/packages/desktop-client/src/components/FatalError.tsx +++ b/packages/desktop-client/src/components/FatalError.tsx @@ -167,7 +167,7 @@ export function FatalError({ buttonText, error }: FatalErrorProps) { const showSimpleRender = 'type' in error && error.type === 'app-init-failure'; return ( - + >; showTitle?: boolean; editableTitle?: boolean; - showClose?: boolean; showOverlay?: boolean; loading?: boolean; noAnimation?: boolean; @@ -57,9 +60,9 @@ export const Modal = ({ padding = 20, showHeader = true, leftHeaderContent, + CloseButton: CloseButtonComponent = CloseButton, showTitle = true, editableTitle = false, - showClose = true, showOverlay = true, loading = false, noAnimation = false, @@ -261,16 +264,7 @@ export const Modal = ({ marginRight: 15, }} > - {showClose && !isEditingTitle && ( - - )} + {!isEditingTitle && } @@ -427,3 +421,21 @@ export const ModalButtons = ({ ); }; + +type CloseButtonProps = { + onClick: ComponentProps['onClick']; + style?: CSSProperties; +}; + +export function CloseButton({ onClick, style }: CloseButtonProps) { + return ( + + ); +} diff --git a/packages/desktop-client/src/components/gocardless/GoCardlessLink.tsx b/packages/desktop-client/src/components/gocardless/GoCardlessLink.tsx index 9a3e3d65677..4a8a9e371d0 100644 --- a/packages/desktop-client/src/components/gocardless/GoCardlessLink.tsx +++ b/packages/desktop-client/src/components/gocardless/GoCardlessLink.tsx @@ -8,7 +8,7 @@ export function GoCardlessLink() { window.close(); return ( - + {() => ( Please wait... diff --git a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx index 3db3104f884..aa306fcd61a 100644 --- a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx +++ b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx @@ -3,7 +3,7 @@ import React, { type ComponentPropsWithoutRef } from 'react'; import { useResponsive } from '../../ResponsiveProvider'; import { theme } from '../../style'; import { AccountAutocomplete } from '../autocomplete/AccountAutocomplete'; -import { Modal } from '../common/Modal'; +import { CloseButton, Modal } from '../common/Modal'; import { View } from '../common/View'; import { SectionLabel } from '../forms'; import { type CommonModalProps } from '../Modals'; @@ -48,6 +48,9 @@ export function AccountAutocompleteModal({ borderRadius: '6px', backgroundColor: theme.menuAutoCompleteBackground, }} + CloseButton={props => ( + + )} > {() => ( diff --git a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx index 886bd221a68..4da7baa1d7a 100644 --- a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx +++ b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx @@ -3,7 +3,7 @@ import React, { type ComponentPropsWithoutRef } from 'react'; import { useResponsive } from '../../ResponsiveProvider'; import { theme } from '../../style'; import { CategoryAutocomplete } from '../autocomplete/CategoryAutocomplete'; -import { Modal } from '../common/Modal'; +import { CloseButton, Modal } from '../common/Modal'; import { View } from '../common/View'; import { SectionLabel } from '../forms'; import { type CommonModalProps } from '../Modals'; @@ -49,6 +49,9 @@ export function CategoryAutocompleteModal({ borderRadius: '6px', backgroundColor: theme.menuAutoCompleteBackground, }} + CloseButton={props => ( + + )} > {() => ( diff --git a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx index 64a4e25115d..15c4dfeb3e9 100644 --- a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx +++ b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx @@ -5,7 +5,7 @@ import { usePayees } from '../../hooks/usePayees'; import { useResponsive } from '../../ResponsiveProvider'; import { theme } from '../../style'; import { PayeeAutocomplete } from '../autocomplete/PayeeAutocomplete'; -import { Modal } from '../common/Modal'; +import { CloseButton, Modal } from '../common/Modal'; import { type CommonModalProps } from '../Modals'; type PayeeAutocompleteModalProps = { @@ -51,6 +51,9 @@ export function PayeeAutocompleteModal({ borderRadius: '6px', backgroundColor: theme.menuAutoCompleteBackground, }} + CloseButton={props => ( + + )} > {() => (