Skip to content

A local-first personal finance app

[React Aria Button] All remaining components except filters, mobile transaction edit, and autocomplete (#3163)

Joel Jeremy Marquez3985d2549e53
diff --git a/packages/desktop-client/.gitignore b/packages/desktop-client/.gitignore
index 08fad3425b..f635ae3caa 100644
--- a/packages/desktop-client/.gitignore
+++ b/packages/desktop-client/.gitignore
@@ -6,6 +6,7 @@ node_modules
# testing
coverage
test-results
+playwright-report
# production
build
diff --git a/packages/desktop-client/e2e/page-models/mobile-accounts-page.js b/packages/desktop-client/e2e/page-models/mobile-accounts-page.js
index f91bb147fd..2a64c3e553 100644
--- a/packages/desktop-client/e2e/page-models/mobile-accounts-page.js
+++ b/packages/desktop-client/e2e/page-models/mobile-accounts-page.js
@@ -23,7 +23,7 @@ export class MobileAccountsPage {
* Click on the n-th account to open it up
*/
async openNthAccount(idx) {
- await this.accounts.nth(idx).getByRole('button').click();
+ await this.accounts.nth(idx).click();
return new MobileAccountPage(this.page);
}
diff --git a/packages/desktop-client/playwright.config.js b/packages/desktop-client/playwright.config.js
index f8ba4d8f2f..1bf7e2cf40 100644
--- a/packages/desktop-client/playwright.config.js
+++ b/packages/desktop-client/playwright.config.js
@@ -57,9 +57,7 @@ export default defineConfig({
timeout: 20000, // 20 seconds
retries: 1,
testDir: 'e2e/',
- reporter: !process.env.CI
- ? [['html', { open: 'never', outputFolder: 'test-results/html' }]]
- : undefined,
+ reporter: !process.env.CI ? [['html', { open: 'never' }]] : undefined,
use: {
userAgent: 'playwright',
screenshot: 'on',
diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsx
index 8179cb8854..c283886eaa 100644
--- a/packages/desktop-client/src/components/Titlebar.tsx
+++ b/packages/desktop-client/src/components/Titlebar.tsx
@@ -44,7 +44,7 @@ function UncategorizedButton() {
return (
<Link
variant="button"
- type="bare"
+ buttonVariant="bare"
to="/accounts/uncategorized"
style={{
color: theme.errorText,
diff --git a/packages/desktop-client/src/components/common/Link.tsx b/packages/desktop-client/src/components/common/Link.tsx
index 4795ccf218..a945e95570 100644
--- a/packages/desktop-client/src/components/common/Link.tsx
+++ b/packages/desktop-client/src/components/common/Link.tsx
@@ -13,7 +13,7 @@ import { useNavigate } from '../../hooks/useNavigate';
import { type CSSProperties, styles } from '../../style';
import { theme } from '../../style/theme';
-import { Button } from './Button';
+import { Button } from './Button2';
import { Text } from './Text';
type TextLinkProps = {
@@ -22,7 +22,8 @@ type TextLinkProps = {
children?: ReactNode;
};
-type ButtonLinkProps = ComponentProps<typeof Button> & {
+type ButtonLinkProps = Omit<ComponentProps<typeof Button>, 'variant'> & {
+ buttonVariant?: ComponentProps<typeof Button>['variant'];
to?: string;
activeStyle?: CSSProperties;
};
@@ -94,17 +95,15 @@ const ButtonLink = ({ to, style, activeStyle, ...props }: ButtonLinkProps) => {
const match = useMatch({ path });
return (
<Button
- style={{
+ style={({ isPressed }) => ({
...style,
- ...(match ? activeStyle : {}),
- }}
- activeStyle={activeStyle}
+ ...(match || isPressed ? activeStyle : {}),
+ })}
{...props}
- onClick={e => {
- props.onClick?.(e);
- if (!e.defaultPrevented) {
- navigate(path);
- }
+ variant={props.buttonVariant}
+ onPress={e => {
+ props.onPress?.(e);
+ navigate(path);
}}
/>
);
@@ -136,28 +135,34 @@ const InternalLink = ({
};
type LinkProps =
- | ({
- variant: 'button';
- } & ButtonLinkProps)
- | ({ variant?: 'internal' } & InternalLinkProps)
- | ({ variant?: 'external' } & ExternalLinkProps)
- | ({ variant?: 'text' } & TextLinkProps);
-
-export function Link({ variant = 'internal', ...props }: LinkProps) {
- switch (variant) {
- case 'internal':
- return <InternalLink {...props} />;
-
- case 'external':
- return <ExternalLink {...props} />;
-
- case 'button':
- return <ButtonLink {...props} />;
-
- case 'text':
- return <TextLink {...props} />;
+ | ({ variant: 'button' } & ButtonLinkProps)
+ | ({ variant: 'internal' } & InternalLinkProps)
+ | ({ variant: 'external' } & ExternalLinkProps)
+ | ({ variant: 'text' } & TextLinkProps);
+
+export function Link(props: LinkProps) {
+ switch (props.variant) {
+ case 'internal': {
+ const { variant: _, ...internalProps } = props;
+ return <InternalLink {...internalProps} />;
+ }
+
+ case 'external': {
+ const { variant: _, ...externalProps } = props;
+ return <ExternalLink {...externalProps} />;
+ }
+
+ case 'button': {
+ const { variant: _, ...buttonProps } = props;
+ return <ButtonLink {...buttonProps} />;
+ }
+
+ case 'text': {
+ const { variant: _, ...textProps } = props;
+ return <TextLink {...textProps} />;
+ }
default:
- throw new Error(`Unrecognised link type: ${variant}`);
+ throw new Error(`Unrecognised Link variant.`);
}
}
diff --git a/packages/desktop-client/src/components/common/Modal.tsx b/packages/desktop-client/src/components/common/Modal.tsx
index e3a65d694b..2e7636e351 100644
--- a/packages/desktop-client/src/components/common/Modal.tsx
+++ b/packages/desktop-client/src/components/common/Modal.tsx
@@ -20,7 +20,7 @@ import { SvgDelete } from '../../icons/v0';
import { type CSSProperties, styles, theme } from '../../style';
import { tokens } from '../../tokens';
-import { Button } from './Button';
+import { Button } from './Button2';
import { Input } from './Input';
import { Text } from './Text';
import { TextOneLine } from './TextOneLine';
@@ -202,7 +202,7 @@ export const Modal = ({
right: 0,
}}
>
- <CloseButtonComponent onClick={onClose} />
+ <CloseButtonComponent onPress={onClose} />
</View>
)}
</View>
@@ -463,15 +463,15 @@ function ModalTitle({
}
type ModalCloseButtonProps = {
- onClick: ComponentProps<typeof Button>['onClick'];
+ onPress: ComponentProps<typeof Button>['onPress'];
style?: CSSProperties;
};
-function ModalCloseButton({ onClick, style }: ModalCloseButtonProps) {
+function ModalCloseButton({ onPress, style }: ModalCloseButtonProps) {
return (
<Button
- type="bare"
- onClick={onClick}
+ variant="bare"
+ onPress={onPress}
style={{ padding: '10px 10px' }}
aria-label="Close"
>
diff --git a/packages/desktop-client/src/components/common/Modal2.tsx b/packages/desktop-client/src/components/common/Modal2.tsx
index 2de38db980..c7e0cdc40b 100644
--- a/packages/desktop-client/src/components/common/Modal2.tsx
+++ b/packages/desktop-client/src/components/common/Modal2.tsx
@@ -24,7 +24,7 @@ import { SvgDelete } from '../../icons/v0';
import { type CSSProperties, styles, theme } from '../../style';
import { tokens } from '../../tokens';
-import { Button } from './Button';
+import { Button } from './Button2';
import { Input } from './Input';
import { Text } from './Text';
import { TextOneLine } from './TextOneLine';
@@ -450,15 +450,15 @@ export function ModalTitle({
}
type ModalCloseButtonProps = {
- onClick: ComponentPropsWithoutRef<typeof Button>['onClick'];
+ onClick: ComponentPropsWithoutRef<typeof Button>['onPress'];
style?: CSSProperties;
};
export function ModalCloseButton({ onClick, style }: ModalCloseButtonProps) {
return (
<Button
- type="bare"
- onClick={onClick}
+ variant="bare"
+ onPress={onClick}
style={{ padding: '10px 10px' }}
aria-label="Close"
>
diff --git a/packages/desktop-client/src/components/common/Search.tsx b/packages/desktop-client/src/components/common/Search.tsx
index 1cf98e8bf0..6f9c2c469f 100644
--- a/packages/desktop-client/src/components/common/Search.tsx
+++ b/packages/desktop-client/src/components/common/Search.tsx
@@ -3,8 +3,9 @@ import { type Ref } from 'react';
import { SvgRemove, SvgSearchAlternate } from '../../icons/v2';
import { theme } from '../../style';
-import { Button } from './Button';
+import { Button } from './Button2';
import { InputWithContent } from './InputWithContent';
+import { View } from './View';
type SearchProps = {
inputRef?: Ref<HTMLInputElement>;
@@ -54,14 +55,15 @@ export function Search({
}
rightContent={
value && (
- <Button
- type="bare"
- style={{ padding: 8 }}
- onClick={() => onChange('')}
- title="Clear search term"
- >
- <SvgRemove style={{ width: 8, height: 8 }} />
- </Button>
+ <View title="Clear search term">
+ <Button
+ variant="bare"
+ style={{ padding: 8 }}
+ onPress={() => onChange('')}
+ >
+ <SvgRemove style={{ width: 8, height: 8 }} />
+ </Button>
+ </View>
)
}
inputStyle={{
diff --git a/packages/desktop-client/src/components/common/Select.tsx b/packages/desktop-client/src/components/common/Select.tsx
index 09db132168..27b6747914 100644
--- a/packages/desktop-client/src/components/common/Select.tsx
+++ b/packages/desktop-client/src/components/common/Select.tsx
@@ -3,7 +3,7 @@ import { useRef, useState } from 'react';
import { SvgExpandArrow } from '../../icons/v0';
import { type CSSProperties } from '../../style';
-import { Button } from './Button';
+import { Button } from './Button2';
import { Menu } from './Menu';
import { Popover } from './Popover';
import { View } from './View';
@@ -64,16 +64,17 @@ export function Select<const Value = string>({
<Button
ref={triggerRef}
id={id}
- type={bare ? 'bare' : 'normal'}
- disabled={disabled}
- onClick={() => {
+ variant={bare ? 'bare' : 'normal'}
+ isDisabled={disabled}
+ onPress={() => {
setIsOpen(true);
}}
- style={buttonStyle}
- hoveredStyle={{
- backgroundColor: bare ? 'transparent' : undefined,
+ style={({ isHovered }) => ({
...buttonStyle,
- }}
+ ...(isHovered
+ ? { backgroundColor: bare ? 'transparent' : undefined }
+ : {}),
+ })}
>
<View
style={{
diff --git a/packages/desktop-client/src/components/manager/ServerURL.tsx b/packages/desktop-client/src/components/manager/ServerURL.tsx
index 89e3dfebd0..4979e8d19b 100644
--- a/packages/desktop-client/src/components/manager/ServerURL.tsx
+++ b/packages/desktop-client/src/components/manager/ServerURL.tsx
@@ -30,7 +30,7 @@ export function ServerURL() {
<strong>No server configured</strong>
)}
</Text>
- <Link to="/config-server" style={{ marginLeft: 15 }}>
+ <Link variant="internal" to="/config-server" style={{ marginLeft: 15 }}>
Change
</Link>
</View>
diff --git a/packages/desktop-client/src/components/manager/subscribe/Login.tsx b/packages/desktop-client/src/components/manager/subscribe/Login.tsx
index ba9546f796..d81f9a52a8 100644
--- a/packages/desktop-client/src/components/manager/subscribe/Login.tsx
+++ b/packages/desktop-client/src/components/manager/subscribe/Login.tsx
@@ -149,7 +149,7 @@ export function Login() {
{error && (
<Link
variant="button"
- type="primary"
+ buttonVariant="primary"
style={{ fontSize: 15 }}
to={'/login/password?error=' + error}
>
diff --git a/packages/desktop-client/src/components/mobile/MobileBackButton.tsx b/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
index cc4a93113d..aa1604bb6a 100644
--- a/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
+++ b/packages/desktop-client/src/components/mobile/MobileBackButton.tsx
@@ -1,35 +1,38 @@
-import React from 'react';
+import React, { type ComponentPropsWithoutRef } from 'react';
import { useNavigate } from '../../hooks/useNavigate';
import { SvgCheveronLeft } from '../../icons/v1';
-import { type CSSProperties, styles, theme } from '../../style';
-import { Button } from '../common/Button';
+import { styles, theme } from '../../style';
+import { Button } from '../common/Button2';
import { Text } from '../common/Text';
-type MobileBackButtonProps = {
- onClick?: () => void;
- style?: CSSProperties;
-};
+type MobileBackButtonProps = ComponentPropsWithoutRef<typeof Button>;
-export function MobileBackButton({ onClick, style }: MobileBackButtonProps) {
+export function MobileBackButton({
+ onPress,
+ style,
+ ...props
+}: MobileBackButtonProps) {
const navigate = useNavigate();
return (
<Button
- type="bare"
- aria-label="Back"
- style={{
+ variant="bare"
+ style={({ isHovered }) => ({
color: theme.mobileHeaderText,
justifyContent: 'center',
margin: 10,
paddingLeft: 5,
paddingRight: 3,
+ ...(isHovered
+ ? {
+ color: theme.mobileHeaderText,
+ background: theme.mobileHeaderTextHover,
+ }
+ : {}),
...style,
- }}
- hoveredStyle={{
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- }}
- onClick={onClick || (() => navigate(-1))}
+ })}
+ onPress={onPress || (() => navigate(-1))}
+ {...props}
>
<SvgCheveronLeft
style={{ width: 30, height: 30, margin: -10, marginLeft: -5 }}
diff --git a/packages/desktop-client/src/components/mobile/accounts/Account.jsx b/packages/desktop-client/src/components/mobile/accounts/Account.jsx
index 129b076598..244ceb99b9 100644
--- a/packages/desktop-client/src/components/mobile/accounts/Account.jsx
+++ b/packages/desktop-client/src/components/mobile/accounts/Account.jsx
@@ -8,7 +8,7 @@ import { useNavigate } from '../../../hooks/useNavigate';
import { useSetThemeColor } from '../../../hooks/useSetThemeColor';
import { useSyncedPref } from '../../../hooks/useSyncedPref';
import { theme, styles } from '../../../style';
-import { Button } from '../../common/Button';
+import { Button } from '../../common/Button2';
import { Text } from '../../common/Text';
import { View } from '../../common/View';
@@ -45,9 +45,9 @@ export function Account() {
There is no Mobile View at the moment
</Text>
<Button
- type="normal"
+ variant="normal"
style={{ fontSize: 15, marginLeft: 10, marginTop: 10 }}
- onClick={() => navigate('/accounts')}
+ onPress={() => navigate('/accounts')}
>
Go back to Mobile Accounts
</Button>
diff --git a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx b/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
index a81c9cdd65..10fa6a2074 100644
--- a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
+++ b/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
@@ -1,6 +1,8 @@
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';
@@ -64,84 +66,67 @@ function AccountCard({
onSelect,
}) {
return (
- <View
+ <Button
+ onPress={() => onSelect(account.id)}
style={{
- flex: 1,
- flexDirection: 'row',
- backgroundColor: theme.tableBackground,
- boxShadow: `0 1px 1px ${theme.mobileAccountShadow}`,
+ border: `1px solid ${theme.pillBorder}`,
borderRadius: 6,
+ boxShadow: `0 1px 1px ${theme.mobileAccountShadow}`,
marginTop: 10,
- marginRight: 10,
- width: '100%',
}}
data-testid="account"
>
- <Button
- onPress={() => onSelect(account.id)}
- style={({ isPressed }) => ({
- flexDirection: 'row',
- border: '1px solid ' + theme.pillBorder,
+ <View
+ style={{
flex: 1,
- alignItems: 'center',
- borderRadius: 6,
- ...(isPressed && {
- opacity: 0.1,
- }),
- })}
+ margin: '10px 0',
+ }}
>
<View
style={{
- flex: 1,
- margin: '10px 0',
+ flexDirection: 'row',
+ alignItems: 'center',
}}
>
- <View
+ {account.bankId && (
+ <View
+ style={{
+ backgroundColor: pending
+ ? theme.sidebarItemBackgroundPending
+ : failed
+ ? theme.sidebarItemBackgroundFailed
+ : theme.sidebarItemBackgroundPositive,
+ marginRight: '8px',
+ width: 8,
+ flexShrink: 0,
+ height: 8,
+ borderRadius: 8,
+ opacity: connected ? 1 : 0,
+ }}
+ />
+ )}
+ <TextOneLine
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ ...styles.text,
+ fontSize: 17,
+ fontWeight: 600,
+ color: updated ? theme.mobileAccountText : theme.pillText,
+ paddingRight: 30,
}}
+ data-testid="account-name"
>
- {account.bankId && (
- <View
- style={{
- backgroundColor: pending
- ? theme.sidebarItemBackgroundPending
- : failed
- ? theme.sidebarItemBackgroundFailed
- : theme.sidebarItemBackgroundPositive,
- marginRight: '8px',
- width: 8,
- flexShrink: 0,
- height: 8,
- borderRadius: 8,
- opacity: connected ? 1 : 0,
- }}
- />
- )}
- <TextOneLine
- style={{
- ...styles.text,
- fontSize: 17,
- fontWeight: 600,
- color: updated ? theme.mobileAccountText : theme.pillText,
- paddingRight: 30,
- }}
- data-testid="account-name"
- >
- {account.name}
- </TextOneLine>
- </View>
+ {account.name}
+ </TextOneLine>
</View>
- <CellValue
- binding={getBalanceQuery(account)}
- type="financial"
- style={{ fontSize: 16, color: 'inherit' }}
- getStyle={makeAmountFullStyle}
- data-testid="account-balance"
- />
- </Button>
- </View>
+ </View>
+ <CellValue
+ binding={getBalanceQuery(account)}
+ type="financial"
+ style={{ fontSize: 16, color: 'inherit' }}
+ getStyle={makeAmountFullStyle}
+ data-testid="account-balance"
+ />
+ </Button>
);
}
@@ -171,10 +156,6 @@ function AccountList({
const syncingAccountIds = useSelector(state => state.account.accountsSyncing);
const budgetedAccounts = accounts.filter(account => account.offbudget === 0);
const offbudgetAccounts = accounts.filter(account => account.offbudget === 1);
- const noBackgroundColorStyle = {
- backgroundColor: 'transparent',
- color: 'white',
- };
return (
<Page
@@ -184,11 +165,18 @@ function AccountList({
rightContent={
<Button
variant="bare"
- style={({ isHovered, isPressed }) => ({
- color: theme.mobileHeaderText,
- margin: 10,
- ...(isHovered || isPressed ? noBackgroundColorStyle : {}),
- })}
+ aria-label="Add account"
+ className={String(
+ css({
+ justifyContent: 'center',
+ color: theme.mobileHeaderText,
+ margin: 10,
+ ':hover': {
+ color: theme.mobileHeaderText,
+ background: theme.mobileHeaderTextHover,
+ },
+ }),
+ )}
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 893ee2f56b..2961520b0e 100644
--- a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
+++ b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
@@ -1,4 +1,4 @@
-import React, { memo, useRef } from 'react';
+import React, { memo, useCallback, useRef } from 'react';
import { useDispatch } from 'react-redux';
import { AutoTextSize } from 'auto-text-size';
@@ -364,13 +364,16 @@ const ExpenseCategory = memo(function ExpenseCategory({
const { list: categories } = useCategories();
const categoriesById = groupById(categories);
- const onCarryover = carryover => {
- onBudgetAction(month, 'carryover', {
- category: category.id,
- flag: carryover,
- });
- dispatch(collapseModals(`${budgetType}-balance-menu`));
- };
+ const onCarryover = useCallback(
+ carryover => {
+ onBudgetAction(month, 'carryover', {
+ category: category.id,
+ flag: carryover,
+ });
+ dispatch(collapseModals(`${budgetType}-balance-menu`));
+ },
+ [budgetType, category.id, dispatch, month, onBudgetAction],
+ );
const catBalance = useSheetValue(
type === 'rollover'
@@ -386,7 +389,7 @@ const ExpenseCategory = memo(function ExpenseCategory({
: budgetedtmp
: null;
- const onTransfer = () => {
+ const onTransfer = useCallback(() => {
dispatch(
pushModal('transfer', {
title: category.name,
@@ -406,9 +409,19 @@ const ExpenseCategory = memo(function ExpenseCategory({
showToBeBudgeted: true,
}),
);
- };
-
- const onCover = () => {
+ }, [
+ budgetType,
+ catBalance,
+ categoriesById,
+ category.id,
+ category.name,
+ dispatch,
+ month,
+ onBudgetAction,
+ showUndoNotification,
+ ]);
+
+ const onCover = useCallback(() => {
dispatch(
pushModal('cover', {
title: category.name,
@@ -426,9 +439,18 @@ const ExpenseCategory = memo(function ExpenseCategory({
},
}),
);
- };
-
- const onOpenBalanceMenu = () => {
+ }, [
+ budgetType,
+ categoriesById,
+ category.id,
+ category.name,
+ dispatch,
+ month,
+ onBudgetAction,
+ showUndoNotification,
+ ]);
+
+ const onOpenBalanceMenu = useCallback(() => {
dispatch(
pushModal(`${budgetType}-balance-menu`, {
categoryId: category.id,
@@ -437,14 +459,22 @@ const ExpenseCategory = memo(function ExpenseCategory({
...(budgetType === 'rollover' && { onTransfer, onCover }),
}),
);
- };
+ }, [
+ budgetType,
+ category.id,
+ dispatch,
+ month,
+ onCarryover,
+ onCover,
+ onTransfer,
+ ]);
const listItemRef = useRef();
const format = useFormat();
const navigate = useNavigate();
- const onShowActivity = () => {
+ const onShowActivity = useCallback(() => {
navigate(`/categories/${category.id}?month=${month}`);
- };
+ }, [category.id, month, navigate]);
const sidebarColumnWidth = getColumnWidth({ show3Cols, isSidebar: true });
const columnWidth = getColumnWidth({ show3Cols });
diff --git a/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx b/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
index a37822163f..f77817a2e0 100644
--- a/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
@@ -1,9 +1,11 @@
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/Button';
+import { Button } from '../../common/Button2';
type AddTransactionButtonProps = {
to: string;
@@ -19,18 +21,20 @@ export function AddTransactionButton({
const navigate = useNavigate();
return (
<Button
- type="bare"
+ variant="bare"
aria-label="Add transaction"
- style={{
- justifyContent: 'center',
- color: theme.mobileHeaderText,
- margin: 10,
- }}
- hoveredStyle={{
- color: theme.mobileHeaderText,
- background: theme.mobileHeaderTextHover,
- }}
- onClick={() => {
+ className={String(
+ css({
+ justifyContent: 'center',
+ color: theme.mobileHeaderText,
+ margin: 10,
+ ':hover': {
+ color: theme.mobileHeaderText,
+ background: theme.mobileHeaderTextHover,
+ },
+ }),
+ )}
+ 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 ad89d0b0a1..bc4b67b637 100644
--- a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
@@ -8,6 +8,8 @@ import React, {
useState,
} from 'react';
+import { css } from 'glamor';
+
import {
amountToCurrency,
appendDecimals,
@@ -18,7 +20,7 @@ import { useMergedRefs } from '../../../hooks/useMergedRefs';
import { useSyncedPref } from '../../../hooks/useSyncedPref';
import { type CSSProperties, theme } from '../../../style';
import { makeAmountFullStyle } from '../../budget/util';
-import { Button } from '../../common/Button';
+import { Button } from '../../common/Button2';
import { Text } from '../../common/Text';
import { View } from '../../common/View';
@@ -240,24 +242,26 @@ export const FocusableAmountInput = memo(function FocusableAmountInput({
right: 'calc(100% + 5px)',
top: '8px',
}}
- onClick={toggleIsNegative}
+ onPress={toggleIsNegative}
>
{isNegative ? '-' : '+'}
</Button>
)}
<Button
- onClick={onFocus}
+ onPress={onFocus}
// Defines how far touch can start away from the button
// hitSlop={{ top: 5, bottom: 5, left: 5, right: 5 }}
{...buttonProps}
- style={{
- ...(buttonProps && buttonProps.style),
- ...(focused && { display: 'none' }),
- ':hover': {
- backgroundColor: 'transparent',
- },
- }}
- type="bare"
+ className={String(
+ css({
+ ...(buttonProps && buttonProps.style),
+ ...(focused && { display: 'none' }),
+ ':hover': {
+ backgroundColor: 'transparent',
+ },
+ }),
+ )}
+ variant="bare"
>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/CoverModal.tsx b/packages/desktop-client/src/components/modals/CoverModal.tsx
index 70ff82bd5a..cdc9404a1a 100644
--- a/packages/desktop-client/src/components/modals/CoverModal.tsx
+++ b/packages/desktop-client/src/components/modals/CoverModal.tsx
@@ -1,4 +1,4 @@
-import React, { useCallback, useEffect, useMemo, useState } from 'react';
+import React, { useCallback, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
import { pushModal } from 'loot-core/client/actions';
@@ -8,7 +8,6 @@ import {
} from 'loot-core/src/types/models';
import { useCategories } from '../../hooks/useCategories';
-import { useInitialMount } from '../../hooks/useInitialMount';
import { styles } from '../../style';
import { addToBeBudgetedGroup } from '../budget/util';
import { Button } from '../common/Button2';
@@ -85,14 +84,6 @@ export function CoverModal({
}
};
- const initialMount = useInitialMount();
-
- useEffect(() => {
- if (initialMount) {
- onCategoryClick();
- }
- }, [initialMount, onCategoryClick]);
-
const fromCategory = categories.find(c => c.id === fromCategoryId);
return (
diff --git a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx b/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
index 0ac9166475..4a105b042b 100644
--- a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
@@ -113,7 +113,7 @@ export function CashFlow() {
<MobilePageHeader
title="Cash Flow"
leftContent={
- <MobileBackButton onClick={() => navigate('/reports')} />
+ <MobileBackButton onPress={() => navigate('/reports')} />
}
/>
) : (
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index df09f6eed2..97df6638da 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -640,7 +640,7 @@ export function CustomReport() {
isNarrowWidth ? (
<MobilePageHeader
title={`Custom Report: ${report.name || 'Unsaved report'}`}
- leftContent={<MobileBackButton onClick={onBackClick} />}
+ leftContent={<MobileBackButton onPress={onBackClick} />}
/>
) : (
<PageHeader
diff --git a/packages/desktop-client/src/components/reports/reports/NetWorth.jsx b/packages/desktop-client/src/components/reports/reports/NetWorth.jsx
index 73cdfec895..fe36605e58 100644
--- a/packages/desktop-client/src/components/reports/reports/NetWorth.jsx
+++ b/packages/desktop-client/src/components/reports/reports/NetWorth.jsx
@@ -144,7 +144,7 @@ function NetWorthInner({ widget }) {
<MobilePageHeader
title={title}
leftContent={
- <MobileBackButton onClick={() => navigate('/reports')} />
+ <MobileBackButton onPress={() => navigate('/reports')} />
}
/>
) : (
diff --git a/packages/desktop-client/src/components/reports/reports/Spending.tsx b/packages/desktop-client/src/components/reports/reports/Spending.tsx
index efbff45ed1..7301a10980 100644
--- a/packages/desktop-client/src/components/reports/reports/Spending.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Spending.tsx
@@ -123,7 +123,7 @@ export function Spending() {
<MobilePageHeader
title="Monthly Spending"
leftContent={
- <MobileBackButton onClick={() => navigate('/reports')} />
+ <MobileBackButton onPress={() => navigate('/reports')} />
}
/>
) : (
diff --git a/packages/desktop-client/src/components/sidebar/Account.tsx b/packages/desktop-client/src/components/sidebar/Account.tsx
index 28c4420a8a..96437fef47 100644
--- a/packages/desktop-client/src/components/sidebar/Account.tsx
+++ b/packages/desktop-client/src/components/sidebar/Account.tsx
@@ -96,6 +96,7 @@ export function Account<FieldName extends SheetFields<'account'>>({
<DropHighlight pos={dropPos} />
<View innerRef={dragRef}>
<Link
+ variant="internal"
to={to}
style={{
...accountNameStyle,
diff --git a/packages/desktop-client/src/components/sidebar/Item.tsx b/packages/desktop-client/src/components/sidebar/Item.tsx
index 8a209bd346..e75c3fa359 100644
--- a/packages/desktop-client/src/components/sidebar/Item.tsx
+++ b/packages/desktop-client/src/components/sidebar/Item.tsx
@@ -69,14 +69,14 @@ export function Item({
...(forceHover ? hoverStyle : {}),
':hover': hoverStyle,
}}
- to={to}
- onClick={onClick}
+ forceActive={forceActive}
activeStyle={{
borderLeft: '4px solid ' + theme.sidebarItemTextSelected,
paddingLeft: 19 + indent - 4,
color: theme.sidebarItemTextSelected,
}}
- forceActive={forceActive}
+ to={to}
+ onClick={onClick}
>
{content}
</ItemContent>
diff --git a/packages/desktop-client/src/components/sidebar/ItemContent.tsx b/packages/desktop-client/src/components/sidebar/ItemContent.tsx
index 2ba413baa7..73ca838f5b 100644
--- a/packages/desktop-client/src/components/sidebar/ItemContent.tsx
+++ b/packages/desktop-client/src/components/sidebar/ItemContent.tsx
@@ -38,7 +38,7 @@ export function ItemContent({
{children}
</View>
) : (
- <Link to={to} style={style} activeStyle={activeStyle}>
+ <Link variant="internal" to={to} style={style} activeStyle={activeStyle}>
{children}
</Link>
);
diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsx
index 7b0a3ecc45..60f38a0ee7 100644
--- a/packages/desktop-client/src/components/table.tsx
+++ b/packages/desktop-client/src/components/table.tsx
@@ -29,7 +29,7 @@ import { SvgDelete, SvgExpandArrow } from '../icons/v0';
import { SvgCheckmark } from '../icons/v1';
import { type CSSProperties, styles, theme } from '../style';
-import { Button } from './common/Button';
+import { Button } from './common/Button2';
import { Input } from './common/Input';
import { Menu, type MenuItem } from './common/Menu';
import { Popover } from './common/Popover';
@@ -843,9 +843,9 @@ export function SelectedItemsButton<T extends MenuItem = MenuItem>({
<View style={{ marginLeft: 10, flexShrink: 0 }}>
<Button
ref={triggerRef}
- type="bare"
+ variant="bare"
style={{ color: theme.pageTextPositive }}
- onClick={() => setMenuOpen(true)}
+ onPress={() => setMenuOpen(true)}
data-testid={id + '-select-button'}
>
<SvgExpandArrow
diff --git a/upcoming-release-notes/3163.md b/upcoming-release-notes/3163.md
new file mode 100644
index 0000000000..f6c8d75db2
--- /dev/null
+++ b/upcoming-release-notes/3163.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Use new react-aria-components in common and mobile components.