A local-first personal finance app
sidebar pt. 3: redesigned shell (#8882)
Matt Fiddamanca442c88cb6d
diff --git a/packages/component-library/src/styles.ts b/packages/component-library/src/styles.tsindex d3c00279ea..607da6ec26 100644--- a/packages/component-library/src/styles.ts+++ b/packages/component-library/src/styles.ts@@ -128,6 +128,11 @@ export const styles: CSSProperties = {wordBreak: 'break-word',};},+ ellipsisText: {+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ },tooltip: {padding: 5,...shadowLarge,diff --git a/packages/component-library/src/theme.ts b/packages/component-library/src/theme.tsindex 873da230ed..52e012c7f5 100644--- a/packages/component-library/src/theme.ts+++ b/packages/component-library/src/theme.ts@@ -51,6 +51,16 @@ export const theme = {sidebarItemTextUpdated: 'var(--color-sidebarItemTextUpdated)',sidebarItemTextSelected: 'var(--color-sidebarItemTextSelected)',sidebarBudgetName: 'var(--color-sidebarBudgetName)',+ sidebarItemBackgroundSelected: 'var(--color-sidebarItemBackgroundSelected)',+ sidebarHeaderText: 'var(--color-sidebarHeaderText)',+ sidebarTextSubdued: 'var(--color-sidebarTextSubdued)',+ sidebarTextMuted: 'var(--color-sidebarTextMuted)',+ sidebarTextPositive: 'var(--color-sidebarTextPositive)',+ sidebarTextFailed: 'var(--color-sidebarTextFailed)',+ sidebarBackgroundFailedSubtle: 'var(--color-sidebarBackgroundFailedSubtle)',+ sidebarBorder: 'var(--color-sidebarBorder)',+ sidebarControlBackground: 'var(--color-sidebarControlBackground)',+ sidebarBrand: 'var(--color-sidebarBrand)',menuBackground: 'var(--color-menuBackground)',menuItemBackground: 'var(--color-menuItemBackground)',menuItemBackgroundHover: 'var(--color-menuItemBackgroundHover)',diff --git a/packages/component-library/src/themes/dark.css b/packages/component-library/src/themes/dark.cssindex cbb3bdd0a7..c230e4b3fb 100644--- a/packages/component-library/src/themes/dark.css+++ b/packages/component-library/src/themes/dark.css@@ -58,10 +58,28 @@--color-sidebarItemBackgroundFailed: var(--palette-red300);--color-sidebarItemAccentSelected: var(--palette-purple200);--color-sidebarItemBackgroundHover: var(--palette-navy700);+ --color-sidebarItemBackgroundSelected: color-mix(+ in srgb,+ var(--color-sidebarItemAccentSelected) 22%,+ transparent+ );--color-sidebarItemText: var(--palette-navy150);--color-sidebarItemTextUpdated: var(--color-sidebarItemText);--color-sidebarItemTextSelected: var(--palette-purple200);--color-sidebarBudgetName: var(--palette-navy300);+ --color-sidebarHeaderText: var(--palette-white);+ --color-sidebarTextSubdued: var(--palette-navy300);+ --color-sidebarTextMuted: var(--palette-navy500);+ --color-sidebarTextPositive: var(--color-sidebarItemBackgroundPositive);+ --color-sidebarTextFailed: var(--color-sidebarItemBackgroundFailed);+ --color-sidebarBackgroundFailedSubtle: color-mix(+ in srgb,+ var(--color-sidebarItemBackgroundFailed) 16%,+ transparent+ );+ --color-sidebarBorder: var(--color-sidebarItemBackgroundHover);+ --color-sidebarControlBackground: var(--color-sidebarItemBackgroundHover);+ --color-sidebarBrand: var(--color-sidebarItemAccentSelected);--color-menuBackground: var(--palette-navy800);--color-menuItemBackground: var(--palette-navy800);diff --git a/packages/component-library/src/themes/light.css b/packages/component-library/src/themes/light.cssindex b69618af77..de7d713933 100644--- a/packages/component-library/src/themes/light.css+++ b/packages/component-library/src/themes/light.css@@ -58,10 +58,38 @@--color-sidebarItemBackgroundFailed: var(--palette-red300);--color-sidebarItemBackgroundHover: var(--palette-navy800);--color-sidebarItemAccentSelected: var(--palette-purple200);+ --color-sidebarItemBackgroundSelected: color-mix(+ in srgb,+ var(--color-sidebarItemAccentSelected) 22%,+ transparent+ );--color-sidebarItemText: var(--palette-navy150);--color-sidebarItemTextUpdated: var(--color-sidebarItemText);--color-sidebarItemTextSelected: var(--palette-purple200);--color-sidebarBudgetName: var(--palette-navy150);+ --color-sidebarHeaderText: var(--palette-white);+ --color-sidebarTextSubdued: var(--palette-navy300);+ --color-sidebarTextMuted: var(--palette-navy500);+ --color-sidebarTextPositive: var(--color-sidebarItemBackgroundPositive);+ --color-sidebarTextFailed: var(--color-sidebarItemBackgroundFailed);+ --color-sidebarBackgroundFailedSubtle: color-mix(+ in srgb,+ var(--color-sidebarItemBackgroundFailed) 16%,+ transparent+ );+ --color-sidebarBorder: var(--color-sidebarItemBackgroundHover);+ --color-sidebarControlBackground: var(--color-sidebarItemBackgroundHover);+ --color-sidebarBrand: var(--color-sidebarItemAccentSelected);+ --color-sidebarRedesignBackground: var(--palette-white);+ --color-sidebarRedesignItemText: var(--palette-navy800);+ --color-sidebarRedesignItemBackgroundHover: var(--palette-navy100);+ --color-sidebarRedesignItemAccentSelected: var(--palette-purple500);+ --color-sidebarRedesignItemTextSelected: var(--palette-purple600);+ --color-sidebarRedesignItemBackgroundSelected: var(--palette-purple100);+ --color-sidebarRedesignItemBackgroundFailed: var(--palette-red500);+ --color-sidebarRedesignHeaderText: var(--palette-gray700);+ --color-sidebarRedesignTextSubdued: var(--palette-navy600);+ --color-sidebarRedesignTextMuted: var(--palette-navy400);--color-menuBackground: var(--palette-white);--color-menuItemBackground: var(--palette-navy50);@@ -252,3 +280,40 @@--color-chartQual8: var(--palette-chartQual8);--color-chartQual9: var(--palette-chartQual9);}++/* Light-theme overrides scoped to the redesigned sidebar so the classic+ sidebar keeps its navy styling while the newSidebarUI flag exists. This+ block only remaps the sidebar token family onto the sidebarRedesign*+ values declared at :root, where custom themes can override them. */+.sidebar-redesign {+ --color-sidebarBackground: var(--color-sidebarRedesignBackground);+ --color-sidebarItemText: var(--color-sidebarRedesignItemText);+ --color-sidebarItemBackgroundHover: var(+ --color-sidebarRedesignItemBackgroundHover+ );+ --color-sidebarItemAccentSelected: var(+ --color-sidebarRedesignItemAccentSelected+ );+ --color-sidebarItemTextSelected: var(--color-sidebarRedesignItemTextSelected);+ --color-sidebarItemBackgroundSelected: var(+ --color-sidebarRedesignItemBackgroundSelected+ );+ --color-sidebarItemBackgroundFailed: var(+ --color-sidebarRedesignItemBackgroundFailed+ );+ --color-sidebarHeaderText: var(--color-sidebarRedesignHeaderText);+ --color-sidebarTextSubdued: var(--color-sidebarRedesignTextSubdued);+ --color-sidebarTextMuted: var(--color-sidebarRedesignTextMuted);+ /* Derived tokens must be redeclared here: var() references in custom+ properties resolve where the property is declared, so the :root+ derivations would otherwise keep the classic navy values */+ --color-sidebarTextFailed: var(--color-sidebarItemBackgroundFailed);+ --color-sidebarBackgroundFailedSubtle: color-mix(+ in srgb,+ var(--color-sidebarItemBackgroundFailed) 16%,+ transparent+ );+ --color-sidebarBorder: var(--color-sidebarItemBackgroundHover);+ --color-sidebarControlBackground: var(--color-sidebarItemBackgroundHover);+ --color-sidebarBrand: var(--color-sidebarItemAccentSelected);+}diff --git a/packages/component-library/src/themes/midnight.css b/packages/component-library/src/themes/midnight.cssindex 71f26f450a..7577e5c529 100644--- a/packages/component-library/src/themes/midnight.css+++ b/packages/component-library/src/themes/midnight.css@@ -58,10 +58,28 @@--color-sidebarItemBackgroundFailed: var(--palette-red300);--color-sidebarItemAccentSelected: var(--palette-purple200);--color-sidebarItemBackgroundHover: var(--palette-gray700);+ --color-sidebarItemBackgroundSelected: color-mix(+ in srgb,+ var(--color-sidebarItemAccentSelected) 35%,+ transparent+ );--color-sidebarItemText: var(--palette-gray100);--color-sidebarItemTextUpdated: var(--color-sidebarItemText);--color-sidebarItemTextSelected: var(--palette-purple200);--color-sidebarBudgetName: var(--palette-gray300);+ --color-sidebarHeaderText: var(--palette-gray100);+ --color-sidebarTextSubdued: var(--palette-gray300);+ --color-sidebarTextMuted: var(--palette-gray500);+ --color-sidebarTextPositive: var(--color-sidebarItemBackgroundPositive);+ --color-sidebarTextFailed: var(--color-sidebarItemBackgroundFailed);+ --color-sidebarBackgroundFailedSubtle: color-mix(+ in srgb,+ var(--color-sidebarItemBackgroundFailed) 16%,+ transparent+ );+ --color-sidebarBorder: var(--color-sidebarItemBackgroundHover);+ --color-sidebarControlBackground: var(--color-sidebarItemBackgroundHover);+ --color-sidebarBrand: var(--color-sidebarItemAccentSelected);--color-menuBackground: var(--palette-gray700);--color-menuItemBackground: var(--palette-gray200);diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsxindex 723d9ab096..fd19833f16 100644--- a/packages/desktop-client/src/components/Titlebar.tsx+++ b/packages/desktop-client/src/components/Titlebar.tsx@@ -1,4 +1,4 @@-import React, { useEffect, useState } from 'react';+import React from 'react';import { useHotkeys } from 'react-hotkeys-hook';import { Trans, useTranslation } from 'react-i18next';import { Route, Routes, useLocation } from 'react-router';@@ -19,7 +19,6 @@ import { Text } from '@actual-app/components/text';import { theme } from '@actual-app/components/theme';import { Tooltip } from '@actual-app/components/tooltip';import { View } from '@actual-app/components/view';-import { listen } from '@actual-app/core/platform/client/connection';import { isDevelopmentEnvironment } from '@actual-app/core/shared/environment';import * as Platform from '@actual-app/core/shared/platform';import { css } from '@emotion/css';@@ -28,10 +27,10 @@ import { sync } from '#app/appSlice';import { SharedArrayBufferWarning } from '#components/SharedArrayBufferWarning';import { useGlobalPref } from '#hooks/useGlobalPref';import { useIsTestEnv } from '#hooks/useIsTestEnv';-import { useMetadataPref } from '#hooks/useMetadataPref';import { useNavigate } from '#hooks/useNavigate';import { useSheetValue } from '#hooks/useSheetValue';import { useSyncedPref } from '#hooks/useSyncedPref';+import { useSyncStatus } from '#hooks/useSyncStatus';import { useDispatch } from '#redux';import * as bindings from '#spreadsheet/bindings';@@ -126,45 +125,12 @@ type ServerSyncButtonProps = {};function ServerSyncButton({ style, isMobile = false }: ServerSyncButtonProps) {const { t } = useTranslation();- const [cloudFileId] = useMetadataPref('cloudFileId');const dispatch = useDispatch();- const [syncing, setSyncing] = useState(false);- const [syncState, setSyncState] = useState<- null | 'offline' | 'local' | 'disabled' | 'error'- >(null);-- useEffect(() => {- const unlisten = listen('sync-event', event => {- if (event.type === 'start') {- setSyncing(true);- setSyncState(null);- } else {- // Give the layout some time to apply the starting animation- // so we always finish it correctly even if it's almost- // instant- setTimeout(() => {- setSyncing(false);- }, 200);- }-- if (event.type === 'error') {- // Use the offline state if either there is a network error or- // if this file isn't a "cloud file". You can't sync a local- // file.- if (event.subtype === 'network') {- setSyncState('offline');- } else if (!cloudFileId) {- setSyncState('local');- } else {- setSyncState('error');- }- } else if (event.type === 'success') {- setSyncState(event.syncDisabled ? 'disabled' : null);- }- });-- return unlisten;- }, [cloudFileId]);+ // Give the layout some time to apply the starting animation so we+ // always finish it correctly even if the sync is almost instant+ const { isSyncing: syncing, syncState } = useSyncStatus({+ syncingEndDelayMs: 200,+ });const mobileColor =syncState === 'error'diff --git a/packages/desktop-client/src/components/sidebar/Sidebar.tsx b/packages/desktop-client/src/components/sidebar/Sidebar.tsxindex 3b0136021f..cd3ab95221 100644--- a/packages/desktop-client/src/components/sidebar/Sidebar.tsx+++ b/packages/desktop-client/src/components/sidebar/Sidebar.tsx@@ -1,21 +1,10 @@-import React, { useState } from 'react';-import type { CSSProperties } from 'react';-import { ErrorBoundary } from 'react-error-boundary';+import React from 'react';import { useTranslation } from 'react-i18next';-import { useResponsive } from '@actual-app/components/hooks/useResponsive';import { SvgAdd } from '@actual-app/components/icons/v1';-import { styles } from '@actual-app/components/styles';-import { theme } from '@actual-app/components/theme';import { View } from '@actual-app/components/view';-import * as Platform from '@actual-app/core/shared/platform';-import { css } from '@emotion/css';-import { Resizable } from 're-resizable';-import { FeatureErrorFallback } from '#components/FeatureErrorFallback';import { useGlobalPref } from '#hooks/useGlobalPref';-import { useLocalPref } from '#hooks/useLocalPref';-import { useResizeObserver } from '#hooks/useResizeObserver';import { replaceModal } from '#modals/modalsSlice';import { useDispatch } from '#redux';@@ -24,38 +13,16 @@ import { BudgetName } from './BudgetName';import { PrimaryButtons } from './PrimaryButtons';import { SecondaryButtons } from './SecondaryButtons';import { useSidebar } from './SidebarProvider';+import { SidebarShell } from './SidebarShell';import { ToggleButton } from './ToggleButton';export function Sidebar() {- const hasWindowButtons = !Platform.isBrowser && Platform.OS === 'mac';-const { t } = useTranslation();const dispatch = useDispatch();const sidebar = useSidebar();- const { width } = useResponsive();const [isFloating = false, setFloatingSidebarPref] =useGlobalPref('floatingSidebar');- const [sidebarWidthLocalPref, setSidebarWidthLocalPref] =- useLocalPref('sidebarWidth');- const DEFAULT_SIDEBAR_WIDTH = 240;- const MAX_SIDEBAR_WIDTH = width / 3;- const MIN_SIDEBAR_WIDTH = 200;-- const [sidebarWidth, setSidebarWidth] = useState(- Math.min(- MAX_SIDEBAR_WIDTH,- Math.max(- MIN_SIDEBAR_WIDTH,- sidebarWidthLocalPref || DEFAULT_SIDEBAR_WIDTH,- ),- ),- );-- const onResizeStop = () => {- setSidebarWidthLocalPref(sidebarWidth);- };-const onFloat = () => {setFloatingSidebarPref(!isFloating);};@@ -64,81 +31,37 @@ export function Sidebar() {dispatch(replaceModal({ modal: { name: 'add-account', options: {} } }));};- const containerRef = useResizeObserver<HTMLDivElement>(rect => {- setSidebarWidth(rect.width);- });-return (- <ErrorBoundary FallbackComponent={FeatureErrorFallback}>- <Resizable- defaultSize={{- width: sidebarWidth,- height: '100%',- }}- onResizeStop={onResizeStop}- maxWidth={MAX_SIDEBAR_WIDTH}- minWidth={MIN_SIDEBAR_WIDTH}- enable={{- top: false,- right: true,- bottom: false,- left: false,- topRight: false,- bottomRight: false,- bottomLeft: false,- topLeft: false,+ <SidebarShell>+ <BudgetName>+ {!sidebar.alwaysFloats && (+ <ToggleButton isFloating={isFloating} onFloat={onFloat} />+ )}+ </BudgetName>++ <View+ style={{+ flexGrow: 1,+ '@media screen and (max-height: 480px)': {+ overflowY: 'auto',+ },}}>- <View- innerRef={containerRef}- className={css({- color: theme.sidebarItemText,- height: '100%',- backgroundColor: theme.sidebarBackground,- '& .float': {- opacity: isFloating ? 1 : 0,- transition: 'opacity .25s, width .25s',- width: hasWindowButtons || isFloating ? null : 0,- } as CSSProperties,- '&:hover .float': {- opacity: 1,- width: hasWindowButtons ? null : 'auto',- } as CSSProperties,- flex: 1,- ...styles.darkScrollbar,- })}- >- <BudgetName>- {!sidebar.alwaysFloats && (- <ToggleButton isFloating={isFloating} onFloat={onFloat} />- )}- </BudgetName>-- <View- style={{- flexGrow: 1,- '@media screen and (max-height: 480px)': {- overflowY: 'auto',- },- }}- >- <PrimaryButtons />+ <PrimaryButtons />- <Accounts />+ <Accounts />- <SecondaryButtons- buttons={[- {- title: t('Add account'),- Icon: SvgAdd,- onClick: onAddAccount,- dataTestId: 'sidebar-add-account',- },- ]}- />- </View>- </View>- </Resizable>- </ErrorBoundary>+ <SecondaryButtons+ buttons={[+ {+ title: t('Add account'),+ Icon: SvgAdd,+ onClick: onAddAccount,+ dataTestId: 'sidebar-add-account',+ },+ ]}+ />+ </View>+ </SidebarShell>);}diff --git a/packages/desktop-client/src/components/sidebar/SidebarShell.tsx b/packages/desktop-client/src/components/sidebar/SidebarShell.tsxnew file mode 100644index 0000000000..73fafafba2--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/SidebarShell.tsx@@ -0,0 +1,106 @@+import { useState } from 'react';+import type { CSSProperties, ReactNode } from 'react';+import { ErrorBoundary } from 'react-error-boundary';++import { useResponsive } from '@actual-app/components/hooks/useResponsive';+import { styles } from '@actual-app/components/styles';+import { theme } from '@actual-app/components/theme';+import { View } from '@actual-app/components/view';+import * as Platform from '@actual-app/core/shared/platform';+import { css, cx } from '@emotion/css';+import { Resizable } from 're-resizable';++import { FeatureErrorFallback } from '#components/FeatureErrorFallback';+import { useGlobalPref } from '#hooks/useGlobalPref';+import { useLocalPref } from '#hooks/useLocalPref';+import { useResizeObserver } from '#hooks/useResizeObserver';++const MIN_SIDEBAR_WIDTH = 200;++export function hasMacOSWindowButtons() {+ return !Platform.isBrowser && Platform.OS === 'mac';+}++type SidebarShellProps = {+ defaultWidth?: number;+ className?: string;+ children: ReactNode;+};++export function SidebarShell({+ defaultWidth = 240,+ className,+ children,+}: SidebarShellProps) {+ const hasWindowButtons = hasMacOSWindowButtons();+ const { width } = useResponsive();+ const [isFloating = false] = useGlobalPref('floatingSidebar');++ const [sidebarWidthLocalPref, setSidebarWidthLocalPref] =+ useLocalPref('sidebarWidth');+ const maxSidebarWidth = width / 3;++ const [sidebarWidth, setSidebarWidth] = useState(+ Math.min(+ maxSidebarWidth,+ Math.max(MIN_SIDEBAR_WIDTH, sidebarWidthLocalPref || defaultWidth),+ ),+ );++ const onResizeStop = () => {+ setSidebarWidthLocalPref(sidebarWidth);+ };++ const containerRef = useResizeObserver<HTMLDivElement>(rect => {+ setSidebarWidth(rect.width);+ });++ return (+ <ErrorBoundary FallbackComponent={FeatureErrorFallback}>+ <Resizable+ defaultSize={{+ width: sidebarWidth,+ height: '100%',+ }}+ onResizeStop={onResizeStop}+ maxWidth={maxSidebarWidth}+ minWidth={MIN_SIDEBAR_WIDTH}+ enable={{+ top: false,+ right: true,+ bottom: false,+ left: false,+ topRight: false,+ bottomRight: false,+ bottomLeft: false,+ topLeft: false,+ }}+ >+ <View+ innerRef={containerRef}+ className={cx(+ className,+ css({+ color: theme.sidebarItemText,+ height: '100%',+ backgroundColor: theme.sidebarBackground,+ '& .float': {+ opacity: isFloating ? 1 : 0,+ transition: 'opacity .25s, width .25s',+ width: hasWindowButtons || isFloating ? null : 0,+ } as CSSProperties,+ '&:hover .float': {+ opacity: 1,+ width: hasWindowButtons ? null : 'auto',+ } as CSSProperties,+ flex: 1,+ ...styles.darkScrollbar,+ }),+ )}+ >+ {children}+ </View>+ </Resizable>+ </ErrorBoundary>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/index.tsx b/packages/desktop-client/src/components/sidebar/index.tsxindex f3da4047dd..8bbf9d96af 100644--- a/packages/desktop-client/src/components/sidebar/index.tsx+++ b/packages/desktop-client/src/components/sidebar/index.tsx@@ -4,13 +4,16 @@ import { useResponsive } from '@actual-app/components/hooks/useResponsive';import { View } from '@actual-app/components/view';import { useDebounceCallback } from 'usehooks-ts';+import { useFeatureFlag } from '#hooks/useFeatureFlag';import { useGlobalPref } from '#hooks/useGlobalPref';+import { SidebarRedesign } from './redesign/SidebarRedesign';import { Sidebar } from './Sidebar';import { useSidebar } from './SidebarProvider';export function FloatableSidebar() {const [floatingSidebar] = useGlobalPref('floatingSidebar');+ const newSidebarUIEnabled = useFeatureFlag('newSidebarUI');const sidebar = useSidebar();const { isNarrowWidth } = useResponsive();@@ -55,7 +58,7 @@ export function FloatableSidebar() {'transform .5s, box-shadow .5s, border-radius .5s, bottom .5s',}}>- <Sidebar />+ {newSidebarUIEnabled ? <SidebarRedesign /> : <Sidebar />}</View>);}diff --git a/packages/desktop-client/src/components/sidebar/redesign/NavRow.tsx b/packages/desktop-client/src/components/sidebar/redesign/NavRow.tsxnew file mode 100644index 0000000000..6c015c7ccc--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/NavRow.tsx@@ -0,0 +1,50 @@+import type { ComponentType, SVGProps } from 'react';++import { styles } from '@actual-app/components/styles';+import { Text } from '@actual-app/components/text';+import { theme } from '@actual-app/components/theme';+import { radius, spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { Link } from '#components/common/Link';++type NavRowProps = {+ title: string;+ Icon:+ | ComponentType<SVGProps<SVGElement>>+ | ComponentType<SVGProps<SVGSVGElement>>;+ to: string;+};++export function NavRow({ title, Icon, to }: NavRowProps) {+ return (+ <View style={{ flexShrink: 0 }}>+ <Link+ variant="internal"+ to={to}+ style={{+ display: 'flex',+ flexDirection: 'row',+ alignItems: 'center',+ gap: spacing.sm,+ padding: spacing.sm,+ borderRadius: radius.sm,+ marginBottom: 1,+ fontSize: 13,+ fontWeight: 500,+ textDecoration: 'none',+ color: theme.sidebarItemText,+ ':hover': { backgroundColor: theme.sidebarItemBackgroundHover },+ }}+ activeStyle={{+ backgroundColor: theme.sidebarItemBackgroundSelected,+ color: theme.sidebarItemTextSelected,+ fontWeight: 600,+ }}+ >+ <Icon width={15} height={15} style={{ flexShrink: 0 }} />+ <Text style={styles.ellipsisText}>{title}</Text>+ </Link>+ </View>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsx b/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsxnew file mode 100644index 0000000000..3d30d46a36--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsx@@ -0,0 +1,45 @@+import { useTranslation } from 'react-i18next';++import {+ SvgLibrary,+ SvgReports,+ SvgTag,+ SvgTuning,+ SvgUserGroup,+ SvgWallet,+} from '@actual-app/components/icons/v1';+import { SvgCalendar3 } from '@actual-app/components/icons/v2';+import { spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { useIsTestEnv } from '#hooks/useIsTestEnv';+import { useSyncServerStatus } from '#hooks/useSyncServerStatus';++import { NavRow } from './NavRow';++export function PrimaryNav() {+ const { t } = useTranslation();+ const syncServerStatus = useSyncServerStatus();+ const isTestEnv = useIsTestEnv();+ const isUsingServer = syncServerStatus !== 'no-server' || isTestEnv;++ return (+ <View+ data-testid="sidebar-primary-buttons"+ style={{+ flexShrink: 0,+ padding: `${spacing.xs}px ${spacing.sm}px 0`,+ }}+ >+ <NavRow title={t('Budget')} Icon={SvgWallet} to="/budget" />+ <NavRow title={t('Reports')} Icon={SvgReports} to="/reports" />+ <NavRow title={t('Schedules')} Icon={SvgCalendar3} to="/schedules" />+ <NavRow title={t('Payees')} Icon={SvgUserGroup} to="/payees" />+ <NavRow title={t('Rules')} Icon={SvgTuning} to="/rules" />+ {isUsingServer && (+ <NavRow title={t('Bank Sync')} Icon={SvgLibrary} to="/bank-sync" />+ )}+ <NavRow title={t('Tags')} Icon={SvgTag} to="/tags" />+ </View>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/SidebarBudgetName.tsx b/packages/desktop-client/src/components/sidebar/redesign/SidebarBudgetName.tsxnew file mode 100644index 0000000000..421cb3e7ae--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/SidebarBudgetName.tsx@@ -0,0 +1,98 @@+import { useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { Button } from '@actual-app/components/button';+import { SvgCheveronDown } from '@actual-app/components/icons/v1';+import { InitialFocus } from '@actual-app/components/initial-focus';+import { Input } from '@actual-app/components/input';+import { styles } from '@actual-app/components/styles';+import { Text } from '@actual-app/components/text';+import { theme } from '@actual-app/components/theme';+import { spacing } from '@actual-app/components/tokens';+import { isElectron } from '@actual-app/core/shared/environment';++import { closeBudget } from '#budgetfiles/budgetfilesSlice';+import { useContextMenu } from '#hooks/useContextMenu';+import { useMetadataPref } from '#hooks/useMetadataPref';+import { useNavigate } from '#hooks/useNavigate';+import { pushModal } from '#modals/modalsSlice';+import { useDispatch } from '#redux';++export function SidebarBudgetName() {+ const { t } = useTranslation();+ const [budgetName, setBudgetNamePref] = useMetadataPref('budgetName');+ const dispatch = useDispatch();+ const navigate = useNavigate();+ const [isEditing, setIsEditing] = useState(false);+ const triggerRef = useRef<HTMLButtonElement>(null);+ const { handleContextMenu } = useContextMenu({+ triggerRef,+ items: [+ {+ name: 'rename',+ text: t('Rename budget'),+ onClick: () => setIsEditing(true),+ },+ {+ name: 'settings',+ text: t('Settings'),+ onClick: () => void navigate('/settings'),+ },+ isElectron() && {+ name: 'loadBackup',+ text: t('Load Backup…'),+ onClick: () =>+ dispatch(pushModal({ modal: { name: 'load-backup', options: {} } })),+ },+ {+ name: 'close',+ text: t('Switch file'),+ onClick: () => void dispatch(closeBudget()),+ },+ ],+ });++ if (isEditing) {+ return (+ <InitialFocus>+ <Input+ style={{ fontSize: 13, fontWeight: 600 }}+ defaultValue={budgetName}+ onEnter={newBudgetName => {+ if (newBudgetName.trim() !== '') {+ setBudgetNamePref(newBudgetName);+ setIsEditing(false);+ }+ }}+ onBlur={() => setIsEditing(false)}+ />+ </InitialFocus>+ );+ }++ return (+ <Button+ ref={triggerRef}+ data-testid="budget-name"+ variant="bare"+ style={{+ color: theme.sidebarHeaderText,+ backgroundColor: 'transparent',+ fontSize: 13,+ fontWeight: 600,+ gap: spacing.xs,+ padding: 0,+ justifyContent: 'flex-start',+ maxWidth: '100%',+ }}+ onClick={handleContextMenu}+ >+ <Text style={styles.ellipsisText}>{budgetName || t('Unnamed')}</Text>+ <SvgCheveronDown+ width={11}+ height={11}+ style={{ flexShrink: 0, color: theme.sidebarTextSubdued }}+ />+ </Button>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/SidebarFooter.tsx b/packages/desktop-client/src/components/sidebar/redesign/SidebarFooter.tsxnew file mode 100644index 0000000000..75f937cde9--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/SidebarFooter.tsx@@ -0,0 +1,24 @@+import { useTranslation } from 'react-i18next';++import { SvgCog } from '@actual-app/components/icons/v1';+import { theme } from '@actual-app/components/theme';+import { spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { NavRow } from './NavRow';++export function SidebarFooter() {+ const { t } = useTranslation();++ return (+ <View+ style={{+ flexShrink: 0,+ borderTop: `1px solid ${theme.sidebarBorder}`,+ padding: spacing.sm,+ }}+ >+ <NavRow title={t('Settings')} Icon={SvgCog} to="/settings" />+ </View>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/SidebarHeader.tsx b/packages/desktop-client/src/components/sidebar/redesign/SidebarHeader.tsxnew file mode 100644index 0000000000..3e1e20b6fb--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/SidebarHeader.tsx@@ -0,0 +1,47 @@+import type { ReactNode } from 'react';++import { SvgLogo } from '@actual-app/components/icons/logo';+import { theme } from '@actual-app/components/theme';+import { spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { hasMacOSWindowButtons } from '#components/sidebar/SidebarShell';++import { SidebarBudgetName } from './SidebarBudgetName';+import { SyncStatusLine } from './SyncStatusLine';++const MAC_WINDOW_BUTTONS_INSET = spacing.xl + spacing.md;++type SidebarHeaderProps = {+ children?: ReactNode;+};++export function SidebarHeader({ children }: SidebarHeaderProps) {+ return (+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ gap: spacing.sm,+ padding: `${spacing.md}px ${spacing.md}px ${spacing.sm}px`,+ paddingTop: hasMacOSWindowButtons()+ ? MAC_WINDOW_BUTTONS_INSET+ : spacing.md,+ borderBottom: `1px solid ${theme.sidebarBorder}`,+ userSelect: 'none',+ flexShrink: 0,+ }}+ >+ <SvgLogo+ width={28}+ height={28}+ style={{ flexShrink: 0, color: theme.sidebarBrand }}+ />+ <View style={{ minWidth: 0, flex: 1 }}>+ <SidebarBudgetName />+ <SyncStatusLine />+ </View>+ {children}+ </View>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/SidebarRedesign.tsx b/packages/desktop-client/src/components/sidebar/redesign/SidebarRedesign.tsxnew file mode 100644index 0000000000..be10f37e38--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/SidebarRedesign.tsx@@ -0,0 +1,84 @@+import { useTranslation } from 'react-i18next';++import { SvgAdd } from '@actual-app/components/icons/v1';+import { theme } from '@actual-app/components/theme';+import { spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { Accounts } from '#components/sidebar/Accounts';+import { SecondaryButtons } from '#components/sidebar/SecondaryButtons';+import { useSidebar } from '#components/sidebar/SidebarProvider';+import { SidebarShell } from '#components/sidebar/SidebarShell';+import { ToggleButton } from '#components/sidebar/ToggleButton';+import { useGlobalPref } from '#hooks/useGlobalPref';+import { replaceModal } from '#modals/modalsSlice';+import { useDispatch } from '#redux';++import { PrimaryNav } from './PrimaryNav';+import { SidebarFooter } from './SidebarFooter';+import { SidebarHeader } from './SidebarHeader';++const DEFAULT_SIDEBAR_WIDTH = 270;++export function SidebarRedesign() {+ const { t } = useTranslation();+ const dispatch = useDispatch();+ const sidebar = useSidebar();+ const [isFloating = false, setFloatingSidebarPref] =+ useGlobalPref('floatingSidebar');++ const onFloat = () => {+ setFloatingSidebarPref(!isFloating);+ };++ const onAddAccount = () => {+ dispatch(replaceModal({ modal: { name: 'add-account', options: {} } }));+ };++ return (+ <SidebarShell+ defaultWidth={DEFAULT_SIDEBAR_WIDTH}+ className="sidebar-redesign"+ >+ <View+ role="navigation"+ aria-label={t('Sidebar')}+ style={{ flex: 1, minHeight: 0 }}+ >+ <SidebarHeader>+ {!sidebar.alwaysFloats && (+ <ToggleButton isFloating={isFloating} onFloat={onFloat} />+ )}+ </SidebarHeader>++ <PrimaryNav />++ <View+ style={{+ height: 1,+ margin: `${spacing.sm}px ${spacing.md}px`,+ backgroundColor: theme.sidebarBorder,+ flexShrink: 0,+ }}+ />++ <View style={{ flexGrow: 1, overflowY: 'auto' }}>+ <Accounts />++ <SecondaryButtons+ buttons={[+ {+ title: t('Add account'),+ Icon: SvgAdd,+ onClick: onAddAccount,+ dataTestId: 'sidebar-add-account',+ },+ ]}+ />+ </View>++ <SidebarFooter />+ </View>+ </SidebarShell>+ );+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/SyncStatusLine.tsx b/packages/desktop-client/src/components/sidebar/redesign/SyncStatusLine.tsxnew file mode 100644index 0000000000..a3aa4b588c--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/redesign/SyncStatusLine.tsx@@ -0,0 +1,102 @@+import type { ComponentType, SVGProps } from 'react';+import { useTranslation } from 'react-i18next';++import {+ SvgCloudCheck,+ SvgCloudWarning,+} from '@actual-app/components/icons/v1';+import { SvgCloudUnknown } from '@actual-app/components/icons/v2';+import { styles } from '@actual-app/components/styles';+import { Text } from '@actual-app/components/text';+import { theme } from '@actual-app/components/theme';+import { spacing } from '@actual-app/components/tokens';+import { View } from '@actual-app/components/view';++import { useSyncServerStatus } from '#hooks/useSyncServerStatus';+import { useSyncStatus } from '#hooks/useSyncStatus';+import type { SyncState } from '#hooks/useSyncStatus';++type SyncPresentation = {+ Icon:+ | ComponentType<SVGProps<SVGElement>>+ | ComponentType<SVGProps<SVGSVGElement>>;+ color: string;+ label: string;+};++export function SyncStatusLine() {+ const { t } = useTranslation();+ const serverStatus = useSyncServerStatus();+ const { isSyncing, syncState } = useSyncStatus();++ const presentations: Record<+ 'no-server' | 'syncing' | 'synced' | Exclude<SyncState, null>,+ SyncPresentation+ > = {+ 'no-server': {+ Icon: SvgCloudUnknown,+ color: theme.sidebarTextSubdued,+ label: t('Local only'),+ },+ syncing: {+ Icon: SvgCloudCheck,+ color: theme.sidebarTextSubdued,+ label: t('Syncing…'),+ },+ error: {+ Icon: SvgCloudWarning,+ color: theme.sidebarTextFailed,+ label: t('Sync error'),+ },+ offline: {+ Icon: SvgCloudUnknown,+ color: theme.sidebarTextSubdued,+ label: t('Offline'),+ },+ local: {+ Icon: SvgCloudUnknown,+ color: theme.sidebarTextSubdued,+ label: t('Local file'),+ },+ disabled: {+ Icon: SvgCloudUnknown,+ color: theme.sidebarTextSubdued,+ label: t('Sync disabled'),+ },+ synced: {+ Icon: SvgCloudCheck,+ color: theme.sidebarTextPositive,+ label: t('Synced'),+ },+ };++ const statusKey =+ serverStatus === 'no-server'+ ? 'no-server'+ : isSyncing+ ? 'syncing'+ : (syncState ?? 'synced');+ const { Icon, color, label } = presentations[statusKey];++ return (+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ gap: spacing.xs,+ marginTop: 1,+ }}+ >+ <Icon width={10} height={10} style={{ flexShrink: 0, color }} />+ <Text+ style={{+ fontSize: 11,+ color: theme.sidebarTextSubdued,+ ...styles.ellipsisText,+ }}+ >+ {label}+ </Text>+ </View>+ );+}diff --git a/packages/desktop-client/src/hooks/useSyncStatus.ts b/packages/desktop-client/src/hooks/useSyncStatus.tsnew file mode 100644index 0000000000..e1919f17cd--- /dev/null+++ b/packages/desktop-client/src/hooks/useSyncStatus.ts@@ -0,0 +1,65 @@+import { useEffect, useState } from 'react';++import { listen } from '@actual-app/core/platform/client/connection';++import { useMetadataPref } from '#hooks/useMetadataPref';++export type SyncState = null | 'offline' | 'local' | 'disabled' | 'error';++type UseSyncStatusOpts = {+ syncingEndDelayMs?: number;+};++export function useSyncStatus({+ syncingEndDelayMs = 0,+}: UseSyncStatusOpts = {}): {+ isSyncing: boolean;+ syncState: SyncState;+} {+ const [cloudFileId] = useMetadataPref('cloudFileId');+ const [isSyncing, setIsSyncing] = useState(false);+ const [syncState, setSyncState] = useState<SyncState>(null);++ useEffect(() => {+ let endTimeout: ReturnType<typeof setTimeout> | null = null;++ const unlisten = listen('sync-event', event => {+ if (event.type === 'start') {+ if (endTimeout) {+ clearTimeout(endTimeout);+ endTimeout = null;+ }+ setIsSyncing(true);+ setSyncState(null);+ } else if (syncingEndDelayMs > 0) {+ endTimeout = setTimeout(() => {+ setIsSyncing(false);+ endTimeout = null;+ }, syncingEndDelayMs);+ } else {+ setIsSyncing(false);+ }++ if (event.type === 'error') {+ if (event.subtype === 'network') {+ setSyncState('offline');+ } else if (!cloudFileId) {+ setSyncState('local');+ } else {+ setSyncState('error');+ }+ } else if (event.type === 'success') {+ setSyncState(event.syncDisabled ? 'disabled' : null);+ }+ });++ return () => {+ if (endTimeout) {+ clearTimeout(endTimeout);+ }+ unlisten();+ };+ }, [cloudFileId, syncingEndDelayMs]);++ return { isSyncing, syncState };+}diff --git a/upcoming-release-notes/add-new-sidebar-shell.md b/upcoming-release-notes/add-new-sidebar-shell.mdnew file mode 100644index 0000000000..cddf0cc22d--- /dev/null+++ b/upcoming-release-notes/add-new-sidebar-shell.md@@ -0,0 +1,6 @@+---+category: Features+authors: [matt-fidd]+---++Add the experimental new sidebar shell with a redesigned header, navigation, and light theme support