A local-first personal finance app
[AI] Add alternating colors to the TransactionsTable (#7841)
Mats Nilsson2eee23b2efb9
diff --git a/packages/component-library/src/theme.ts b/packages/component-library/src/theme.tsindex 98c00a74a6..1d8f831f5e 100644--- a/packages/component-library/src/theme.ts+++ b/packages/component-library/src/theme.ts@@ -36,6 +36,8 @@ export const theme = {tableRowBackgroundHighlight: 'var(--color-tableRowBackgroundHighlight)',tableRowBackgroundHighlightText:'var(--color-tableRowBackgroundHighlightText)',+ tableRowBackgroundAlternate:+ 'var(--color-tableRowBackgroundAlternate, var(--color-tableBackground))',tableRowHeaderBackground: 'var(--color-tableRowHeaderBackground)',tableRowHeaderText: 'var(--color-tableRowHeaderText)',sidebarBackground: 'var(--color-sidebarBackground)',diff --git a/packages/component-library/src/themes/dark.css b/packages/component-library/src/themes/dark.cssindex fde3be9a50..eb2eec4b23 100644--- a/packages/component-library/src/themes/dark.css+++ b/packages/component-library/src/themes/dark.css@@ -19,6 +19,7 @@--color-cardShadow: var(--palette-navy700);--color-tableBackground: var(--palette-navy800);+ --color-tableRowBackgroundAlternate: var(--color-tableBackground);--color-tableRowBackgroundHover: var(--palette-navy700);--color-tableText: var(--palette-navy150);--color-tableTextLight: var(--color-tableText);diff --git a/packages/component-library/src/themes/light.css b/packages/component-library/src/themes/light.cssindex 489aac2f21..4c640f1760 100644--- a/packages/component-library/src/themes/light.css+++ b/packages/component-library/src/themes/light.css@@ -19,6 +19,7 @@--color-cardShadow: var(--palette-navy700);--color-tableBackground: var(--palette-white);+ --color-tableRowBackgroundAlternate: var(--color-tableBackground);--color-tableRowBackgroundHover: var(--palette-navy50);--color-tableText: var(--color-pageText);--color-tableTextLight: var(--palette-navy400);diff --git a/packages/component-library/src/themes/midnight.css b/packages/component-library/src/themes/midnight.cssindex d4779528a0..0d757fb32d 100644--- a/packages/component-library/src/themes/midnight.css+++ b/packages/component-library/src/themes/midnight.css@@ -19,6 +19,7 @@--color-cardShadow: var(--palette-gray900);--color-tableBackground: var(--palette-gray800);+ --color-tableRowBackgroundAlternate: var(--color-tableBackground);--color-tableRowBackgroundHover: var(--palette-gray500);--color-tableText: var(--palette-gray150);--color-tableTextLight: var(--color-tableText);diff --git a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsxindex 4ed9b45b16..8d3422b309 100644--- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx+++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx@@ -913,10 +913,11 @@ export function ImportTransactionsModal({</View>);}}- renderItem={({ item }) => (+ renderItem={({ item, index }) => (<View><Transactiontransaction={item}+ index={index}showParsed={filetype === 'csv' || filetype === 'qif'}parseDateFormat={parseDateFormat}dateFormat={dateFormat}diff --git a/packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsxindex d1e341f775..c41d9d8670 100644--- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsx+++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.tsx@@ -32,6 +32,7 @@ type TransactionProps = {categories: CategoryEntity[];onCheckTransaction: (transactionId: string) => void;reconcile: boolean;+ index: number;};export function Transaction({@@ -48,6 +49,7 @@ export function Transaction({categories,onCheckTransaction,reconcile,+ index,}: TransactionProps) {const { t } = useTranslation();@@ -92,7 +94,10 @@ export function Transaction({return (<Rowstyle={{- backgroundColor: theme.tableBackground,+ backgroundColor:+ index % 2 === 0+ ? theme.tableBackground+ : theme.tableRowBackgroundAlternate,textDecoration: transaction.tombstone ? 'line-through' : 'none',color:(transaction.isMatchedTransaction && !transaction.selected_merge) ||diff --git a/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.tsx b/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.tsxindex 4b116d44ed..5a5649f195 100644--- a/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.tsx+++ b/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.tsx@@ -1,4 +1,4 @@-import React, { memo, useCallback, useMemo } from 'react';+import React, { useCallback, useMemo } from 'react';import type { CSSProperties, ReactNode } from 'react';import { Trans, useTranslation } from 'react-i18next';@@ -43,13 +43,15 @@ type TransactionRowProps = {fields: string[];selected: boolean;format: (value: unknown, type: FormatType) => string;+ index: number;};-const TransactionRow = memo(function TransactionRow({+function TransactionRow({transaction,fields,selected,format,+ index,}: TransactionRowProps) {const { t } = useTranslation();@@ -59,7 +61,16 @@ const TransactionRow = memo(function TransactionRow({const dispatchSelected = useSelectedDispatch();return (- <Row style={{ color: theme.tableText }}>+ <Row+ style={{+ color: theme.tableText,+ backgroundColor: selected+ ? theme.tableRowBackgroundHighlight+ : index % 2 === 0+ ? theme.tableBackground+ : theme.tableRowBackgroundAlternate,+ }}+ ><SelectCellexposedfocused={false}@@ -152,7 +163,7 @@ const TransactionRow = memo(function TransactionRow({})}</Row>);-});+}type SimpleTransactionsTableProps = {transactions: readonly TransactionEntity[];@@ -178,13 +189,14 @@ export function SimpleTransactionsTable({}, [transactions, dateFormat]);const renderItem = useCallback(- ({ item }: { item: TransactionEntity }) => {+ ({ item, index }: { item: TransactionEntity; index: number }) => {return (<TransactionRowtransaction={item}fields={memoFields}selected={selectedItems && selectedItems.has(item.id)}format={format}+ index={index}/>);},diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.tsxindex c2048ea5ff..f984362b86 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx@@ -908,6 +908,7 @@ type TransactionProps = {ascDesc?: 'asc' | 'desc';onDragChange?: OnDragChangeCallback<TransactionEntity>;onDrop?: OnDropCallback;+ index: number;};const Transaction = memo(function Transaction({@@ -966,6 +967,7 @@ const Transaction = memo(function Transaction({ascDesc,onDragChange,onDrop,+ index,}: TransactionProps) {const { t } = useTranslation();@@ -1335,7 +1337,9 @@ const Transaction = memo(function Transaction({? theme.tableRowBackgroundHighlight: backgroundFocus? theme.tableRowBackgroundHover- : theme.tableBackground,+ : index % 2 === 0+ ? theme.tableBackground+ : theme.tableRowBackgroundAlternate,':hover': !(backgroundFocus || selected) && {backgroundColor: theme.tableRowBackgroundHover,},@@ -2183,9 +2187,10 @@ function NewTransaction({}}}>- {transactions.map(transaction => (+ {transactions.map((transaction, index) => (<Transactionkey={transaction.id}+ index={index}editing={editingTransaction === transaction.id}transaction={transaction}subtransactions={transaction.is_parent ? childTransactions : null}@@ -2556,6 +2561,7 @@ function TransactionTableInner({ascDesc={props.ascDesc}onDragChange={props.onDragChange}onDrop={props.onDrop}+ index={index}/>);};diff --git a/upcoming-release-notes/7841.md b/upcoming-release-notes/7841.mdnew file mode 100644index 0000000000..24c8b79e29--- /dev/null+++ b/upcoming-release-notes/7841.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [mnil]+---++Add alternating row colors for the transaction table.