From 27a31c7b68711de52cf5a8ffb0a480b1f37fe2bb Mon Sep 17 00:00:00 2001
From: Neil <55785687+carkom@users.noreply.github.com>
Date: Mon, 7 Aug 2023 19:04:33 +0100
Subject: [PATCH] Dark mode filters/rules/transactions (#1436)
---
.../src/components/ManageRules.js | 75 ++++----
.../src/components/common/Input.tsx | 5 +-
.../src/components/common/Menu.tsx | 20 +-
.../src/components/common/Modal.tsx | 13 +-
.../src/components/common/Select.tsx | 61 ++++++-
.../src/components/filters/FiltersMenu.js | 84 +++++----
.../src/components/filters/SavedFilters.js | 6 +-
.../desktop-client/src/components/forms.tsx | 24 +--
.../src/components/modals/EditRule.js | 56 +++---
.../select/RecurringSchedulePicker.js | 20 +-
.../desktop-client/src/components/sort.js | 4 +-
.../desktop-client/src/components/table.tsx | 171 ++++++++++--------
.../desktop-client/src/components/tooltips.js | 5 +-
.../transactions/SimpleTransactionsTable.js | 4 +-
.../transactions/TransactionList.js | 3 +-
.../transactions/TransactionsTable.js | 147 ++++++++-------
packages/desktop-client/src/style/styles.ts | 55 +++---
.../desktop-client/src/style/themes/dark.ts | 12 +-
.../desktop-client/src/style/themes/light.ts | 55 ++++--
upcoming-release-notes/1436.md | 5 +
20 files changed, 472 insertions(+), 353 deletions(-)
create mode 100644 upcoming-release-notes/1436.md
diff --git a/packages/desktop-client/src/components/ManageRules.js b/packages/desktop-client/src/components/ManageRules.js
index 2dc1b21da88..9b1f229908f 100644
--- a/packages/desktop-client/src/components/ManageRules.js
+++ b/packages/desktop-client/src/components/ManageRules.js
@@ -29,7 +29,7 @@ import useSelected, {
SelectedProvider,
} from '../hooks/useSelected';
import ArrowRight from '../icons/v0/RightArrow2';
-import { colors } from '../style';
+import { theme } from '../style';
import Button from './common/Button';
import ExternalLink from './common/ExternalLink';
@@ -40,6 +40,9 @@ import Text from './common/Text';
import View from './common/View';
import { SelectCell, Row, Field, Cell, CellButton, TableHeader } from './table';
+let valueStyle = {
+ color: theme.pageTextPositive,
+};
let SchedulesQuery = liveQueryContext(q('schedules').select('*'));
export function Value({
@@ -133,11 +136,11 @@ export function Value({
if (Array.isArray(value)) {
if (value.length === 0) {
- return (empty);
+ return (empty);
} else if (value.length === 1) {
return (
- [{formatValue(value[0])}]
+ [{formatValue(value[0])}]
);
}
@@ -148,10 +151,10 @@ export function Value({
}
let numHidden = value.length - displayed.length;
return (
-
+
[
{displayed.map((v, i) => {
- let text = {formatValue(v)};
+ let text = {formatValue(v)};
let spacing;
if (inline) {
spacing = i !== 0 ? ' ' : '';
@@ -174,9 +177,9 @@ export function Value({
);
})}
{numHidden > 0 && (
-
+
-
+
{numHidden} more items...
{!inline &&
}
@@ -189,12 +192,12 @@ export function Value({
// An "in between" type
return (
- {formatValue(value.num1)} and{' '}
- {formatValue(value.num2)}
+ {formatValue(value.num1)} and{' '}
+ {formatValue(value.num2)}
);
} else {
- return {formatValue(value)};
+ return {formatValue(value)};
}
}
@@ -213,7 +216,8 @@ function ConditionExpression({
{
display: 'block',
maxWidth: '100%',
- backgroundColor: colors.n10,
+ color: theme.altPillText,
+ backgroundColor: theme.altPillBackground,
borderRadius: 4,
padding: '3px 5px',
whiteSpace: 'nowrap',
@@ -223,9 +227,9 @@ function ConditionExpression({
style,
]}
>
- {prefix && {prefix} }
- {mapField(field, options)}{' '}
- {friendlyOp(op)}{' '}
+ {prefix && {prefix} }
+ {mapField(field, options)}{' '}
+ {friendlyOp(op)}{' '}
);
@@ -261,7 +265,8 @@ function ActionExpression({ field, op, value, options, style }) {
{
display: 'block',
maxWidth: '100%',
- backgroundColor: colors.n10,
+ color: theme.altPillText,
+ backgroundColor: theme.altPillBackground,
borderRadius: 4,
padding: '3px 5px',
whiteSpace: 'nowrap',
@@ -273,15 +278,14 @@ function ActionExpression({ field, op, value, options, style }) {
>
{op === 'set' ? (
<>
- {friendlyOp(op)}{' '}
- {mapField(field, options)}{' '}
- to
+ {friendlyOp(op)}{' '}
+ {mapField(field, options)}{' '}
+ to
>
) : op === 'link-schedule' ? (
<>
- {friendlyOp(op)}{' '}
-
+ {friendlyOp(op)}
>
) : null}
@@ -290,17 +294,22 @@ function ActionExpression({ field, op, value, options, style }) {
let Rule = memo(({ rule, hovered, selected, onHover, onEditRule }) => {
let dispatchSelected = useSelectedDispatch();
- let borderColor = selected ? colors.b8 : colors.border;
+ let borderColor = selected ? theme.tableBorderSelected : 'none';
let backgroundFocus = hovered;
return (
onHover && onHover(rule.id)}
onMouseLeave={() => onHover && onHover(null)}
@@ -314,14 +323,14 @@ let Rule = memo(({ rule, hovered, selected, onHover, onEditRule }) => {
selected={selected}
/>
-
+
{rule.stage && (
{
-
+
diff --git a/packages/desktop-client/src/components/common/Input.tsx b/packages/desktop-client/src/components/common/Input.tsx
index 2b09d772aa0..c55c6ac15ac 100644
--- a/packages/desktop-client/src/components/common/Input.tsx
+++ b/packages/desktop-client/src/components/common/Input.tsx
@@ -9,11 +9,12 @@ import { type HTMLPropsWithStyle } from '../../types/utils';
export const defaultInputStyle = {
outline: 0,
- backgroundColor: 'white',
+ backgroundColor: theme.tableBackground,
+ color: theme.formInputText,
margin: 0,
padding: 5,
borderRadius: 4,
- border: '1px solid #d0d0d0',
+ border: '1px solid ' + theme.formInputBorder,
};
type InputProps = HTMLPropsWithStyle & {
diff --git a/packages/desktop-client/src/components/common/Menu.tsx b/packages/desktop-client/src/components/common/Menu.tsx
index 59ad018bf64..06d7d472c82 100644
--- a/packages/desktop-client/src/components/common/Menu.tsx
+++ b/packages/desktop-client/src/components/common/Menu.tsx
@@ -6,7 +6,7 @@ import {
useState,
} from 'react';
-import { colors } from '../../style';
+import { theme } from '../../style';
import Text from './Text';
import View from './View';
@@ -16,7 +16,11 @@ type KeybindingProps = {
};
function Keybinding({ keyName }: KeybindingProps) {
- return {keyName};
+ return (
+
+ {keyName}
+
+ );
}
type MenuItem = {
@@ -106,7 +110,7 @@ export default function Menu({
if (item === Menu.line) {
return (
-
+
);
} else if (item.type === Menu.label) {
@@ -114,7 +118,7 @@ export default function Menu({
setHoveredIndex(idx)}
onMouseLeave={() => setHoveredIndex(null)}
diff --git a/packages/desktop-client/src/components/common/Modal.tsx b/packages/desktop-client/src/components/common/Modal.tsx
index 863c4208e9b..99515a20100 100644
--- a/packages/desktop-client/src/components/common/Modal.tsx
+++ b/packages/desktop-client/src/components/common/Modal.tsx
@@ -11,7 +11,7 @@ import hotkeys from 'hotkeys-js';
import AnimatedLoading from '../../icons/AnimatedLoading';
import Delete from '../../icons/v0/Delete';
-import { styles, colors } from '../../style';
+import { styles, theme } from '../../style';
import tokens from '../../tokens';
import Button from './Button';
@@ -124,7 +124,9 @@ const Modal = ({
minWidth: '100%',
minHeight: 0,
borderRadius: 4,
- backgroundColor: 'white',
+ //border: '1px solid ' + theme.modalBorder,
+ color: theme.pageText,
+ backgroundColor: theme.modalBackground,
opacity: isHidden ? 0 : 1,
[`@media (min-width: ${tokens.breakpoint_small})`]: {
minWidth: tokens.breakpoint_small,
@@ -146,7 +148,6 @@ const Modal = ({
{showTitle && (
-
+
)}
@@ -211,7 +212,7 @@ const Modal = ({
left: 0,
right: 0,
bottom: 0,
- backgroundColor: 'rgba(255, 255, 255, .6)',
+ backgroundColor: theme.pageBackground,
alignItems: 'center',
justifyContent: 'center',
zIndex: 1000,
@@ -219,7 +220,7 @@ const Modal = ({
>
)}
diff --git a/packages/desktop-client/src/components/common/Select.tsx b/packages/desktop-client/src/components/common/Select.tsx
index e3d57c91a26..fb1b984d066 100644
--- a/packages/desktop-client/src/components/common/Select.tsx
+++ b/packages/desktop-client/src/components/common/Select.tsx
@@ -8,9 +8,10 @@ import {
import { type CSSProperties, css } from 'glamor';
import ExpandArrow from '../../icons/v0/ExpandArrow';
-import { colors } from '../../style';
+import { theme, styles } from '../../style';
type SelectProps = {
+ bare?: boolean;
options: Array<[Value, string]>;
value: Value;
defaultLabel?: string;
@@ -37,6 +38,7 @@ type SelectProps = {
*/
export default function Select({
+ bare,
options,
value,
defaultLabel = '',
@@ -47,19 +49,38 @@ export default function Select({
disabledKeys = [],
}: SelectProps) {
const arrowSize = 7;
+ const checkHeight = !style
+ ? '18px'
+ : style.minHeight
+ ? style.minHeight
+ : !style[0]
+ ? '18px'
+ : style[0].minHeight ?? '18px';
const targetOption = options.filter(option => option[0] === value);
return (
}
+ {...css([{ borderWidth: 0, padding: 5, borderRadius: 4 }, style])}
+ arrow={
+
+ }
>
({
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
maxWidth: `calc(100% - ${arrowSize + 5}px)`,
- minHeight: '18px',
alignItems: 'center',
+ minHeight: checkHeight,
}}
>
{targetOption.length !== 0 ? targetOption[0][1] : defaultLabel}
-
+
{!line ? (
{options.map(([value, label]) => (
@@ -103,7 +144,7 @@ export default function Select({
style={{
padding: '2px',
marginTop: 5,
- borderTop: '1px solid ' + colors.n10,
+ borderTop: '1px solid ' + theme.menuBorder,
}}
/>
{options.slice(line, options.length).map(([value, label]) => (
diff --git a/packages/desktop-client/src/components/filters/FiltersMenu.js b/packages/desktop-client/src/components/filters/FiltersMenu.js
index 3397be89c2c..f503c1032f9 100644
--- a/packages/desktop-client/src/components/filters/FiltersMenu.js
+++ b/packages/desktop-client/src/components/filters/FiltersMenu.js
@@ -25,7 +25,7 @@ import { titleFirst } from 'loot-core/src/shared/util';
import DeleteIcon from '../../icons/v0/Delete';
import SettingsSliderAlternate from '../../icons/v2/SettingsSliderAlternate';
-import { colors } from '../../style';
+import { theme } from '../../style';
import Button from '../common/Button';
import Menu from '../common/Menu';
import Select from '../common/Select';
@@ -96,11 +96,14 @@ function OpButton({ op, selected, style, onClick }) {
| |