Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use desktop colors for mobile autocomplete modals #2577

Merged
merged 8 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/FatalError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export function FatalError({ buttonText, error }: FatalErrorProps) {
const showSimpleRender = 'type' in error && error.type === 'app-init-failure';

return (
<Modal isCurrent={true} showClose={false} title="Fatal Error">
<Modal isCurrent={true} CloseButton={undefined} title="Fatal Error">
<View
style={{
maxWidth: 500,
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/MobileWebMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export function MobileWebMessage() {
bottom: 0,
left: 0,
right: 0,
backgroundColor: theme.mobileModalBackground,
color: theme.mobileModalText,
backgroundColor: theme.menuAutoCompleteBackground,
color: theme.menuAutoCompleteText,
padding: 10,
margin: 10,
borderRadius: 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ function AccountItem({
backgroundColor: highlighted
? theme.menuAutoCompleteBackgroundHover
: 'transparent',
color: highlighted
? theme.menuAutoCompleteItemTextHover
: theme.menuAutoCompleteItemText,
padding: 4,
paddingLeft: 20,
borderRadius: embedded ? 4 : 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ type CategoryItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function CategoryItem({
function CategoryItem({
item,
className,
style,
Expand All @@ -312,7 +311,6 @@ export function CategoryItem({
const narrowStyle = isNarrowWidth
? {
...styles.mobileMenuItem,
color: theme.menuAutoCompleteText,
borderRadius: 0,
borderTop: `1px solid ${theme.pillBorder}`,
}
Expand All @@ -331,9 +329,6 @@ export function CategoryItem({
color: highlighted
? theme.menuAutoCompleteItemTextHover
: theme.menuAutoCompleteItemText,
':hover': {
color: theme.menuAutoCompleteItemTextHover,
},
padding: 4,
paddingLeft: 20,
borderRadius: embedded ? 4 : 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function ItemHeader({ title, style, type, ...props }: ItemHeaderProps) {
const narrowStyle = isNarrowWidth
? {
...styles.largeText,
color: theme.menuItemTextHeader,
paddingTop: 10,
paddingBottom: 10,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ function PayeeItem({
const narrowStyle = isNarrowWidth
? {
...styles.mobileMenuItem,
color: theme.menuAutoCompleteText,
borderRadius: 0,
borderTop: `1px solid ${theme.pillBorder}`,
}
Expand Down Expand Up @@ -522,9 +521,6 @@ function PayeeItem({
color: highlighted
? theme.menuAutoCompleteItemTextHover
: theme.menuAutoCompleteItemText,
':hover': {
color: theme.menuAutoCompleteItemTextHover,
},
borderRadius: embedded ? 4 : 0,
padding: 4,
paddingLeft: 20,
Expand Down
37 changes: 25 additions & 12 deletions packages/desktop-client/src/components/common/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import React, {
useLayoutEffect,
type ReactNode,
useState,
type ComponentProps,
type ComponentType,
type ComponentPropsWithRef,
} from 'react';
import { useHotkeysContext } from 'react-hotkeys-hook';
import ReactModal from 'react-modal';
Expand All @@ -30,8 +33,9 @@ export type ModalProps = {
padding?: CSSProperties['padding'];
showHeader?: boolean;
leftHeaderContent?: ReactNode;
CloseButton?: ComponentType<ComponentPropsWithRef<typeof ModalCloseButton>>;
showTitle?: boolean;
showClose?: boolean;
editableTitle?: boolean;
showOverlay?: boolean;
loading?: boolean;
noAnimation?: boolean;
Expand All @@ -52,8 +56,8 @@ export const Modal = ({
padding = 20,
showHeader = true,
leftHeaderContent,
CloseButton: CloseButtonComponent = ModalCloseButton,
showTitle = true,
showClose = true,
showOverlay = true,
loading = false,
noAnimation = false,
Expand Down Expand Up @@ -200,16 +204,7 @@ export const Modal = ({
marginLeft: !isNarrowWidth ? 5 : undefined,
}}
>
{showClose && (
<Button
type="bare"
onClick={onClose}
style={{ padding: 10 }}
aria-label="Close"
>
<SvgDelete width={10} style={{ color: 'inherit' }} />
</Button>
)}
<CloseButtonComponent onClick={onClose} />
</View>
</View>
)}
Expand Down Expand Up @@ -462,3 +457,21 @@ export function ModalTitle({
</Text>
);
}

type ModalCloseButtonProps = {
onClick: ComponentProps<typeof Button>['onClick'];
style?: CSSProperties;
};

export function ModalCloseButton({ onClick, style }: ModalCloseButtonProps) {
return (
<Button
type="bare"
onClick={onClick}
style={{ padding: '10px 10px' }}
aria-label="Close"
>
<SvgDelete width={10} style={style} />
</Button>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function GoCardlessLink() {
window.close();

return (
<Modal isCurrent={true} showClose={false} title="Account sync">
<Modal isCurrent={true} CloseButton={undefined} title="Account sync">
{() => (
<View style={{ maxWidth: 500 }}>
<Paragraph>Please wait...</Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function Option({ isLast, item, state }) {
background: isSelected
? theme.tableRowBackgroundHighlight
: theme.tableBackground,
color: isSelected ? theme.mobileModalText : null,
color: isSelected ? theme.tableText : null,
outline: isFocusVisible ? '2px solid orange' : 'none',
...(!isLast && { borderBottom: `1px solid ${theme.tableBorder}` }),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ModalCloseButton, Modal, ModalTitle } from '../common/Modal';
import { View } from '../common/View';
import { SectionLabel } from '../forms';
import { type CommonModalProps } from '../Modals';
Expand Down Expand Up @@ -31,7 +31,12 @@ export function AccountAutocompleteModal({

return (
<Modal
title="Account"
title={
<ModalTitle
title="Account"
getStyle={() => ({ color: theme.menuAutoCompleteText })}
/>
}
noAnimation={!isNarrowWidth}
showHeader={isNarrowWidth}
focusAfterClose={false}
Expand All @@ -43,11 +48,14 @@ export function AccountAutocompleteModal({
height: isNarrowWidth ? '85vh' : 275,
padding: '15px 10px',
borderRadius: '6px',
...(!isNarrowWidth && {
backgroundColor: theme.mobileModalBackground,
color: theme.mobileModalText,
}),
backgroundColor: theme.menuAutoCompleteBackground,
}}
CloseButton={props => (
<ModalCloseButton
{...props}
style={{ color: theme.menuAutoCompleteText }}
/>
)}
>
{() => (
<View>
Expand All @@ -56,7 +64,7 @@ export function AccountAutocompleteModal({
title="Account"
style={{
alignSelf: 'center',
color: theme.mobileModalText,
color: theme.menuAutoCompleteText,
marginBottom: 10,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ModalCloseButton, Modal, ModalTitle } from '../common/Modal';
import { View } from '../common/View';
import { SectionLabel } from '../forms';
import { type CommonModalProps } from '../Modals';
Expand Down Expand Up @@ -32,7 +32,12 @@ export function CategoryAutocompleteModal({

return (
<Modal
title="Category"
title={
<ModalTitle
title="Category"
getStyle={() => ({ color: theme.menuAutoCompleteText })}
/>
}
noAnimation={!isNarrowWidth}
showHeader={isNarrowWidth}
focusAfterClose={false}
Expand All @@ -44,11 +49,14 @@ export function CategoryAutocompleteModal({
height: isNarrowWidth ? '85vh' : 275,
padding: '15px 10px',
borderRadius: '6px',
...(!isNarrowWidth && {
backgroundColor: theme.mobileModalBackground,
color: theme.mobileModalText,
}),
backgroundColor: theme.menuAutoCompleteBackground,
}}
CloseButton={props => (
<ModalCloseButton
{...props}
style={{ color: theme.menuAutoCompleteText }}
/>
)}
>
{() => (
<View>
Expand All @@ -57,7 +65,7 @@ export function CategoryAutocompleteModal({
title="Category"
style={{
alignSelf: 'center',
color: theme.mobileModalText,
color: theme.menuAutoCompleteText,
marginBottom: 10,
}}
/>
Expand Down
7 changes: 2 additions & 5 deletions packages/desktop-client/src/components/modals/EditField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ export function EditField({ modalProps, name, onSubmit, onClose }) {
padding: '15px 10px',
borderRadius: '6px',
...(minWidth && { minWidth }),
...(!isNarrowWidth && {
backgroundColor: theme.mobileModalBackground,
color: theme.mobileModalText,
}),
backgroundColor: theme.menuAutoCompleteBackground,
}}
>
{() => (
Expand All @@ -291,7 +288,7 @@ export function EditField({ modalProps, name, onSubmit, onClose }) {
title={label}
style={{
alignSelf: 'center',
color: theme.mobileModalText,
color: theme.menuAutoCompleteText,
marginBottom: 10,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ModalCloseButton, Modal, ModalTitle } from '../common/Modal';
import { type CommonModalProps } from '../Modals';

type PayeeAutocompleteModalProps = {
Expand Down Expand Up @@ -34,7 +34,12 @@ export function PayeeAutocompleteModal({

return (
<Modal
title="Payee"
title={
<ModalTitle
title="Payee"
getStyle={() => ({ color: theme.menuAutoCompleteText })}
/>
}
noAnimation={!isNarrowWidth}
showHeader={isNarrowWidth}
focusAfterClose={false}
Expand All @@ -46,11 +51,14 @@ export function PayeeAutocompleteModal({
height: isNarrowWidth ? '85vh' : 275,
padding: '15px 10px',
borderRadius: '6px',
...(!isNarrowWidth && {
backgroundColor: theme.mobileModalBackground,
color: theme.mobileModalText,
}),
backgroundColor: theme.menuAutoCompleteBackground,
}}
CloseButton={props => (
<ModalCloseButton
{...props}
style={{ color: theme.menuAutoCompleteText }}
/>
)}
>
{() => (
<PayeeAutocomplete
Expand Down
2 changes: 0 additions & 2 deletions packages/desktop-client/src/style/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export const mobileNavItem = colorPalette.navy150;
export const mobileNavItemSelected = colorPalette.purple400;
export const mobileAccountShadow = cardShadow;
export const mobileAccountText = colorPalette.blue800;
export const mobileModalBackground = colorPalette.navy900;
export const mobileModalText = colorPalette.white;

// Mobile view themes (for the top bar)
export const mobileViewTheme = mobileHeaderBackground;
Expand Down
2 changes: 0 additions & 2 deletions packages/desktop-client/src/style/themes/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export const mobileNavItem = colorPalette.gray300;
export const mobileNavItemSelected = colorPalette.purple500;
export const mobileAccountShadow = colorPalette.navy300;
export const mobileAccountText = colorPalette.blue800;
export const mobileModalBackground = colorPalette.navy900;
export const mobileModalText = colorPalette.white;

// Mobile view themes (for the top bar)
export const mobileViewTheme = mobileHeaderBackground;
Expand Down
2 changes: 0 additions & 2 deletions packages/desktop-client/src/style/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ export const mobileNavItem = colorPalette.gray300;
export const mobileNavItemSelected = colorPalette.purple500;
export const mobileAccountShadow = colorPalette.navy300;
export const mobileAccountText = colorPalette.blue800;
export const mobileModalBackground = colorPalette.navy900;
export const mobileModalText = colorPalette.white;

// Mobile view themes (for the top bar)
export const mobileViewTheme = mobileHeaderBackground;
Expand Down
2 changes: 0 additions & 2 deletions packages/desktop-client/src/style/themes/midnight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export const mobileNavItem = colorPalette.gray150;
export const mobileNavItemSelected = colorPalette.purple200;
export const mobileAccountShadow = cardShadow;
export const mobileAccountText = colorPalette.blue800;
export const mobileModalBackground = menuAutoCompleteBackground;
export const mobileModalText = colorPalette.white;

// Mobile view themes (for the top bar)
export const mobileViewTheme = mobileHeaderBackground;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2577.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [joel-jeremy]
---

Use desktop colors for mobile autocomplete modals.
Loading