Skip to content

A local-first personal finance app

feat: show/hide balance graph in side nav (#5452)

Matiss Janis Aboltins0fa582b3d3af
diff --git a/packages/component-library/src/SpaceBetween.tsx b/packages/component-library/src/SpaceBetween.tsx
index 582a4745d0..547518f00f 100644
--- a/packages/component-library/src/SpaceBetween.tsx
+++ b/packages/component-library/src/SpaceBetween.tsx
@@ -1,5 +1,6 @@
-import React, { type CSSProperties, type ReactNode } from 'react';
+import React, { type ReactNode } from 'react';
+import { type CSSProperties } from './styles';
import { View } from './View';
type SpaceBetweenProps = {
diff --git a/packages/desktop-client/src/components/sidebar/Account.tsx b/packages/desktop-client/src/components/sidebar/Account.tsx
index d5df8190b5..7e86378685 100644
--- a/packages/desktop-client/src/components/sidebar/Account.tsx
+++ b/packages/desktop-client/src/components/sidebar/Account.tsx
@@ -1,11 +1,18 @@
// @ts-strict-ignore
import React, { type CSSProperties, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import { AlignedText } from '@actual-app/components/aligned-text';
+import { Button } from '@actual-app/components/button';
+import {
+ SvgArrowButtonDown1,
+ SvgArrowButtonUp1,
+} from '@actual-app/components/icons/v2';
import { InitialFocus } from '@actual-app/components/initial-focus';
import { Input } from '@actual-app/components/input';
import { Menu } from '@actual-app/components/menu';
import { Popover } from '@actual-app/components/popover';
+import { SpaceBetween } from '@actual-app/components/space-between';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
@@ -31,6 +38,7 @@ import { CellValue } from '@desktop-client/components/spreadsheet/CellValue';
import { useContextMenu } from '@desktop-client/hooks/useContextMenu';
import { useDragRef } from '@desktop-client/hooks/useDragRef';
import { useNotes } from '@desktop-client/hooks/useNotes';
+import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';
import { openAccountCloseModal } from '@desktop-client/modals/modalsSlice';
import {
reopenAccount,
@@ -83,6 +91,7 @@ export function Account<FieldName extends SheetFields<'account'>>({
onDrop,
titleAccount,
}: AccountProps<FieldName>) {
+ const { t } = useTranslation();
const type = account
? account.closed
? 'account-closed'
@@ -109,6 +118,10 @@ export function Account<FieldName extends SheetFields<'account'>>({
onDrop,
});
+ const [showBalanceHistory, setShowBalanceHistory] = useSyncedPref(
+ `side-nav.show-balance-history-${account?.id}`,
+ );
+
const dispatch = useDispatch();
const [isEditing, setIsEditing] = useState(false);
@@ -281,14 +294,48 @@ export function Account<FieldName extends SheetFields<'account'>>({
padding: 10,
}}
>
- <Text
+ <SpaceBetween
+ gap={5}
style={{
- fontWeight: 'bold',
+ justifyContent: 'space-between',
+ '& .hover-visible': {
+ opacity: 0,
+ transition: 'opacity .25s',
+ },
+ '&:hover .hover-visible': {
+ opacity: 1,
+ },
}}
>
- {name}
- </Text>
- {account && <BalanceHistoryGraph accountId={account.id} />}
+ <Text
+ style={{
+ fontWeight: 'bold',
+ }}
+ >
+ {name}
+ </Text>
+ <Button
+ aria-label={t('Toggle balance history')}
+ variant="bare"
+ onClick={() =>
+ setShowBalanceHistory(
+ showBalanceHistory === 'true' ? 'false' : 'true',
+ )
+ }
+ className="hover-visible"
+ >
+ <SpaceBetween gap={3}>
+ {showBalanceHistory === 'true' ? (
+ <SvgArrowButtonUp1 width={10} height={10} />
+ ) : (
+ <SvgArrowButtonDown1 width={10} height={10} />
+ )}
+ </SpaceBetween>
+ </Button>
+ </SpaceBetween>
+ {showBalanceHistory === 'true' && account && (
+ <BalanceHistoryGraph accountId={account.id} />
+ )}
{accountNote && (
<Notes
getStyle={() => ({
diff --git a/packages/loot-core/src/types/prefs.ts b/packages/loot-core/src/types/prefs.ts
index 9e29467ab8..e41c22f85f 100644
--- a/packages/loot-core/src/types/prefs.ts
+++ b/packages/loot-core/src/types/prefs.ts
@@ -20,6 +20,7 @@ export type SyncedPrefs = Partial<
| 'currencySymbolPosition'
| 'currencySpaceBetweenAmountAndSymbol'
| 'defaultCurrencyCode'
+ | `side-nav.show-balance-history-${string}`
| `show-balances-${string}`
| `show-extra-balances-${string}`
| `hide-cleared-${string}`
diff --git a/upcoming-release-notes/5452.md b/upcoming-release-notes/5452.md
new file mode 100644
index 0000000000..a6ef34da40
--- /dev/null
+++ b/upcoming-release-notes/5452.md
@@ -0,0 +1,7 @@
+---
+category: Enhancements
+authors: [MatissJanis]
+---
+
+Add toggle feature to show/hide balance history graph in sidebar account tooltip.
+