Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sidebar - Expanding Button Section #3621

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3c4e687
Initial Commit
tlesicka Oct 9, 2024
e3e3579
Update e2e Test for Settings Page
tlesicka Oct 10, 2024
940cca7
Update VRTs
tlesicka Oct 10, 2024
10f0bf5
Update VRTs
tlesicka Oct 10, 2024
e4eb9e3
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 10, 2024
bac508f
Create 3621.md
tlesicka Oct 10, 2024
590b246
Updated as recommeded by coderabbitai
tlesicka Oct 10, 2024
0471661
Merge branch 'update-sidebar-expanding-button-section' of https://git…
tlesicka Oct 10, 2024
daa4767
Updated as recommended by coderabbitai
tlesicka Oct 10, 2024
826a0e7
Update VRTs
tlesicka Oct 10, 2024
01db5ea
Fix Lint Error
tlesicka Oct 10, 2024
46d29fd
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 11, 2024
dcfa9e8
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 11, 2024
9be3b22
Update VRTs
tlesicka Oct 11, 2024
0a3544b
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 13, 2024
983cede
Update VRTs
tlesicka Oct 13, 2024
e9421cb
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 14, 2024
8132d4c
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 14, 2024
c86a559
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 15, 2024
fe208e6
Update VRTs
tlesicka Oct 15, 2024
82a3969
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 17, 2024
eb7df84
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 17, 2024
f496b4f
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 20, 2024
4bc5f84
Update VRTs
tlesicka Oct 20, 2024
763b03c
Merge remote-tracking branch 'upstream/master' into update-sidebar-ex…
tlesicka Oct 23, 2024
2093d29
Update VRTs
tlesicka Oct 23, 2024
308a9d1
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 24, 2024
def6214
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 24, 2024
99501f9
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 24, 2024
3ba9663
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 25, 2024
15497bb
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 25, 2024
d36ec21
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 26, 2024
fa37247
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 27, 2024
02510af
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 27, 2024
f1759e6
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 28, 2024
10ca252
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 29, 2024
1bae6a8
Merge branch 'actualbudget:master' into update-sidebar-expanding-butt…
tlesicka Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/desktop-client/e2e/page-models/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export class Navigation {
}

