From f6be0c8439daf5aeb74349abeb19465d3f30f282 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Wed, 2 Sep 2026 22:58:44 +0200 Subject: [PATCH] fix(purchase): one control language in the purchase dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adopts NativeSelect for the three date/post/currency selects and the split editor's post picker, and Segmented for the one/many and percentages/amounts switches. The currency select now matches the Total input beside it exactly: same height, radius, border and text indent. The rest is hit areas and edges: - "set exact date" / "use the month only" were bare buttons with no padding at all — a 15px target under a 36px field, unhittable on a phone. Now a 24px box, with a negative margin so the text still lines up with the field's left edge. - The split row's `remove` and the plan's `remove plan` ran past the dialog's right padding; both now end on it. - The bulk-entry remove was a `×` glyph in a 20px box. It uses lucide's X, the icon family the dialog's own close button already uses. - The split editor's post select gains `min-w-0` via NativeSelect, so `flex-1` can shrink below the widest option — the actual cause of the dialog padding bug fixed in the previous commit. - The "rounding" radio label gets a real vertical hit area. Co-Authored-By: Claude Opus 5 (1M context) --- src/ui/components/BulkLines.tsx | 15 +++-- src/ui/components/PlanEditor.tsx | 4 +- src/ui/components/PurchaseDialog.tsx | 86 +++++++++++++++++----------- src/ui/components/SplitEditor.tsx | 42 ++++++++------ 4 files changed, 89 insertions(+), 58 deletions(-) diff --git a/src/ui/components/BulkLines.tsx b/src/ui/components/BulkLines.tsx index 66098a8..8a18b02 100644 --- a/src/ui/components/BulkLines.tsx +++ b/src/ui/components/BulkLines.tsx @@ -1,6 +1,8 @@ import { useRef } from "react"; +import { XIcon } from "lucide-react"; import { useDataset } from "../hooks/useDataset.ts"; import { digitsFor } from "../../domain/currencies.ts"; +import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { formatMoney } from "../format.ts"; @@ -113,15 +115,20 @@ export function BulkLines({ draft, onChange }: Props) { }} /> - + + ))} diff --git a/src/ui/components/PlanEditor.tsx b/src/ui/components/PlanEditor.tsx index 107f09b..2753c3e 100644 --- a/src/ui/components/PlanEditor.tsx +++ b/src/ui/components/PlanEditor.tsx @@ -61,7 +61,7 @@ export function PlanEditor({ draft, onChange }: Props) { } return ( -
+
@@ -79,7 +79,7 @@ export function PlanEditor({ draft, onChange }: Props) { } }} /> -
diff --git a/src/ui/components/PurchaseDialog.tsx b/src/ui/components/PurchaseDialog.tsx index dd47c43..d924217 100644 --- a/src/ui/components/PurchaseDialog.tsx +++ b/src/ui/components/PurchaseDialog.tsx @@ -9,7 +9,9 @@ import { } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import { NativeSelect } from "@/components/ui/native-select"; import { Label } from "@/components/ui/label"; +import { Segmented } from "./Segmented.tsx"; import { SplitEditor } from "./SplitEditor.tsx"; import { PlanEditor } from "./PlanEditor.tsx"; import { BulkLines } from "./BulkLines.tsx"; @@ -108,19 +110,15 @@ export function PurchaseDialog({ monthId, purchase, trigger }: Props) { {!purchase && ( -
- {(["one", "many"] as const).map((option) => ( - - ))} -
+ )}
@@ -142,9 +140,7 @@ export function PurchaseDialog({ monthId, purchase, trigger }: Props) { setBulk((b) => ({ ...b, date })); }} /> - +
- +
- +
@@ -220,24 +214,20 @@ export function PurchaseDialog({ monthId, purchase, trigger }: Props) { setDraft((d) => ({ ...d, date })); }} /> - + ) : ( <> - + )} @@ -275,9 +265,8 @@ export function PurchaseDialog({ monthId, purchase, trigger }: Props) {
- +
@@ -346,3 +335,32 @@ export function PurchaseDialog({ monthId, purchase, trigger }: Props) { ); } + +/** + * "set exact date" / "use the month only", under the date field. + * + * Was a bare ` + ); +} diff --git a/src/ui/components/SplitEditor.tsx b/src/ui/components/SplitEditor.tsx index 8ee36c3..b99dbec 100644 --- a/src/ui/components/SplitEditor.tsx +++ b/src/ui/components/SplitEditor.tsx @@ -2,7 +2,9 @@ import { Button } from "@/components/ui/button"; import { useDataset } from "../hooks/useDataset.ts"; import { digitsFor } from "../../domain/currencies.ts"; import { Input } from "@/components/ui/input"; +import { NativeSelect } from "@/components/ui/native-select"; import { Label } from "@/components/ui/label"; +import { Segmented } from "./Segmented.tsx"; import { formatAmount } from "../format.ts"; import type { PurchaseDraft, SplitDraft } from "../purchaseForm.ts"; import { splitBalance } from "../purchaseForm.ts"; @@ -39,25 +41,24 @@ export function SplitEditor({ draft, posts, onChange }: Props) {
-
- {(["percent", "fixed"] as const).map((mode) => ( - - ))} -
+ onChange({ ...draft, splitMode })} + options={[ + { value: "percent", label: "Percentages" }, + { value: "fixed", label: "Amounts" }, + ]} + />
{draft.splits.map((split, index) => (
- + {unit} -