A local-first personal finance app
React Aria Button on Settings and Rules Page (#2913)
Joel Jeremy Marqueza67c969189c2
diff --git a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.pngindex 833c32d9a0..e3724cb798 100644Binary files a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.pngindex 1f904d3812..e64c9a6a14 100644Binary files a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.pngindex 0774a4ed58..2986a14dda 100644Binary files a/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png differdiff --git a/packages/desktop-client/src/components/rules/RuleRow.tsx b/packages/desktop-client/src/components/rules/RuleRow.tsxindex 4b8a748a83..913a6b045d 100644--- a/packages/desktop-client/src/components/rules/RuleRow.tsx+++ b/packages/desktop-client/src/components/rules/RuleRow.tsx@@ -9,11 +9,11 @@ import { type RuleEntity } from 'loot-core/src/types/models';import { useSelectedDispatch } from '../../hooks/useSelected';import { SvgRightArrow2 } from '../../icons/v0';import { styles, theme } from '../../style';-import { Button } from '../common/Button';+import { Button } from '../common/Button2';import { Stack } from '../common/Stack';import { Text } from '../common/Text';import { View } from '../common/View';-import { SelectCell, Row, Field, Cell, CellButton } from '../table';+import { SelectCell, Row, Field, Cell } from '../table';import { ActionExpression } from './ActionExpression';import { ConditionExpression } from './ConditionExpression';@@ -162,10 +162,7 @@ export const RuleRow = memo(</Field><Cell name="edit" plain style={{ padding: '0 15px', paddingLeft: 5 }}>- {/* @ts-expect-error fix this later */}- <Button as={CellButton} onSelect={() => onEditRule(rule)}>- Edit- </Button>+ <Button onPress={() => onEditRule(rule)}>Edit</Button></Cell></Row>);diff --git a/packages/desktop-client/src/components/settings/Encryption.tsx b/packages/desktop-client/src/components/settings/Encryption.tsxindex ee76328f38..1328af761c 100644--- a/packages/desktop-client/src/components/settings/Encryption.tsx+++ b/packages/desktop-client/src/components/settings/Encryption.tsx@@ -1,10 +1,12 @@// @ts-strict-ignoreimport React from 'react';+import { useDispatch } from 'react-redux';++import { pushModal } from 'loot-core/client/actions';-import { useActions } from '../../hooks/useActions';import { useLocalPref } from '../../hooks/useLocalPref';import { theme } from '../../style';-import { Button } from '../common/Button';+import { Button } from '../common/Button2';import { Link } from '../common/Link';import { Text } from '../common/Text';import { useServerURL } from '../ServerContext';@@ -12,19 +14,19 @@ import { useServerURL } from '../ServerContext';import { Setting } from './UI';export function EncryptionSettings() {- const { pushModal } = useActions();+ const dispatch = useDispatch();const serverURL = useServerURL();const [encryptKeyId] = useLocalPref('encryptKeyId');const missingCryptoAPI = !(window.crypto && crypto.subtle);function onChangeKey() {- pushModal('create-encryption-key', { recreate: true });+ dispatch(pushModal('create-encryption-key', { recreate: true }));}return encryptKeyId ? (<Setting- primaryAction={<Button onClick={onChangeKey}>Generate new key</Button>}+ primaryAction={<Button onPress={onChangeKey}>Generate new key</Button>}><Text><Text style={{ color: theme.noticeTextLight, fontWeight: 600 }}>@@ -43,7 +45,7 @@ export function EncryptionSettings() {</Text></Setting>) : missingCryptoAPI ? (- <Setting primaryAction={<Button disabled>Enable encryption…</Button>}>+ <Setting primaryAction={<Button isDisabled>Enable encryption…</Button>}><Text><strong>End-to-end encryption</strong> is not available when making anunencrypted connection to a remote server. You’ll need to enable HTTPS@@ -61,7 +63,7 @@ export function EncryptionSettings() {) : serverURL ? (<SettingprimaryAction={- <Button onClick={() => pushModal('create-encryption-key')}>+ <Button onPress={() => dispatch(pushModal('create-encryption-key'))}>Enable encryption…</Button>}@@ -82,7 +84,7 @@ export function EncryptionSettings() {</Text></Setting>) : (- <Setting primaryAction={<Button disabled>Enable encryption…</Button>}>+ <Setting primaryAction={<Button isDisabled>Enable encryption…</Button>}><Text><strong>End-to-end encryption</strong> is not available when runningwithout a server. Budget files are always kept unencrypted locally, anddiff --git a/packages/desktop-client/src/components/settings/Export.tsx b/packages/desktop-client/src/components/settings/Export.tsxindex b61f5d724a..7a9179becf 100644--- a/packages/desktop-client/src/components/settings/Export.tsx+++ b/packages/desktop-client/src/components/settings/Export.tsx@@ -7,7 +7,7 @@ import { send } from 'loot-core/src/platform/client/fetch';import { useLocalPref } from '../../hooks/useLocalPref';import { theme } from '../../style';import { Block } from '../common/Block';-import { ButtonWithLoading } from '../common/Button';+import { ButtonWithLoading } from '../common/Button2';import { Text } from '../common/Text';import { Setting } from './UI';@@ -43,7 +43,7 @@ export function ExportBudget() {<SettingprimaryAction={<>- <ButtonWithLoading onClick={onExport} loading={isLoading}>+ <ButtonWithLoading onPress={onExport} isLoading={isLoading}>Export data</ButtonWithLoading>{error && (diff --git a/packages/desktop-client/src/components/settings/FixSplits.tsx b/packages/desktop-client/src/components/settings/FixSplits.tsxindex 8a8be2a7fe..17d712ad14 100644--- a/packages/desktop-client/src/components/settings/FixSplits.tsx+++ b/packages/desktop-client/src/components/settings/FixSplits.tsx@@ -4,7 +4,7 @@ import { send } from 'loot-core/src/platform/client/fetch';import { type Handlers } from 'loot-core/src/types/handlers';import { theme } from '../../style';-import { ButtonWithLoading } from '../common/Button';+import { ButtonWithLoading } from '../common/Button2';import { Paragraph } from '../common/Paragraph';import { Text } from '../common/Text';import { View } from '../common/View';@@ -74,7 +74,7 @@ export function FixSplits() {alignItems: 'center',}}>- <ButtonWithLoading loading={loading} onClick={onFix}>+ <ButtonWithLoading isLoading={loading} onPress={onFix}>Repair split transactions</ButtonWithLoading>{results && renderResults(results)}diff --git a/packages/desktop-client/src/components/settings/Format.tsx b/packages/desktop-client/src/components/settings/Format.tsxindex a64613b34f..b4d4e7bdd3 100644--- a/packages/desktop-client/src/components/settings/Format.tsx+++ b/packages/desktop-client/src/components/settings/Format.tsx@@ -6,8 +6,8 @@ import { type LocalPrefs } from 'loot-core/src/types/prefs';import { useDateFormat } from '../../hooks/useDateFormat';import { useLocalPref } from '../../hooks/useLocalPref';+import { type CSSProperties, theme } from '../../style';import { tokens } from '../../tokens';-import { Button } from '../common/Button';import { Select } from '../common/Select';import { Text } from '../common/Text';import { View } from '../common/View';@@ -65,6 +65,12 @@ export function FormatSettings() {const [hideFraction = false, setHideFractionPref] =useLocalPref('hideFraction');+ const selectButtonStyle: CSSProperties = {+ ':hover': {+ backgroundColor: theme.buttonNormalBackgroundHover,+ },+ };+return (<SettingprimaryAction={@@ -83,18 +89,16 @@ export function FormatSettings() {}}><Column title="Numbers">- <Button bounce={false} style={{ padding: 0 }}>- <Select- bare- key={String(hideFraction)} // needed because label does not update- value={numberFormat}- onChange={setNumberFormatPref}- options={numberFormats.map(f => [- f.value,- hideFraction ? f.labelNoFraction : f.label,- ])}- />- </Button>+ <Select+ key={String(hideFraction)} // needed because label does not update+ value={numberFormat}+ onChange={format => setNumberFormatPref(format)}+ options={numberFormats.map(f => [+ f.value,+ hideFraction ? f.labelNoFraction : f.label,+ ])}+ buttonStyle={selectButtonStyle}+ /><Text style={{ display: 'flex' }}><Checkbox@@ -107,25 +111,21 @@ export function FormatSettings() {</Column><Column title="Dates">- <Button bounce={false} style={{ padding: 0 }}>- <Select- bare- value={dateFormat}- onChange={setDateFormatPref}- options={dateFormats.map(f => [f.value, f.label])}- />- </Button>+ <Select+ value={dateFormat}+ onChange={format => setDateFormatPref(format)}+ options={dateFormats.map(f => [f.value, f.label])}+ buttonStyle={selectButtonStyle}+ /></Column><Column title="First day of the week">- <Button bounce={false} style={{ padding: 0 }}>- <Select- bare- value={firstDayOfWeekIdx}- onChange={setFirstDayOfWeekIdxPref}- options={daysOfWeek.map(f => [f.value, f.label])}- />- </Button>+ <Select+ value={firstDayOfWeekIdx}+ onChange={idx => setFirstDayOfWeekIdxPref(idx)}+ options={daysOfWeek.map(f => [f.value, f.label])}+ buttonStyle={selectButtonStyle}+ /></Column></View>}diff --git a/packages/desktop-client/src/components/settings/Global.tsx b/packages/desktop-client/src/components/settings/Global.tsxindex da9fa01d74..242d76d409 100644--- a/packages/desktop-client/src/components/settings/Global.tsx+++ b/packages/desktop-client/src/components/settings/Global.tsx@@ -3,7 +3,7 @@ import React, { useState, useEffect, useRef } from 'react';import { useGlobalPref } from '../../hooks/useGlobalPref';import { theme } from '../../style';import { Information } from '../alerts';-import { Button } from '../common/Button';+import { Button } from '../common/Button2';import { Text } from '../common/Text';import { View } from '../common/View';@@ -35,7 +35,7 @@ export function GlobalSettings() {<SettingprimaryAction={<View style={{ flexDirection: 'row' }}>- <Button onClick={onChooseDocumentDir}>Change location</Button>+ <Button onPress={onChooseDocumentDir}>Change location</Button>{documentDirChanged && (<Information>A restart is required for this change to take effectdiff --git a/packages/desktop-client/src/components/settings/Reset.tsx b/packages/desktop-client/src/components/settings/Reset.tsxindex 78d7f88a9d..9ceb5883a7 100644--- a/packages/desktop-client/src/components/settings/Reset.tsx+++ b/packages/desktop-client/src/components/settings/Reset.tsx@@ -4,7 +4,7 @@ import { send } from 'loot-core/src/platform/client/fetch';import { useActions } from '../../hooks/useActions';import { useLocalPref } from '../../hooks/useLocalPref';-import { ButtonWithLoading } from '../common/Button';+import { ButtonWithLoading } from '../common/Button2';import { Text } from '../common/Text';import { Setting } from './UI';@@ -21,7 +21,7 @@ export function ResetCache() {return (<SettingprimaryAction={- <ButtonWithLoading loading={resetting} onClick={onResetCache}>+ <ButtonWithLoading isLoading={resetting} onPress={onResetCache}>Reset budget cache</ButtonWithLoading>}@@ -54,9 +54,9 @@ export function ResetSync() {<SettingprimaryAction={<ButtonWithLoading- loading={resetting}- disabled={!isEnabled}- onClick={onResetSync}+ isLoading={resetting}+ isDisabled={!isEnabled}+ onPress={onResetSync}>Reset sync</ButtonWithLoading>diff --git a/packages/desktop-client/src/components/settings/Themes.tsx b/packages/desktop-client/src/components/settings/Themes.tsxindex 494d7fc39e..44e713ae53 100644--- a/packages/desktop-client/src/components/settings/Themes.tsx+++ b/packages/desktop-client/src/components/settings/Themes.tsx@@ -2,8 +2,7 @@ import React from 'react';import { type Theme } from 'loot-core/types/prefs';-import { themeOptions, useTheme } from '../../style';-import { Button } from '../common/Button';+import { themeOptions, useTheme, theme as themeStyle } from '../../style';import { Select } from '../common/Select';import { Text } from '../common/Text';@@ -15,14 +14,18 @@ export function ThemeSettings() {return (<SettingprimaryAction={- <Button bounce={false} style={{ padding: 0 }}>- <Select<Theme>- bare- onChange={switchTheme}- value={theme}- options={themeOptions}- />- </Button>+ <Select<Theme>+ onChange={value => {+ switchTheme(value);+ }}+ value={theme}+ options={themeOptions}+ buttonStyle={{+ ':hover': {+ backgroundColor: themeStyle.buttonNormalBackgroundHover,+ },+ }}+ />}><Text>diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsxindex fe7c797110..3da251d768 100644--- a/packages/desktop-client/src/components/settings/index.tsx+++ b/packages/desktop-client/src/components/settings/index.tsx@@ -13,7 +13,7 @@ import { useSetThemeColor } from '../../hooks/useSetThemeColor';import { useResponsive } from '../../ResponsiveProvider';import { theme } from '../../style';import { tokens } from '../../tokens';-import { Button } from '../common/Button';+import { Button } from '../common/Button2';import { Input } from '../common/Input';import { Link } from '../common/Link';import { Text } from '../common/Text';@@ -167,7 +167,7 @@ export function Settings() {style={{ color: theme.buttonNormalDisabledText }}/></FormField>- <Button onClick={closeBudget}>Close Budget</Button>+ <Button onPress={closeBudget}>Close Budget</Button></View>)}diff --git a/upcoming-release-notes/2913.md b/upcoming-release-notes/2913.mdnew file mode 100644index 0000000000..a1272ae781--- /dev/null+++ b/upcoming-release-notes/2913.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [joel-jeremy]+---++Use new react-aria-components based Button on settings and rules page.