async goToSettingsPage() {
const settingsLink = this.page.getByRole('link', { name: 'Settings' });
const settingsLink = this.page.getByRole('button', { name: 'Settings' });

// Expand the "more" menu only if it is not already expanded
// Expand the menu only if it is not already expanded
if (!(await settingsLink.isVisible())) {
await this.page.getByRole('button', { name: 'More' }).click();
await this.page.getByRole('button', { name: 'Test Budget' }).click();
}

await settingsLink.click();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 73 additions & 51 deletions packages/desktop-client/src/components/sidebar/PrimaryButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,94 @@
import React, { useState, useCallback, useEffect } from 'react';
import React, {
useEffect,
useRef,
type ComponentType,
type SVGProps,
} from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';

import {
SvgCheveronDown,
SvgCheveronRight,
SvgCog,
SvgReports,
SvgStoreFront,
SvgTuning,
SvgWallet,
} from '../../icons/v1';
import { SvgCalendar } from '../../icons/v2';
import { useLocalPref } from '../../hooks/useLocalPref';
import { SvgCheveronDown, SvgCheveronUp } from '../../icons/v1';
import { styles } from '../../style';
tlesicka marked this conversation as resolved.
Show resolved Hide resolved
import { View } from '../common/View';

import { Item } from './Item';
import { SecondaryItem } from './SecondaryItem';

export function PrimaryButtons() {
type PrimaryButtonItems = {
title: string;
Icon: ComponentType<SVGProps<SVGSVGElement>>;
to: string;
hidable?: boolean;
};

type PrimaryButtonsProps = {
collapseSpeed?: number;
buttons: Array<PrimaryButtonItems>;
};

export function PrimaryButtons({
collapseSpeed = 0.15,
buttons,
}: PrimaryButtonsProps) {
const { t } = useTranslation();
const [isOpen, setOpen] = useState(false);
const onToggle = useCallback(() => setOpen(open => !open), []);
const divRef = useRef<HTMLDivElement>(null);
const itemsRef = useRef<HTMLDivElement>(null);
const location = useLocation();

const isActive = ['/payees', '/rules', '/settings', '/tools'].some(route =>
location.pathname.startsWith(route),
const [expanded, setExpandedActionButtonsPref] = useLocalPref(
'ui.expandPrimaryButtons',
);

const onToggle = () => {
setExpandedActionButtonsPref(!expanded);
};

useEffect(() => {
if (isActive) {
setOpen(true);
if (divRef?.current && itemsRef?.current) {
divRef.current.style.height = itemsRef.current.scrollHeight + 'px';
}
}, [isActive, location.pathname]);
}, [expanded, location.pathname]);

tlesicka marked this conversation as resolved.
Show resolved Hide resolved
return (
<View style={{ flexShrink: 0 }}>
<Item title={t('Budget')} Icon={SvgWallet} to="/budget" />
<Item title={t('Reports')} Icon={SvgReports} to="/reports" />
<Item title={t('Schedules')} Icon={SvgCalendar} to="/schedules" />
<Item
title="More"
Icon={isOpen ? SvgCheveronDown : SvgCheveronRight}
<View style={{ padding: '5px 0', flexShrink: 0 }}>
<View
ref={divRef}
style={{
overflow: 'hidden',
transition: 'height ' + collapseSpeed + 's ease-in-out',
}}
aria-expanded={expanded}
>
<View
ref={itemsRef}
style={{
flexShrink: 0,
height: 'auto',
}}
>
{buttons.map(item => {
const isActive = location.pathname.startsWith(item.to);
const shouldHide = item.hidable && !expanded && !isActive;
return (
<Item
key={item.title}
title={item.title}
Icon={item.Icon}
to={item.to}
style={{
...(shouldHide && { display: 'none' }),
}}
/>
);
})}
</View>
</View>
<SecondaryItem
title={expanded ? t('Less') : t('More')}
Icon={expanded ? SvgCheveronUp : SvgCheveronDown}
onClick={onToggle}
style={{ marginBottom: isOpen ? 8 : 0 }}
forceActive={!isOpen && isActive}
style={{ ...styles.verySmallText }}
/>
{isOpen && (
<>
<SecondaryItem
title={t('Payees')}
Icon={SvgStoreFront}
to="/payees"
indent={15}
/>
<SecondaryItem
title={t('Rules')}
Icon={SvgTuning}
to="/rules"
indent={15}
/>
<SecondaryItem
title={t('Settings')}
Icon={SvgCog}
to="/settings"
indent={15}
/>
</>
)}
</View>
);
}
21 changes: 19 additions & 2 deletions packages/desktop-client/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
import { useNavigate } from '../../hooks/useNavigate';
import { useResizeObserver } from '../../hooks/useResizeObserver';
import { SvgExpandArrow } from '../../icons/v0';
import { SvgAdd } from '../../icons/v1';
import {
SvgAdd,
SvgReports,
SvgStoreFront,
SvgTuning,
SvgWallet,
} from '../../icons/v1';
import { SvgCalendar } from '../../icons/v2';
import { useResponsive } from '../../ResponsiveProvider';
import { styles, theme } from '../../style';
import { Button } from '../common/Button2';
Expand Down Expand Up @@ -72,6 +79,14 @@
setSidebarWidth(rect.width);
});

const primaryButtonConfigs = [
{ title: t('Budget'), Icon: SvgWallet, to: '/budget' },
{ title: t('Reports'), Icon: SvgReports, to: '/reports' },
{ title: t('Schedules'), Icon: SvgCalendar, to: '/schedules' },
{ title: t('Payees'), Icon: SvgStoreFront, to: '/payees', hidable: true },
{ title: t('Rules'), Icon: SvgTuning, to: '/rules', hidable: true },
];

return (
<Resizable
defaultSize={{
Expand Down Expand Up @@ -142,7 +157,9 @@
},
}}
>
<PrimaryButtons />
<PrimaryButtons

Check warning on line 160 in packages/desktop-client/src/components/sidebar/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎············buttons={primaryButtonConfigs}⏎·········` with `·buttons={primaryButtonConfigs}`
buttons={primaryButtonConfigs}
/>

<Accounts />

Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type MetadataPrefs = Partial<{
*/
export type LocalPrefs = Partial<{
'ui.showClosedAccounts': boolean;
'ui.expandPrimaryButtons': boolean;
'expand-splits': boolean;
'budget.collapsed': string[];
'budget.summaryCollapsed': boolean;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3621.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [tlesicka]
---

Update Sidebar Primary Buttons group. All buttons in the same flow and are not broken with "More" in the middle.
Loading