A local-first personal finance app
Highlight current month in budgets. (#3111)
Robert Dyerfe922ec22e4b
diff --git a/packages/desktop-client/src/components/budget/MonthPicker.tsx b/packages/desktop-client/src/components/budget/MonthPicker.tsxindex 160bcd9a6f..501bafd79f 100644--- a/packages/desktop-client/src/components/budget/MonthPicker.tsx+++ b/packages/desktop-client/src/components/budget/MonthPicker.tsx@@ -133,6 +133,17 @@ export const MonthPicker = ({!selected && {backgroundColor: theme.buttonBareBackgroundHover,}),+ ...(!hovered &&+ !selected &&+ current && {+ backgroundColor: theme.buttonBareBackgroundHover,+ filter: 'brightness(120%)',+ }),+ ...(hovered &&+ selected &&+ current && {+ filter: 'brightness(120%)',+ }),...(hovered &&selected && {backgroundColor: theme.tableBorderHover,diff --git a/packages/desktop-client/src/components/budget/report/ReportComponents.tsx b/packages/desktop-client/src/components/budget/report/ReportComponents.tsxindex 02c49d3155..b0f2345343 100644--- a/packages/desktop-client/src/components/budget/report/ReportComponents.tsx+++ b/packages/desktop-client/src/components/budget/report/ReportComponents.tsx@@ -3,6 +3,7 @@ import React, { memo, useRef, useState } from 'react';import { reportBudget } from 'loot-core/src/client/queries';import { evalArithmetic } from 'loot-core/src/shared/arithmetic';+import * as monthUtils from 'loot-core/src/shared/months';import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';import { SvgCheveronDown } from '../../../icons/v1';@@ -88,13 +89,25 @@ export function IncomeHeaderMonth() {}type GroupMonthProps = {+ month: string;group: { id: string; is_income: boolean };};-export const GroupMonth = memo(function GroupMonth({ group }: GroupMonthProps) {+export const GroupMonth = memo(function GroupMonth({+ month,+ group,+}: GroupMonthProps) {const { id } = group;return (- <View style={{ flex: 1, flexDirection: 'row' }}>+ <View+ style={{+ flex: 1,+ flexDirection: 'row',+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetHeaderCurrentMonth+ : theme.budgetHeaderOtherMonth,+ }}+ ><SheetCellname="budgeted"width="flex"@@ -174,6 +187,9 @@ export const CategoryMonth = memo(function CategoryMonth({style={{flex: 1,flexDirection: 'row',+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetCurrentMonth+ : theme.budgetOtherMonth,'& .hover-visible': {opacity: 0,transition: 'opacity .25s',diff --git a/packages/desktop-client/src/components/budget/report/budgetsummary/BudgetSummary.tsx b/packages/desktop-client/src/components/budget/report/budgetsummary/BudgetSummary.tsxindex 6f524a60e6..282db62978 100644--- a/packages/desktop-client/src/components/budget/report/budgetsummary/BudgetSummary.tsx+++ b/packages/desktop-client/src/components/budget/report/budgetsummary/BudgetSummary.tsx@@ -50,7 +50,10 @@ export function BudgetSummary({ month }: BudgetSummaryProps) {return (<Viewstyle={{- backgroundColor: theme.tableBackground,+ backgroundColor:+ month === currentMonth+ ? theme.budgetCurrentMonth+ : theme.budgetOtherMonth,boxShadow: styles.cardShadow,borderRadius: 6,marginLeft: 0,diff --git a/packages/desktop-client/src/components/budget/rollover/RolloverComponents.tsx b/packages/desktop-client/src/components/budget/rollover/RolloverComponents.tsxindex 49aa030549..9b7ccc9b10 100644--- a/packages/desktop-client/src/components/budget/rollover/RolloverComponents.tsx+++ b/packages/desktop-client/src/components/budget/rollover/RolloverComponents.tsx@@ -3,6 +3,7 @@ import { memo, useRef, useState } from 'react';import { rolloverBudget } from 'loot-core/src/client/queries';import { evalArithmetic } from 'loot-core/src/shared/arithmetic';+import * as monthUtils from 'loot-core/src/shared/months';import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';import { SvgCheveronDown } from '../../../icons/v1';@@ -113,15 +114,25 @@ export function IncomeHeaderMonth() {}type ExpenseGroupMonthProps = {+ month: string;group: { id: string };};export const ExpenseGroupMonth = memo(function ExpenseGroupMonth({+ month,group,}: ExpenseGroupMonthProps) {const { id } = group;return (- <View style={{ flex: 1, flexDirection: 'row' }}>+ <View+ style={{+ flex: 1,+ flexDirection: 'row',+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetHeaderCurrentMonth+ : theme.budgetHeaderOtherMonth,+ }}+ ><RolloverSheetCellname="budgeted"width="flex"@@ -197,6 +208,9 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({style={{flex: 1,flexDirection: 'row',+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetCurrentMonth+ : theme.budgetOtherMonth,'& .hover-visible': {opacity: 0,transition: 'opacity .25s',@@ -379,7 +393,10 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({);});-export function IncomeGroupMonth() {+type IncomeGroupMonthProps = {+ month: string;+};+export function IncomeGroupMonth({ month }: IncomeGroupMonthProps) {return (<View style={{ flex: 1 }}><RolloverSheetCell@@ -390,6 +407,9 @@ export function IncomeGroupMonth() {fontWeight: 600,paddingRight: styles.monthRightPadding,...styles.tnum,+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetHeaderCurrentMonth+ : theme.budgetHeaderOtherMonth,}}valueProps={{binding: rolloverBudget.groupIncomeReceived,@@ -426,6 +446,9 @@ export function IncomeCategoryMonth({paddingRight: styles.monthRightPadding,textAlign: 'right',...(isLast && { borderBottomWidth: 0 }),+ backgroundColor: monthUtils.isCurrentMonth(month)+ ? theme.budgetCurrentMonth+ : theme.budgetOtherMonth,}}><span onClick={() => onShowActivity(category.id, month)}>diff --git a/packages/desktop-client/src/components/budget/rollover/budgetsummary/BudgetSummary.tsx b/packages/desktop-client/src/components/budget/rollover/budgetsummary/BudgetSummary.tsxindex 0ce4d5c887..746f00c395 100644--- a/packages/desktop-client/src/components/budget/rollover/budgetsummary/BudgetSummary.tsx+++ b/packages/desktop-client/src/components/budget/rollover/budgetsummary/BudgetSummary.tsx@@ -51,7 +51,10 @@ export function BudgetSummary({ month }: BudgetSummaryProps) {<Viewdata-testid="budget-summary"style={{- backgroundColor: theme.tableBackground,+ backgroundColor:+ month === currentMonth+ ? theme.budgetCurrentMonth+ : theme.budgetOtherMonth,boxShadow: styles.cardShadow,borderRadius: 6,marginLeft: 0,diff --git a/packages/desktop-client/src/style/palette.ts b/packages/desktop-client/src/style/palette.tsindex fa8bbe7f22..3e2cf47883 100644--- a/packages/desktop-client/src/style/palette.ts+++ b/packages/desktop-client/src/style/palette.ts@@ -2,6 +2,7 @@ import * as oldColors from './colors';// Only for use in contextual color definitionsexport const gray50 = '#f6f8fa';+export const gray80 = '#f0f4f6';export const gray100 = '#e8ecf0';export const gray150 = '#d4dae0';export const gray200 = '#bdc5cf';diff --git a/packages/desktop-client/src/style/themes/dark.ts b/packages/desktop-client/src/style/themes/dark.tsindex 3385e100a4..722d886ab8 100644--- a/packages/desktop-client/src/style/themes/dark.ts+++ b/packages/desktop-client/src/style/themes/dark.ts@@ -196,3 +196,8 @@ export const reportsInnerLabel = colorPalette.navy800;export const noteTagBackground = colorPalette.purple700;export const noteTagBackgroundHover = colorPalette.purple500;export const noteTagText = colorPalette.purple100;++export const budgetOtherMonth = colorPalette.navy900;+export const budgetCurrentMonth = tableBackground;+export const budgetHeaderOtherMonth = colorPalette.navy800;+export const budgetHeaderCurrentMonth = tableHeaderBackground;diff --git a/packages/desktop-client/src/style/themes/development.ts b/packages/desktop-client/src/style/themes/development.tsindex 3d73f670b6..8a1a1f955d 100644--- a/packages/desktop-client/src/style/themes/development.ts+++ b/packages/desktop-client/src/style/themes/development.ts@@ -195,3 +195,8 @@ export const reportsInnerLabel = colorPalette.navy800;export const noteTagBackground = colorPalette.purple100;export const noteTagBackgroundHover = colorPalette.purple150;export const noteTagText = colorPalette.purple700;++export const budgetCurrentMonth = tableBackground;+export const budgetOtherMonth = colorPalette.gray50;+export const budgetHeaderCurrentMonth = budgetOtherMonth;+export const budgetHeaderOtherMonth = colorPalette.gray80;diff --git a/packages/desktop-client/src/style/themes/light.ts b/packages/desktop-client/src/style/themes/light.tsindex ad8318f869..e5ce2e1db1 100644--- a/packages/desktop-client/src/style/themes/light.ts+++ b/packages/desktop-client/src/style/themes/light.ts@@ -198,3 +198,8 @@ export const reportsInnerLabel = colorPalette.navy800;export const noteTagBackground = colorPalette.purple100;export const noteTagBackgroundHover = colorPalette.purple150;export const noteTagText = colorPalette.purple700;++export const budgetCurrentMonth = tableBackground;+export const budgetOtherMonth = colorPalette.gray50;+export const budgetHeaderCurrentMonth = budgetOtherMonth;+export const budgetHeaderOtherMonth = colorPalette.gray80;diff --git a/packages/desktop-client/src/style/themes/midnight.ts b/packages/desktop-client/src/style/themes/midnight.tsindex 4ee7055588..f19701e6db 100644--- a/packages/desktop-client/src/style/themes/midnight.ts+++ b/packages/desktop-client/src/style/themes/midnight.ts@@ -198,3 +198,8 @@ export const reportsInnerLabel = colorPalette.navy800;export const noteTagBackground = colorPalette.purple800;export const noteTagBackgroundHover = colorPalette.purple600;export const noteTagText = colorPalette.purple100;++export const budgetOtherMonth = colorPalette.gray700;+export const budgetCurrentMonth = tableBackground;+export const budgetHeaderOtherMonth = colorPalette.gray800;+export const budgetHeaderCurrentMonth = tableHeaderBackground;diff --git a/packages/loot-core/src/shared/months.ts b/packages/loot-core/src/shared/months.tsindex 89aee77ea0..1ebbb97599 100644--- a/packages/loot-core/src/shared/months.ts+++ b/packages/loot-core/src/shared/months.ts@@ -216,6 +216,10 @@ export function isAfter(month1: DateLike, month2: DateLike): boolean {return d.isAfter(_parse(month1), _parse(month2));}+export function isCurrentMonth(month: DateLike): boolean {+ return month === currentMonth();+}+// TODO: This doesn't really fit in this module anymore, should// probably live elsewhereexport function bounds(month: DateLike): { start: number; end: number } {diff --git a/upcoming-release-notes/3111.md b/upcoming-release-notes/3111.mdnew file mode 100644index 0000000000..5faa6916c2--- /dev/null+++ b/upcoming-release-notes/3111.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [psybers]+---++Highlight current month in budgets.