feat(sidebar): add indentation and font size settings
This commit is contained in:
1 parent
98df975614
commit
745483cd6c
16 files changed
+164
-13
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { alignedCommentLeadingWidth, alignedSidebarCommentLabelWidths, canTreeNodeShowExpander, sidebarTreeNaturalContentWidth, sidebarTreeNodeComment, trailingCommentAvailableWidth, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
import { alignedCommentLeadingWidth, alignedSidebarCommentLabelWidths, canTreeNodeShowExpander, sidebarTreeNaturalContentWidth, sidebarTreeNodeComment, trailingCommentAvailableWidth, treeItemPaddingLeft, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
import type { TreeNode } from "@/types/database";
|
||||
|
||||
describe("sidebar tree item layout", () => {
|
||||
@@ -91,4 +91,16 @@ describe("sidebar tree item layout", () => {
|
||||
it("returns zero when no tree row uses natural width", () => {
|
||||
expect(sidebarTreeNaturalContentWidth([{ depth: 2, label: "commented", usesNaturalWidth: false }], (text) => text.length * 7)).toBe(0);
|
||||
});
|
||||
|
||||
it("applies a configurable per-depth indent to rows and natural-width measurement", () => {
|
||||
// Default keeps the historical 16px per level.
|
||||
expect(treeItemPaddingLeft(2)).toBe("40px");
|
||||
expect(treeItemPaddingLeft(2, 24)).toBe("56px");
|
||||
expect(treeItemPaddingLeft(0, 24)).toBe("8px");
|
||||
|
||||
const items = [{ depth: 4, label: "nested", usesNaturalWidth: true, trailingWidth: 20 }];
|
||||
const measure = (text: string) => text.length * 7;
|
||||
expect(sidebarTreeNaturalContentWidth(items, measure, 16)).toBe(4 * 16 + 8 + 54 + "nested".length * 7 + 20);
|
||||
expect(sidebarTreeNaturalContentWidth(items, measure, 32)).toBe(4 * 32 + 8 + 54 + "nested".length * 7 + 20);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user