diff --git a/packages/desktop-client/src/components/common/Menu.tsx b/packages/desktop-client/src/components/common/Menu.tsx index 27c428aa339..57dd789ab5e 100644 --- a/packages/desktop-client/src/components/common/Menu.tsx +++ b/packages/desktop-client/src/components/common/Menu.tsx @@ -10,6 +10,7 @@ import { import { type CSSProperties, theme } from '../../style'; import { Text } from './Text'; +import { Toggle } from './Toggle'; import { View } from './View'; type KeybindingProps = { @@ -33,6 +34,8 @@ type MenuItem = { text: string; key?: string; style?: CSSProperties; + toggle?: boolean; + tooltip?: string; }; type MenuProps = { @@ -164,23 +167,48 @@ export function Menu({ onMouseEnter={() => setHoveredIndex(idx)} onMouseLeave={() => setHoveredIndex(null)} onClick={() => - !item.disabled && onMenuSelect && onMenuSelect(item.name) + !item.disabled && + onMenuSelect && + item.toggle === undefined && + onMenuSelect(item.name) } > {/* Force it to line up evenly */} - - {item.icon && - createElement(item.icon, { - width: item.iconSize || 10, - height: item.iconSize || 10, - style: { - marginRight: 7, - width: item.iconSize || 10, - }, - })} - - {item.text} - + {item.toggle === undefined ? ( + <> + + {item.icon && + createElement(item.icon, { + width: item.iconSize || 10, + height: item.iconSize || 10, + style: { + marginRight: 7, + width: item.iconSize || 10, + }, + })} + + {item.text} + + + ) : ( + <> + + + + !item.disabled && + item.toggle !== undefined && + onMenuSelect(item.name) + } + /> + + )} {item.key && } ); diff --git a/packages/desktop-client/src/components/common/Toggle.tsx b/packages/desktop-client/src/components/common/Toggle.tsx new file mode 100644 index 00000000000..1bf72175e8d --- /dev/null +++ b/packages/desktop-client/src/components/common/Toggle.tsx @@ -0,0 +1,75 @@ +import React from 'react'; + +import { css } from 'glamor'; + +import { theme, type CSSProperties } from '../../style'; + +type ToggleProps = { + id: string; + checked: boolean; + onToggle?: () => void; + onColor?: string; + style?: CSSProperties; +}; + +export const Toggle = ({ + id, + checked, + onToggle, + onColor, + style, +}: ToggleProps) => { + return ( +
+ + +
+ ); +}; diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx index dc2fdd24768..9d0fffd3582 100644 --- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx +++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx @@ -1,12 +1,14 @@ -import React from 'react'; +import React, { useState } from 'react'; import * as monthUtils from 'loot-core/src/shared/months'; import { theme } from '../../style'; +import { Button } from '../common/Button'; +import { Menu } from '../common/Menu'; import { Select } from '../common/Select'; import { Text } from '../common/Text'; import { View } from '../common/View'; -import { Checkbox } from '../forms'; +import { Tooltip } from '../tooltips'; import { CategorySelector } from './CategorySelector'; import { @@ -39,6 +41,7 @@ export function ReportSidebar({ onChangeDates, onChangeViews, }) { + const [menuOpen, setMenuOpen] = useState(false); const onSelectRange = cond => { setDateRange(cond); switch (cond) { @@ -242,70 +245,62 @@ export function ReportSidebar({ }} > - - setShowEmpty(!customReportItems.showEmpty)} - /> - -
- - - - - setShowOffBudgetHidden(!customReportItems.showOffBudgetHidden) - } - /> - - - - - - - setShowUncategorized(!customReportItems.showUncategorized) - } - /> - + Options + {menuOpen && ( + { + setMenuOpen(false); + }} + > + { + if (type === 'show-hidden-categories') { + setShowOffBudgetHidden( + !customReportItems.showOffBudgetHidden, + ); + } else if (type === 'show-empty-rows') { + setShowEmpty(!customReportItems.showEmpty); + } else if (type === 'show-uncategorized') { + setShowUncategorized( + !customReportItems.showUncategorized, + ); + } + }} + items={[ + { + name: 'show-empty-rows', + text: 'Show Empty Rows', + tooltip: 'Show rows that are zero or blank', + toggle: customReportItems.showEmpty, + }, + { + name: 'show-hidden-categories', + text: 'Show Off Budget', + tooltip: 'Show off budget accounts and hidden categories', + toggle: customReportItems.showOffBudgetHidden, + }, + { + name: 'show-uncategorized', + text: 'Show Uncategorized', + tooltip: 'Show uncategorized transactions', + toggle: customReportItems.showUncategorized, + }, + ]} + /> + + )} + values > value).arr; + source = variableLookup.find(({ value }) => values >= value).arr; break; case 'donut': source = donutLookup; diff --git a/packages/desktop-client/src/style/themes/dark.ts b/packages/desktop-client/src/style/themes/dark.ts index 39f2aac8efd..2185558d59e 100644 --- a/packages/desktop-client/src/style/themes/dark.ts +++ b/packages/desktop-client/src/style/themes/dark.ts @@ -174,6 +174,7 @@ export const checkboxText = tableText; export const checkboxBackgroundSelected = colorPalette.purple300; export const checkboxBorderSelected = colorPalette.purple300; export const checkboxShadowSelected = colorPalette.purple500; +export const checkboxToggleBackground = colorPalette.gray700; export const pillBackground = colorPalette.navy800; export const pillBackgroundLight = colorPalette.navy900; diff --git a/packages/desktop-client/src/style/themes/light.ts b/packages/desktop-client/src/style/themes/light.ts index a891743253c..1149fed337d 100644 --- a/packages/desktop-client/src/style/themes/light.ts +++ b/packages/desktop-client/src/style/themes/light.ts @@ -174,6 +174,7 @@ export const checkboxText = tableBackground; export const checkboxBackgroundSelected = colorPalette.blue500; export const checkboxBorderSelected = colorPalette.blue500; export const checkboxShadowSelected = colorPalette.blue300; +export const checkboxToggleBackground = colorPalette.gray400; export const pillBackground = colorPalette.navy150; export const pillBackgroundLight = colorPalette.navy100; diff --git a/upcoming-release-notes/2174.md b/upcoming-release-notes/2174.md new file mode 100644 index 00000000000..de09420e2d3 --- /dev/null +++ b/upcoming-release-notes/2174.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [carkom] +--- + +Hide "show ..." checkboxes within menu for custom reports page. Introduce toggle switches.