Skip to content

A local-first personal finance app

Fix mobile page header buttons (#3491)

Joel Jeremy Marquez2acf99643049
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png
index c8e0b47f52..db0ea1066d 100644
Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png
index 59bb41b121..52423795d8 100644
Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png
index 49df0e1a1d..fadeb6b427 100644
Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png differ
diff --git a/packages/desktop-client/src/components/Page.tsx b/packages/desktop-client/src/components/Page.tsx
index c93c095b60..d3c287ded0 100644
--- a/packages/desktop-client/src/components/Page.tsx
+++ b/packages/desktop-client/src/components/Page.tsx
@@ -54,11 +54,16 @@ export function MobilePageHeader({
<View
style={{
alignItems: 'center',
- backgroundColor: theme.mobileHeaderBackground,
- color: theme.mobileHeaderText,
flexDirection: 'row',
flexShrink: 0,
height: HEADER_HEIGHT,
+ backgroundColor: theme.mobileHeaderBackground,
+ '& *': {
+ color: theme.mobileHeaderText,
+ },
+ '& button[data-pressed]': {
+ backgroundColor: theme.mobileHeaderTextHover,
+ },
...style,
}}
>
diff --git a/packages/desktop-client/src/components/common/Button2.tsx b/packages/desktop-client/src/components/common/Button2.tsx
index 7921dbccb6..694429d573 100644
--- a/packages/desktop-client/src/components/common/Button2.tsx
+++ b/packages/desktop-client/src/components/common/Button2.tsx
@@ -1,9 +1,8 @@
import React, {
forwardRef,
+ useMemo,
type ComponentPropsWithoutRef,
- type ComponentType,
type ReactNode,
- type SVGProps,
} from 'react';
import {
type ButtonRenderProps as ReactAriaButtonRenderProps,
@@ -104,6 +103,13 @@ const _getPadding = (variant: ButtonVariant): string => {
}
};
+const _getHoveredStyles = (variant: ButtonVariant): CSSProperties => ({
+ ...(variant !== 'bare' && styles.shadow),
+ backgroundColor: backgroundColorHover[variant],
+ color: textColorHover[variant],
+ cursor: 'pointer',
+});
+
const _getActiveStyles = (
variant: ButtonVariant,
bounce: boolean,
@@ -127,7 +133,6 @@ const _getActiveStyles = (
type ButtonProps = ComponentPropsWithoutRef<typeof ReactAriaButton> & {
variant?: ButtonVariant;
bounce?: boolean;
- Icon?: ComponentType<SVGProps<SVGSVGElement>>;
children?: ReactNode;
};
@@ -135,70 +140,49 @@ type ButtonVariant = 'normal' | 'primary' | 'bare' | 'menu' | 'menuSelected';
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(props, ref) => {
- const {
- children,
- variant = 'normal',
- bounce = true,
- Icon,
- ...restProps
- } = props;
+ const { children, variant = 'normal', bounce = true, ...restProps } = props;
const variantWithDisabled: ButtonVariant | `${ButtonVariant}Disabled` =
props.isDisabled ? `${variant}Disabled` : variant;
- const hoveredStyle = {
- ...(variant !== 'bare' && styles.shadow),
- backgroundColor: backgroundColorHover[variant],
- color: textColorHover[variant],
- cursor: 'pointer',
- };
- const activeStyle = {
- ..._getActiveStyles(variant, bounce),
- };
-
- const defaultButtonClassName: ReactAriaButtonClassNameFn = renderProps =>
- String(
- css({
- alignItems: 'center',
- justifyContent: 'center',
- flexShrink: 0,
- padding: _getPadding(variant),
- margin: 0,
- overflow: 'hidden',
- display: 'flex',
- borderRadius: 4,
- backgroundColor: backgroundColor[variantWithDisabled],
- border: _getBorder(variant, variantWithDisabled),
- color: textColor[variantWithDisabled],
- transition: 'box-shadow .25s',
- WebkitAppRegion: 'no-drag',
- ...styles.smallText,
- ...(renderProps.isDisabled
- ? {}
- : {
- '&[data-hovered]': hoveredStyle,
- '&[data-pressed]': activeStyle,
- }),
- ...(Icon ? { paddingLeft: 0 } : {}),
- }),
- );
+ const defaultButtonClassName: string = useMemo(
+ () =>
+ String(
+ css({
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ padding: _getPadding(variant),
+ margin: 0,
+ overflow: 'hidden',
+ display: 'flex',
+ borderRadius: 4,
+ backgroundColor: backgroundColor[variantWithDisabled],
+ border: _getBorder(variant, variantWithDisabled),
+ color: textColor[variantWithDisabled],
+ transition: 'box-shadow .25s',
+ WebkitAppRegion: 'no-drag',
+ ...styles.smallText,
+ '&[data-hovered]': _getHoveredStyles(variant),
+ '&[data-pressed]': _getActiveStyles(variant, bounce),
+ }),
+ ),
+ [bounce, variant, variantWithDisabled],
+ );
- const buttonClassName: ReactAriaButtonClassNameFn = renderProps =>
- typeof props.className === 'function'
- ? props.className(renderProps)
- : props.className || '';
+ const className = restProps.className;
return (
<ReactAriaButton
ref={ref}
{...restProps}
- className={renderProps =>
- `${renderProps.defaultClassName} ${defaultButtonClassName(renderProps)} ${buttonClassName(renderProps)}`
+ className={
+ typeof className === 'function'
+ ? renderProps =>
+ `${defaultButtonClassName} ${className(renderProps)}`
+ : `${defaultButtonClassName} ${className || ''}`
}
>
- {Icon && (
- <Icon style={{ height: 15, paddingLeft: 5, paddingRight: 3 }} />
- )}
{children}
</ReactAriaButton>
);
@@ -254,10 +238,3 @@ export const ButtonWithLoading = forwardRef<
});
ButtonWithLoading.displayName = 'ButtonWithLoading';
-
-type ReactAriaButtonClassNameFn = Extract<
- ComponentPropsWithoutRef<typeof ReactAriaButton>['className'],
- (
- renderProps: ReactAriaButtonRenderProps & { defaultClassName: string },
- ) => string
->;
diff --git a/packages/desktop-client/src/components/mobile/MobileBackButton.tsx b/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
index b0b69f9b43..7e1c5bd638 100644
--- a/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
+++ b/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
@@ -1,10 +1,8 @@
import React, { type ComponentPropsWithoutRef } from 'react';
-import { css } from 'glamor';
-
import { useNavigate } from '../../hooks/useNavigate';
import { SvgCheveronLeft } from '../../icons/v1';
-import { styles, theme } from '../../style';
+import { styles } from '../../style';
import { Button } from '../common/Button2';
import { Text } from '../common/Text';
@@ -19,20 +17,10 @@ export function MobileBackButton({
return (
<Button
variant="bare"
- className={String(
- css({
- color: theme.mobileHeaderText,
- justifyContent: 'center',
- margin: 10,
- paddingLeft: 5,
- paddingRight: 3,
- '&[data-hovered]': {
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- },
- ...style,
- }),
- )}
+ style={{
+ margin: 10,
+ ...style,
+ }}
onPress={onPress || (() => navigate(-1))}
{...props}
>
diff --git a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
index 4290d26581..98a91445a0 100644
--- a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
+++ b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
@@ -199,7 +199,7 @@ export function MobileNavTabs() {
<View>
<div
style={{
- background: theme.pillBorder,
+ backgroundColor: theme.pillBorder,
borderRadius: 10,
width: 30,
marginTop: 5,
diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
index 1ab45cdd8c..594025e357 100644
--- a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
+++ b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
@@ -32,6 +32,7 @@ import { useDateFormat } from '../../../hooks/useDateFormat';
import { useNavigate } from '../../../hooks/useNavigate';
import { usePreviewTransactions } from '../../../hooks/usePreviewTransactions';
import { styles, theme } from '../../../style';
+import { Button } from '../../common/Button2';
import { Text } from '../../common/Text';
import { View } from '../../common/View';
import { MobilePageHeader, Page } from '../../Page';
@@ -125,16 +126,18 @@ function AccountName({ account, pending, failed }) {
}}
/>
)}
- <Text
- style={{
- userSelect: 'none',
- ...styles.underlinedText,
- ...styles.lineClamp(2),
- }}
- onClick={onClick}
- >
- {`${account.closed ? 'Closed: ' : ''}${account.name}`}
- </Text>
+ <Button variant="bare" onPress={onClick}>
+ <Text
+ style={{
+ fontSize: 17,
+ fontWeight: 500,
+ ...styles.underlinedText,
+ ...styles.lineClamp(2),
+ }}
+ >
+ {`${account.closed ? 'Closed: ' : ''}${account.name}`}
+ </Text>
+ </Button>
</View>
);
}
diff --git a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx b/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
index 2649951427..56bde3b833 100644
--- a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
+++ b/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
@@ -1,8 +1,6 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
-import { css } from 'glamor';
-
import { replaceModal, syncAndDownload } from 'loot-core/src/client/actions';
import * as queries from 'loot-core/src/client/queries';
@@ -172,17 +170,7 @@ function AccountList({
<Button
variant="bare"
aria-label="Add account"
- className={String(
- css({
- justifyContent: 'center',
- color: theme.mobileHeaderText,
- margin: 10,
- ':hover': {
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- },
- }),
- )}
+ style={{ margin: 10 }}
onPress={onAddAccount}
>
<SvgAdd width={20} height={20} />
diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
index ebe158289a..d9b6a2da6c 100644
--- a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
+++ b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
@@ -628,7 +628,6 @@ const ExpenseCategory = memo(function ExpenseCategory({
</View>
<View
style={{
- ...styles.noTapHighlight,
width: columnWidth,
justifyContent: 'center',
alignItems: 'flex-end',
@@ -789,8 +788,7 @@ const ExpenseGroupHeader = memo(function ExpenseGroupHeader({
css({
flexShrink: 0,
color: theme.pageTextSubdued,
- ...styles.noTapHighlight,
- '&[data-hovered], &[data-pressed]': {
+ '&[data-pressed]': {
backgroundColor: 'transparent',
},
}),
@@ -985,8 +983,7 @@ const IncomeGroupHeader = memo(function IncomeGroupHeader({
css({
flexShrink: 0,
color: theme.pageTextSubdued,
- ...styles.noTapHighlight,
- '&[data-hovered], &[data-pressed]': {
+ '&[data-pressed]': {
backgroundColor: 'transparent',
},
}),
@@ -1587,10 +1584,6 @@ export function BudgetTable({
const [showHiddenCategories = false] = useLocalPref(
'budget.showHiddenCategories',
);
- const noBackgroundColorStyle = {
- backgroundColor: 'transparent',
- color: 'white',
- };
return (
<Page
@@ -1609,16 +1602,14 @@ export function BudgetTable({
leftContent={
<Button
variant="bare"
- className={String(
- css({
- color: theme.mobileHeaderText,
- margin: 10,
- '&[data-hovered], &[data-pressed]': noBackgroundColorStyle,
- }),
- )}
+ style={{ margin: 10 }}
onPress={onOpenBudgetPageMenu}
>
- <SvgLogo width="20" height="20" />
+ <SvgLogo
+ style={{ color: theme.mobileHeaderText }}
+ width="20"
+ height="20"
+ />
<SvgCheveronRight
style={{ flexShrink: 0, color: theme.mobileHeaderTextSubdued }}
width="14"
@@ -1924,38 +1915,26 @@ function MonthSelector({
onPrevMonth();
}
}}
- className={String(
- css({
- ...styles.noTapHighlight,
- ...arrowButtonStyle,
- opacity: prevEnabled ? 1 : 0.6,
- color: theme.mobileHeaderText,
- '&[data-hovered]': {
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- },
- }),
- )}
+ style={{ ...arrowButtonStyle, opacity: prevEnabled ? 1 : 0.6 }}
>
<SvgArrowThinLeft width="15" height="15" style={{ margin: -5 }} />
</Button>
- <Text
+ <Button
+ variant="bare"
style={{
- color: theme.mobileHeaderText,
textAlign: 'center',
fontSize: 16,
fontWeight: 500,
margin: '0 5px',
- userSelect: 'none',
- ...styles.underlinedText,
}}
- onPointerUp={e => {
- e.stopPropagation();
+ onPress={() => {
onOpenMonthMenu?.(month);
}}
>
- {monthUtils.format(month, 'MMMM ‘yy')}
- </Text>
+ <Text style={styles.underlinedText}>
+ {monthUtils.format(month, 'MMMM ‘yy')}
+ </Text>
+ </Button>
<Button
variant="bare"
onPress={() => {
@@ -1963,18 +1942,7 @@ function MonthSelector({
onNextMonth();
}
}}
- className={String(
- css({
- ...styles.noTapHighlight,
- ...arrowButtonStyle,
- opacity: nextEnabled ? 1 : 0.6,
- color: theme.mobileHeaderText,
- '&[data-hovered]': {
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- },
- }),
- )}
+ style={{ ...arrowButtonStyle, opacity: nextEnabled ? 1 : 0.6 }}
>
<SvgArrowThinRight width="15" height="15" style={{ margin: -5 }} />
</Button>
diff --git a/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx b/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
index f77817a2e0..edaefb73e1 100644
--- a/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
@@ -1,10 +1,7 @@
import React from 'react';
-import { css } from 'glamor';
-
import { useNavigate } from '../../../hooks/useNavigate';
import { SvgAdd } from '../../../icons/v1';
-import { theme } from '../../../style';
import { Button } from '../../common/Button2';
type AddTransactionButtonProps = {
@@ -23,17 +20,7 @@ export function AddTransactionButton({
<Button
variant="bare"
aria-label="Add transaction"
- className={String(
- css({
- justifyContent: 'center',
- color: theme.mobileHeaderText,
- margin: 10,
- ':hover': {
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- },
- }),
- )}
+ style={{ margin: 10 }}
onPress={() => {
navigate(to, { state: { accountId, categoryId } });
}}
diff --git a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
index bc4b67b637..d00d43b097 100644
--- a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
@@ -256,7 +256,7 @@ export const FocusableAmountInput = memo(function FocusableAmountInput({
css({
...(buttonProps && buttonProps.style),
...(focused && { display: 'none' }),
- ':hover': {
+ '&[data-pressed]': {
backgroundColor: 'transparent',
},
}),
diff --git a/upcoming-release-notes/3491.md b/upcoming-release-notes/3491.md
new file mode 100644
index 0000000000..bdd9b38b7e
--- /dev/null
+++ b/upcoming-release-notes/3491.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [joel-jeremy]
+---
+
+Fix mobile page header button styles.