Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/cleanup tool: tweak the UI
Adorian Doran2a43b8dbbe4c
diff --git a/apps/client/src/widgets/react/charts/DonutChart.css b/apps/client/src/widgets/react/charts/DonutChart.cssindex 16e8c2e835..1f947e5e0c 100644--- a/apps/client/src/widgets/react/charts/DonutChart.css+++ b/apps/client/src/widgets/react/charts/DonutChart.css@@ -12,6 +12,12 @@height: 100%;}+ /* The empty band the segments are laid on, in the color of any other divider — a ring with+ nothing on it still has to read as a ring rather than as a blank square. */+ .donut-track {+ stroke: var(--donut-track-color, var(--main-border-color));+ }+/* Colored through a variable, not a competing rule: consumers set `--donut-segment-color` andnever race this stylesheet's cascade position. */.donut-segment {diff --git a/apps/client/src/widgets/react/charts/DonutChart.render.spec.tsx b/apps/client/src/widgets/react/charts/DonutChart.render.spec.tsxindex 0369f47cc5..7a9cbe3378 100644--- a/apps/client/src/widgets/react/charts/DonutChart.render.spec.tsx+++ b/apps/client/src/widgets/react/charts/DonutChart.render.spec.tsx@@ -60,6 +60,26 @@ describe("DonutChart rendering", () => {expect(circles[0].style.strokeWidth).toContain("20");});+ it("lays the segments on a track when asked, and keeps it when they add up to nothing", () => {+ const probe = renderChart([ ring({ track: true }) ]);+ const tracks = probe.querySelectorAll<SVGCircleElement>(".donut-track");++ expect(tracks.length).toBe(1);+ // Drawn first, so every segment paints over it, and at the band's own width.+ expect(probe.querySelector("circle")).toBe(tracks[0]);+ expect(tracks[0].style.strokeWidth).toContain("20");++ // The case it is there for: nothing to draw, and the ring still reads as a ring.+ render(null, probe);+ const empty = renderChart([ ring({ track: true, segments: [ { id: "none", value: 0 } ] }) ]);+ expect(empty.querySelectorAll(".donut-track").length).toBe(1);+ expect(empty.querySelectorAll(".donut-segment").length).toBe(0);+ });++ it("leaves the band bare unless a track is asked for", () => {+ expect(renderChart([ ring() ]).querySelector(".donut-track")).toBeNull();+ });+it("tints by hue variable, forwards classes, and renders the center content", () => {const probe = renderChart([ ring() ], <span className="center-probe">middle</span>);const [ a, b ] = [ ...probe.querySelectorAll<SVGCircleElement>("circle") ];diff --git a/apps/client/src/widgets/react/charts/DonutChart.tsx b/apps/client/src/widgets/react/charts/DonutChart.tsxindex ed090f7716..5a959a7718 100644--- a/apps/client/src/widgets/react/charts/DonutChart.tsx+++ b/apps/client/src/widgets/react/charts/DonutChart.tsx@@ -29,6 +29,11 @@ export interface DonutRing<T = unknown> {radius: number;thickness: number;segments: DonutSegment<T>[];+ /**+ * Draws a full circle under the segments, so the band reads as a ring whatever is on it — and+ * still reads as one when every value is zero and no segment is drawn at all.+ */+ track?: boolean;onSegmentClick?: (segment: DonutSegment<T>) => void;onSegmentContextMenu?: (segment: DonutSegment<T>, event: MouseEvent) => void;}@@ -100,6 +105,10 @@ function Ring<T>({ ring, onSegmentHover }: {return (<g>+ {/* First, so every segment paints over it. */}+ {ring.track && (+ <circle className="donut-track" r={ring.radius} fill="none" style={{ strokeWidth: ring.thickness }} />+ )}{ring.segments.map((segment, index) => {const arc = layout[index];diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/cleanup_dialog.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/cleanup_dialog.tsxindex d0e16597a2..89401fa4e0 100644--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/cleanup_dialog.tsx+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/cleanup_dialog.tsx@@ -87,6 +87,9 @@ function CleanupDialog({ onFinished }: { onFinished: (reclaimed: number | null)id: "cleanup",radius: DONUT_RADIUS,thickness: DONUT_THICKNESS,+ // A database with nothing to reclaim draws no segment at all; the track is what keeps the+ // reading in its hole from floating in an empty square.+ track: true,segments: CLEANUP_ITEMS.map((item) => ({id: item.id,value: sizes.perItem[item.id],diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsxindex 69e052b21d..433db1f7e3 100644--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx@@ -55,11 +55,11 @@ export default function SpaceUsage({ sectionSwitcher }: ContentManagerSectionProcurrentValue={view}onChange={setView}/>- {/* Boxicons ships no broom; the eraser is what the dialog does anyway. The- charts re-measure once it is done, having just been made wrong by it. */}+ {/* Boxicons ships no broom; the brush is the nearest thing it has. The charts+ re-measure once the dialog is done, having just been made wrong by it. */}<ActionButtonclassName="space-usage-cleanup"- icon="bx bx-eraser"+ icon="bx bx-brush-alt"text={t("space_usage.cleanup_title")}onClick={() => void showCleanupDialog().then((reclaimed) => {if (reclaimed !== null) {