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
refactor(attributes): draw the runs as a card each on desktop too
Elian Doranabdc8633f8ff
diff --git a/apps/client/src/widgets/sidebar/AttributeList.css b/apps/client/src/widgets/sidebar/AttributeList.cssindex 1525cbf57a..79f9f87082 100644--- a/apps/client/src/widgets/sidebar/AttributeList.css+++ b/apps/client/src/widgets/sidebar/AttributeList.css@@ -117,30 +117,9 @@}/*- * What can be done to the rows picked out, at the foot of the card. It stands where the add row- * stands and takes its turn, so that picking rows out costs the list no room of its own.- *- * Held at the foot of what can be seen of the card rather than left at the end of the rows: a note- * carrying more attributes than the card can show at once would otherwise have the bar scrolled off- * below them, and rows are picked out to be acted on. It sticks against the card's body, which is- * what scrolls (see RightPanelContainer.css); where the rows all fit, there is nothing to stick to- * and it sits at their end as before. It is lifted just clear of the rows — but left under the row- * an editor stands over (which reaches 10), that editor being the taller thing to read.- *- * Drawn as a surface of its own standing over the list rather than as a strip ruled off from it:- * held off the card's edges so that it reads as a thing laid on the card and not as furniture the- * card was built with. A rule across the card would have said instead that the list ends there,- * which it does not.- *- * The theme's card recipe, as the chat's composer island wears it (see ChatInputBar.css): the 10px- * radius shared by the centre pane, the dropdown menus and the tool dialogs, the card's own border- * and fill, and no shadow of its own — a Trilium surface is told by its fill, not by being lifted- * off what it sits on.- *- * Its fill is the one thing held apart from that recipe. A card's fill is a film over the pane- * rather than a colour, which the rows sliding under this one would be read straight through; so- * the film is laid over the app's surface here instead of straight onto the card, which comes out- * the shade the recipe asks for and hides what passes beneath it besides.+ * Sticky at the bottom of the scrolled tab, so it stays in view however far the selected rows are+ * scrolled. The background lays the card fill over the opaque app surface, so rows scrolling under the+ * bar do not show through it.*/.attribute-selection-bar {position: sticky;@@ -160,11 +139,7 @@var(--card-background-color, var(--accented-background-color)));}-/* The same island over a ground that is already carrying that wash. Where a run is a card of its own- — a phone (see AttributeSection) — the card paints exactly the fill composited above, so the bar- mixed to the card's own colour and disappeared into it, leaving its border to do all the work. The- plain surface instead, which is what those cards are washed over: the island reads as lifted off- them rather than as one more of them. */+/* A phone's cards already paint the card fill, which would make the bar the same color as them. */body.mobile .attribute-selection-bar {background-image: none;}@@ -184,86 +159,7 @@ body.mobile .attribute-selection-bar {border-radius: 50%;}-/*- * The heading a run of rows folds away under, where a card and its own header stood before. Dressed- * as those headers were — the pane's heading colour at its weight, its size and its letter spacing- * (see shell.css) — so that the runs still read as the sections they were, one notch quieter for- * standing inside a card rather than being one.- *- * Held at the top of what can be seen while its rows are scrolled past, so that a row is never read- * without the heading that says what it is; the heading of the run below pushes it out of the way in- * its turn. Opaque for the same reason the selection's island is, the rows passing under it — but- * the app's surface plainly, not the card's fill over it: a right-pane card paints no ground of its- * own, so its rows lie on that same surface, and a heading carrying the fill besides would read as- * a band laid across them rather than as words above them.- *- * The room above it is padding rather than margin, which a sticky box is held off its edge by: the- * rows would then be read through the gap that opened above the heading as they passed under it.- */-.attribute-list-panel .attribute-group-header {- position: sticky;- top: 0;- z-index: 1;- display: flex;- align-items: center;- /* The row's own gap, so that a heading's words start where a row's name does. */- gap: 6px;- padding: 7px 4px 3px;- cursor: pointer;- color: var(--right-pane-heading-color, var(--muted-text-color));- font-weight: 600;- font-size: 0.85em;- background-color: var(--main-background-color);-}--/* The room above a heading sets its run apart from the one before it. The first has none before it,- only the card's own header, which has set it apart already. */-.attribute-list-panel .attribute-group:first-child .attribute-group-header {- padding-top: 2px;-}--.attribute-list-panel .attribute-group-header:hover {- color: var(--main-text-color);-}--/*- * What makes the runs read as one thing branching rather than as three things stacked: the rows of a- * run hang under its heading, set in from it and gathered by a line drawn down the heading's own- * chevron — the branch the rows are on. The chevron folds the branch as a tree's does, and the line- * ends where the branch does, so the eye is told where a run stops without a rule across the card.- */-.attribute-list-panel .attribute-group-body {- /* Set so the line lands under the middle of the chevron above it. */- margin-inline-start: 11px;- padding-inline-start: 6px;- border-inline-start: 1px solid var(--main-border-color);-}--/* Turned as the cards turned theirs (see RightPanelContainer.css), so that folding a run away reads- as folding a card away did. */-.attribute-list-panel .attribute-group-chevron {- flex-shrink: 0;- transition: transform 100ms ease;-}--.attribute-list-panel .attribute-group.collapsed .attribute-group-chevron {- transform: rotate(-90deg);-}--.attribute-list-panel .attribute-group-title {- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;-}--/* How many the run holds, beside its name rather than away at the trailing edge: it is read as part- of what the run is called, not as a column of its own. Sized and worn as the note tree wears the- count of a node's hidden children (see note_tree.css) — the same wash, a shade of the ink over the- page rather than a colour, and small enough to be answered rather than announced. */-/* The same figure where a run is a card of its own rather than a heading of one — a phone (see- AttributeSection). Scoped by its own class rather than by the panel: the heading it sits in is the- card's, which stands outside the list. The card's name is set uppercase and letter-spaced, neither- of which a number takes any part in. */+/* The card titles are uppercase and letter-spaced; the count is not. */.attribute-run-count {margin-inline-start: 6px;padding: 0.1em 0.5em;@@ -276,27 +172,14 @@ body.mobile .attribute-selection-bar {vertical-align: middle;}-.attribute-list-panel .attribute-group-count {- flex-shrink: 0;- /* The heading's own gap sets it off; the base badge's margin would set it adrift of the name. */- margin-inline-start: 0;- padding: 0.1em 0.5em;- border-radius: 0.5em;- color: var(--muted-text-color);- font-size: 0.7rem;- font-weight: normal;- letter-spacing: 0;-}-/* What separates the note's own vocabulary from the names Trilium reads for itself. Quiet: the sort- is what carries the split, the rule only marks where it falls — and quieter still than the line- the run hangs from, which it crosses: a split within a branch, not a cut through it. Held off the- leading edge for the same reason, so the branch reads as running past it unbroken. */+/* What separates the note's own vocabulary from the names Trilium reads for itself. Quiet: the sort is+ what carries the split, the rule only marks where it falls. */.attribute-list-panel .attribute-rows-divider {- margin: 5px 4px 6px 8px;+ margin: 4px 4px 5px;border: none;border-top: 1px solid var(--main-border-color);- opacity: 0.45;+ opacity: 0.6;}.attribute-list-panel .attribute-name {diff --git a/apps/client/src/widgets/sidebar/AttributeList.mobile.spec.tsx b/apps/client/src/widgets/sidebar/AttributeList.mobile.spec.tsxindex ea66c8c3f7..7c8e16a89f 100644--- a/apps/client/src/widgets/sidebar/AttributeList.mobile.spec.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.mobile.spec.tsx@@ -55,17 +55,12 @@ describe("AttributeList on a phone", () => {vi.useRealTimers();});- it("draws a card per run rather than the tree a pointer gets", () => {+ it("draws a card per run", () => {renderPanel(noteWithRuns());- // A card each, as the panel had before its runs became headings of one card: the tree that- // gathers them is a pointer's affordance — hairlines, hover, a fold — drawn for a pane a hand- // wide, and a phone has neither the pointer nor the want of room.- expect(container.querySelectorAll(".attribute-group")).toHaveLength(0);- expect(container.querySelectorAll(".attribute-group-header")).toHaveLength(0);expect(sectionIds()).toEqual([ "attributes-owned", "attributes-inherited", "attributes-definitions" ]);- // Each card names its run and counts it beside the name, as the headings do on a desktop.+ // Each card counts its rows in its title.expect(section("attributes-owned").querySelector(".attribute-run-count")?.textContent).toBe("2");expect(section("attributes-definitions").querySelector(".attribute-run-count")?.textContent).toBe("2");diff --git a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx b/apps/client/src/widgets/sidebar/AttributeList.spec.tsxindex b05234150f..f7c88d7a1a 100644--- a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.spec.tsx@@ -184,47 +184,46 @@ describe("AttributeList", () => {}});- it("holds the note's own attributes, the inherited ones and the definitions of either in one list", () => {+ it("holds the note's own attributes, the inherited ones and the definitions of either in a card each", () => {renderPanel(noteWithAttributes());- // One card for the lot, every run of it under a heading of its own — the card names the- // panel, so the note's own attributes need one as much as the rest do.- expect(container.querySelectorAll(".card")).toHaveLength(1);- expect(groupIds()).toEqual([ "attributes-owned", "attributes-inherited", "attributes-definitions" ]);- expect(namesIn(group("attributes-owned"))).toEqual([ "author", "cssClass", "template" ]);- expect(namesIn(group("attributes-inherited"))).toEqual([ "inheritedLabel", "archived" ]);+ // Each card counts its rows in its title.+ expect(card("attributes-inherited").querySelector(".attribute-run-count")?.textContent).toBe("2");+ expect(cardIds()).toEqual([ "attributes-owned", "attributes-inherited", "attributes-definitions" ]);+ expect(namesIn(card("attributes-owned"))).toEqual([ "author", "cssClass", "template" ]);+ expect(namesIn(card("attributes-inherited"))).toEqual([ "inheritedLabel", "archived" ]);// The definitions of both notes share a group, the note's own first, and lose their prefix.- expect(namesIn(group("attributes-definitions"))).toEqual([ "priority", "status" ]);+ expect(namesIn(card("attributes-definitions"))).toEqual([ "priority", "status" ]);// The kind is carried by the icon; a definition takes the icon of the field it sets up.- expect(iconsIn(group("attributes-owned"))).toEqual([ "bx bx-hash", "bx bx-hash", "bx bx-transfer" ]);+ expect(iconsIn(card("attributes-owned"))).toEqual([ "bx bx-hash", "bx bx-hash", "bx bx-transfer" ]);// The icon also carries the row's one tooltip — the row itself has none to compete with it.// Only its presence: the wording is translated, and translations stay unloaded here.expect(container.querySelector(".attribute-row")?.hasAttribute("title")).toBe(false);expect(container.querySelector(".attribute-kind")?.hasAttribute("title")).toBe(true);// A definition that names no type sets up a text field, and takes that field's icon.- expect(iconsIn(group("attributes-definitions"))).toEqual([ "bx bx-calendar", "bx bx-text" ]);+ expect(iconsIn(card("attributes-definitions"))).toEqual([ "bx bx-calendar", "bx bx-text" ]);// The names Trilium reads for itself come last, below a rule, and are marked as such.- expect(group("attributes-owned").querySelectorAll("hr.attribute-rows-divider")).toHaveLength(1);- expect([ ...group("attributes-owned").querySelectorAll(".attribute-kind") ]+ expect(card("attributes-owned").querySelectorAll("hr.attribute-rows-divider")).toHaveLength(1);+ expect([ ...card("attributes-owned").querySelectorAll(".attribute-kind") ].map((kind) => kind.className.includes("marker-system"))).toEqual([ false, true, true ]);// A row of the note's own is deletable and unattributed; an inherited one names its note instead.- expect(group("attributes-owned").querySelectorAll(".attribute-delete-button")).toHaveLength(3);- expect(group("attributes-owned").querySelectorAll(".attribute-owner")).toHaveLength(0);- expect(group("attributes-inherited").querySelectorAll(".attribute-delete-button")).toHaveLength(0);- expect(group("attributes-inherited").querySelectorAll(".attribute-owner")).toHaveLength(2);+ expect(card("attributes-owned").querySelectorAll(".attribute-delete-button")).toHaveLength(3);+ expect(card("attributes-owned").querySelectorAll(".attribute-owner")).toHaveLength(0);+ expect(card("attributes-inherited").querySelectorAll(".attribute-delete-button")).toHaveLength(0);+ expect(card("attributes-inherited").querySelectorAll(".attribute-owner")).toHaveLength(2);// Only what the note may edit is deletable, whichever run it is in.- expect(group("attributes-definitions").querySelectorAll(".attribute-delete-button")).toHaveLength(1);+ expect(card("attributes-definitions").querySelectorAll(".attribute-delete-button")).toHaveLength(1);// An inheritable attribute is marked, and every definition previews what it sets up — a// set-holding one (label:status, "multi") by a mark of its own rather than by words.- expect(group("attributes-inherited").querySelectorAll(".attribute-marker")).toHaveLength(2);- expect(group("attributes-definitions").querySelectorAll(".attribute-value.definition")).toHaveLength(2);- expect(group("attributes-definitions").querySelectorAll(".definition-marker")).toHaveLength(1);+ expect(card("attributes-inherited").querySelectorAll(".attribute-marker")).toHaveLength(2);+ expect(card("attributes-definitions").querySelectorAll(".attribute-value.definition")).toHaveLength(2);+ expect(card("attributes-definitions").querySelectorAll(".definition-marker")).toHaveLength(1);});it("lists the attributes of a note that cannot be edited, offering no way to change them", () => {@@ -232,34 +231,37 @@ describe("AttributeList", () => {note.isContentWritable = false;renderPanel(note);- expect(namesIn(group("attributes-owned"))).toEqual([ "author", "cssClass", "template" ]);+ expect(namesIn(card("attributes-owned"))).toEqual([ "author", "cssClass", "template" ]);// Read as any other note's: Trilium's own names below the rule, inherited ones naming their note.- expect(group("attributes-owned").querySelectorAll("hr.attribute-rows-divider")).toHaveLength(1);- expect(group("attributes-inherited").querySelectorAll(".attribute-owner")).toHaveLength(2);+ expect(card("attributes-owned").querySelectorAll("hr.attribute-rows-divider")).toHaveLength(1);+ expect(card("attributes-inherited").querySelectorAll(".attribute-owner")).toHaveLength(2);expect(container.querySelectorAll(".attribute-delete-button")).toHaveLength(0);expect(container.querySelectorAll(".attribute-edit-button")).toHaveLength(0);expect(container.querySelector(".attribute-add-row")).toBeNull();expect(container.querySelector(".bx-plus")).toBeNull();});- it("folds a run of rows away by its heading, and remembers it folded", async () => {+ it("collapses a card by its header, and remembers it collapsed", async () => {options.set("rightPaneCollapsedItems", JSON.stringify([ "attributes-inherited" ]));renderPanel(noteWithAttributes());- // Remembered from before, so the run arrives folded and its rows are not drawn at all.- expect(group("attributes-inherited").className).toContain("collapsed");- expect(namesIn(group("attributes-inherited"))).toEqual([]);- // The card is the only one its tab has, so it is not itself something to fold away.- expect(container.querySelector(".card")?.className).toContain("not-collapsible");+ // A card remembered as collapsed renders without its rows.+ expect(card("attributes-inherited").className).toContain("collapsed");+ expect(namesIn(card("attributes-inherited"))).toEqual([]);- await act(async () => groupHeader("attributes-inherited").click());- expect(group("attributes-inherited").className).not.toContain("collapsed");- expect(namesIn(group("attributes-inherited"))).toEqual([ "inheritedLabel", "archived" ]);+ await act(async () => cardHeader("attributes-inherited").click());+ expect(card("attributes-inherited").className).not.toContain("collapsed");+ expect(namesIn(card("attributes-inherited"))).toEqual([ "inheritedLabel", "archived" ]);expect(JSON.parse(options.get("rightPaneCollapsedItems") ?? "[]")).not.toContain("attributes-inherited");- // And folding one back up is remembered the same way.- await act(async () => groupHeader("attributes-definitions").click());+ // Collapsing is remembered the same way.+ await act(async () => cardHeader("attributes-definitions").click());expect(JSON.parse(options.get("rightPaneCollapsedItems") ?? "[]")).toContain("attributes-definitions");++ // A note with one card has nothing to collapse it in favor of.+ render(null, container);+ renderPanel(buildNote({ id: "bare", title: "Bare", "#author": "Elian" }));+ expect(card("attributes-owned").className).toContain("not-collapsible");});it("leaves a note carrying no attributes its heading and the way in, and says nothing besides", () => {@@ -270,9 +272,9 @@ describe("AttributeList", () => {// would be a third telling of the one fact, and the loudest of the three at that.expect(container.querySelectorAll(".attribute-row")).toHaveLength(0);expect(container.querySelector(".no-items")).toBeNull();- expect(groupIds()).toEqual([ "attributes-owned" ]);- expect(group("attributes-owned").querySelector(".attribute-group-count")?.textContent).toBe("0");- expect(group("attributes-owned").querySelector(".attribute-add-row")).not.toBeNull();+ expect(cardIds()).toEqual([ "attributes-owned" ]);+ expect(card("attributes-owned").querySelector(".attribute-run-count")?.textContent).toBe("0");+ expect(card("attributes-owned").querySelector(".attribute-add-row")).not.toBeNull();// Adding takes the placeholder's place: there is a row again, draft though it still is.act(() => container.querySelector<HTMLElement>(".attribute-add-row")?.click());@@ -285,15 +287,15 @@ describe("AttributeList", () => {const note = buildNote({ id: "linking", title: "Linking", "#author": "Elian", "~internalLink": "target" });renderPanel(note);- expect(groupIds()).toEqual([ "attributes-owned" ]);+ expect(cardIds()).toEqual([ "attributes-owned" ]);// Unmounted first, the panel collecting the attributes of the note it is handed as it mounts.setDevBuild(true);render(null, container);renderPanel(note);- expect(groupIds()).toEqual([ "attributes-owned", "attributes-internal" ]);- const internal = group("attributes-internal");+ expect(cardIds()).toEqual([ "attributes-owned", "attributes-internal" ]);+ const internal = card("attributes-internal");expect(namesIn(internal)).toEqual([ "internalLink" ]);// Nothing on such a row is the note's to change, and nothing marks it as Trilium's own: the// heading it is under says as much of every row it holds.@@ -400,7 +402,7 @@ describe("AttributeList", () => {// a long way from the definitions once a template has filled the pane. It adds the one kind —// the form's own list of field types is where a relation definition is reached — so it opens// the same popup on the same thing the menu's third entry did, with no menu in between.- const definitionAddRow = group("attributes-definitions").querySelector<HTMLElement>(".attribute-add-row");+ const definitionAddRow = card("attributes-definitions").querySelector<HTMLElement>(".attribute-add-row");expect(definitionAddRow).not.toBeNull();act(() => definitionAddRow?.click());expect(document.querySelector(".attr-detail")).not.toBeNull();@@ -477,7 +479,7 @@ describe("AttributeList", () => {// ...in a row at the foot of the list, where the press that opened it was — and not where// the sort would file a name it does not have yet, above the ones Trilium reads for itself.- const ownedRun = group("attributes-owned");+ const ownedRun = card("attributes-owned");expect(namesIn(ownedRun)).toEqual([ "author", "cssClass", "template", "" ]);expect([ ...ownedRun.querySelectorAll(".attribute-row") ].at(-1)?.contains(editor ?? null)).toBe(true);@@ -682,7 +684,7 @@ describe("AttributeList", () => {// hold open — and an inherited flag with no value is not something the note lacks.render(null, container);renderPanel(noteWithAttributes());- const archived = [ ...group("attributes-inherited").querySelectorAll(".attribute-row") ]+ const archived = [ ...card("attributes-inherited").querySelectorAll(".attribute-row") ].find((row) => row.querySelector(".attribute-name")?.textContent === "archived");expect(archived?.querySelector(".attribute-value")?.className).not.toContain("value-placeholder");expect(archived?.querySelector(".attribute-value")?.textContent).toBe("");@@ -1112,10 +1114,8 @@ describe("AttributeList", () => {const bar = container.querySelector(".attribute-selection-bar");expect(bar).not.toBeNull();expect(firstPanel().className).toContain("selecting");- // The bar belongs to the whole list rather than to a run of it, the rows it acts on being- // picked out anywhere: it stands at the list's own foot, outside every folding run.- expect(bar?.closest(".attribute-group")).toBeNull();- expect(bar?.closest(".attribute-list-panel")).not.toBeNull();+ // The bar follows the cards rather than sitting in one, since a selection can span several.+ expect(bar?.closest(".card")).toBeNull();// Adding an attribute stays on offer beside the note's own rows; the bar took nothing over.expect(container.querySelector(".attribute-add-row")).not.toBeNull();// Only that the count has a slot: the wording is translated, and translations stay unloaded.@@ -1301,24 +1301,22 @@ describe("AttributeList", () => {});}- function groupIds() {- return [ ...container.querySelectorAll(".attribute-group") ]- .map((el) => [ ...el.classList ].find((name) => name.startsWith("attributes-")));+ function cardIds() {+ return [ ...container.querySelectorAll(".card") ].map((el) => el.id);}- function group(id: string) {- const el = container.querySelector<HTMLElement>(`.attribute-group.${id}`);+ function card(id: string) {+ const el = container.querySelector<HTMLElement>(`.card#${id}`);expect(el, id).not.toBeNull();return el as HTMLElement;}- function groupHeader(id: string) {- const header = group(id).querySelector<HTMLElement>(".attribute-group-header");+ function cardHeader(id: string) {+ const header = card(id).querySelector<HTMLElement>(".card-header");expect(header, id).not.toBeNull();return header as HTMLElement;}-function firstRow() {const row = container.querySelector<HTMLElement>(".attribute-row");expect(row).not.toBeNull();diff --git a/apps/client/src/widgets/sidebar/AttributeList.tsx b/apps/client/src/widgets/sidebar/AttributeList.tsxindex 07a875443d..e619666bc5 100644--- a/apps/client/src/widgets/sidebar/AttributeList.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.tsx@@ -24,7 +24,7 @@ import { ColorChip, renderLabelValue } from "../attribute_widgets/label_value_diimport ActionButton from "../react/ActionButton";import SimpleBadge from "../react/Badge";import { FormListItem } from "../react/FormList";-import { useActiveNoteContext, useTriliumEvent, useTriliumOptionJson } from "../react/hooks";+import { useActiveNoteContext, useTriliumEvent } from "../react/hooks";import Icon from "../react/Icon";import { DetailPane, MasterPane, useMasterDetail, useMasterDetailPage } from "../react/master_detail";import NoItems from "../react/NoItems";@@ -681,15 +681,12 @@ export default function AttributeList() {onSaveAndClose: detail?.isOwned ? commit : undefined,onDelete: detail?.isOwned ? () => void deleteAttribute(detail.attribute) : undefined};- // The runs the panel is made of, in the order it draws them — the same runs either way it is- // drawn (see below), so what a run is and what it holds is settled in one place.+ // The runs of the panel, in display order; each is drawn as a card.const runs: AttributeRun[] = [ {id: "attributes-owned",title: t("attribute_list_panel.section_owned"),count: sections.owned.length,- // The note's own values read from the trailing edge, as the inherited ones' do — the two- // runs of plain attributes reading as one ledger. Nothing stands in for the run holding- // nothing: its count says it is empty and its way in says what there is to do about it.+ help: "attributes",// The draft under creation is listed last, outside the split between the note's own names and// Trilium's (see `creationRow`).rows: (@@ -737,10 +734,7 @@ export default function AttributeList() {// here rather than at each use so that one render offers the same thing everywhere in itself.const heldAttributes = getHeldAttributes();- // At the foot of the runs, the rows it acts on being picked out anywhere among them. It holds- // there while they are scrolled (see the stylesheet), so it is the one thing both ways of- // drawing them share: a phone picks rows out by holding one down, a pointer by the checkbox or- // a modifier, and either way what can be done about it is said in the one place.+ // After the cards rather than inside one, since a selection can span several cards.const selectionBar = note && isSelecting && (<AttributeSelectionBarcount={selection.size}@@ -762,38 +756,23 @@ export default function AttributeList() {...clipboardProps};- const sectionList = IS_MOBILE ? (- // A card each, as the panel had before its runs became headings of one card. What made them- // headings was a pane a hand wide, where four card headers were a great deal of it to spend- // on saying which run is which — and the tree that gathered them was drawn for a pointer, in- // hairlines and hover. A phone has neither: the panel is a sheet the width of the screen,- // which has the room, and the card is already how everything else on it says that things- // belong together (see the settings pages). So the runs are cards again here, and the tree- // is left to the pane that needed it.- <>+ // A card per run. With a single card, there is nothing to collapse it in favor of.+ const sectionList = (+ <CollapsibleWidgets.Provider value={runs.length > 1}>{runs.map((run, index) => (<AttributeSectionkey={run.id}id={run.id}title={run.title}count={run.count}- buttons={note && (index === 0 ? (- // The panel's own two ride on the first card: there is no header above the- // cards to put them in, and the note's own attributes are what the panel is- // opened for. The menu is also the only way to a relation on a phone, whose- // rows are pressed rather than typed into — hence every kind, not just this- // run's.+ grow={index === 0}+ buttons={note && (<>- <SidebarHelp section="attributes" />-- {/* The only way to paste a phone has. A pointer has three — the key,- a right press on a row, a right press beside them — and all three- are a pointer's: there is no paste key to press, a row that is held- down is being picked out instead, and the list a press beside the- rows would land on is nothing at all on the note that most wants- pasting into, having no rows to give it a height. The header is the- one part of a run that stands whatever the run holds. */}- {canEdit && heldAttributes.length > 0 && (+ {run.help && <SidebarHelp section={run.help} />}++ {/* The only paste control that works on a phone and on a note with no+ attributes, which has no rows to right-click. */}+ {index === 0 && canEdit && heldAttributes.length > 0 && (<ActionButtonicon="bx bx-paste"text={t("attribute_list_panel.paste", { count: heldAttributes.length })}@@ -804,19 +783,16 @@ export default function AttributeList() {/>)}- {canEdit && <AddAttributeButton- text={t("attribute_editor.add_a_new_attribute")}- attrTypes={ALL_ATTRIBUTE_KINDS}- onSelect={addAttribute}- />}- </>- ) : (- <>- {run.help && <SidebarHelp section={run.help} />}- {run.add && (- // A run that can be added to says so in its own header, which is where a- // card keeps what is done to it. The ghost row a pointer gets is a hover- // affordance, so it stays on the desktop.+ {index === 0 && canEdit && (+ <AddAttributeButton+ text={t("attribute_editor.add_a_new_attribute")}+ attrTypes={ALL_ATTRIBUTE_KINDS}+ onSelect={addAttribute}+ />+ )}++ {/* A phone has no hover, so it adds from the header instead of the add row. */}+ {index > 0 && IS_MOBILE && run.add && (<ActionButtonicon="bx bx-plus"text={run.add.text}@@ -827,25 +803,24 @@ export default function AttributeList() {/>)}</>- ))}+ )}><divclass={clsx("attribute-list-panel", isSelecting && "selecting")}- // The popup anchors to the panel, and the first card is the one it is- // opened over: the note's own attributes are what it edits.+ // The detail popup anchors to the first card, which holds the note's own attributes.ref={index === 0 ? containerRef : undefined}{...panelProps}>{run.rows}- {/* A run holding nothing says so here, where a pointer's does not: there,- the count says the run is empty and the add row beneath it says what- there is to do about it, so a third telling would be one too many. A- phone has no add row — a card keeps what is done to it in its header —- which leaves an empty run as an empty card, saying nothing at all. Only- the note's own attributes can be shown empty; every other run is left- out entirely when it holds nothing. */}- {run.count === 0 && (+ {!IS_MOBILE && run.add && (+ <AddAttributeRow+ text={run.add.text}+ onAdd={(e) => addAttribute(run.add?.kind ?? "label", e)}+ />+ )}++ {run.count === 0 && (IS_MOBILE || !run.add) && (<NoItems icon="bx bx-hash" text={t("attribute_list_panel.no_attributes")} />)}</div>@@ -853,56 +828,6 @@ export default function AttributeList() {))}{selectionBar}- </>- ) : (- // One card holding the lot, the runs being headings within it rather than cards of their- // own: they are one list to the eye and one list to a selection — a range runs from any row- // to any other — and four headers is a great deal of a hand-wide pane to spend on saying- // which run is which. It also leaves the selection's own bar somewhere to belong: a bar at- // the foot of one card among several belonged to a card the picked rows need not have been- // in at all.- //- // Collapsing moves to the headings with it. The card cannot be collapsed away, being all its- // tab has (see RightPanelWidget), which is what the context below says.- <CollapsibleWidgets.Provider value={false}>- <AttributeSection- id="attributes"- title={t("attributes_panel.title")}- grow- buttons={note && (- <>- <SidebarHelp section="attributes" />- {canEdit && <AddAttributeButton- text={t("attribute_editor.add_a_new_attribute")}- attrTypes={ALL_ATTRIBUTE_KINDS}- onSelect={addAttribute}- />}- </>- )}- >- <div- class={clsx("attribute-list-panel", isSelecting && "selecting")}- ref={containerRef}- {...panelProps}- >- {runs.map((run) => (- <AttributeGroup key={run.id} id={run.id} title={run.title} count={run.count}>- {run.rows}-- {/* Inside the run it adds to rather than at the foot of everything, and- put away with it. */}- {run.add && note && (- <AddAttributeRow- text={run.add.text}- onAdd={(e) => addAttribute(run.add?.kind ?? "label", e)}- />- )}- </AttributeGroup>- ))}-- {selectionBar}- </div>- </AttributeSection></CollapsibleWidgets.Provider>);@@ -945,134 +870,58 @@ export default function AttributeList() {);}-/**- * One run of the panel — a heading with its rows on a desktop, a card of its own on a phone. Held- * apart from either so that what the runs are, and which of them the note has at all, is settled- * once rather than twice over.- */+/** One run of the panel. */interface AttributeRun {- /** What the run is known by: a class on it, and what a collapsed run is remembered under. */+ /** The card's id, which is also the key its collapsed state is remembered under. */id: string;title: string;count: number;rows: ComponentChildren;- /** The `?` of the run, shown in its card header on a phone. */help?: SidebarSectionId;- /** How the run is added to, for the runs that can be — the kind, and what to call adding it. */+ /** The kind of attribute the run's add control creates, and the control's label. */add?: { kind: AttributeKind; text: string };}interface AttributeSectionProps {- /** What the right pane remembers the section by, collapsed state and all. */+ /** The id the right pane remembers the card's collapsed state under. */id: string;title: string;- /**- * How many rows the section holds, where it stands for one run. A phone puts it beside the name- * in the card's own heading, the runs being cards there; the right pane's card names the whole- * panel and leaves counting to the headings within it.- */- count?: number;+ /** Shown as a badge after the title. */+ count: number;children: ComponentChildren;buttons?: ComponentChildren;- /** Passed on to {@link RightPanelWidget}, which is the only host that has room to give. */+ /** Passed to {@link RightPanelWidget}; a phone has no use for it. */grow?: boolean;}/**- * One section, drawn as the layout it is in draws a titled group of things: a card of the right pane on- * a desktop, foldable and remembered as folded; the same card the settings pages are built from on a- * phone, where the panel is a page of its own and a title is read rather than pressed.+ * One card: a collapsible {@link RightPanelWidget} on desktop, and an {@link OptionsSection} on a+ * phone, which matches the settings pages.*/function AttributeSection({ id, title, count, children, buttons, grow }: AttributeSectionProps) {+ const heading = (+ <>+ {title}+ <SimpleBadge className="attribute-run-count" title={count} />+ </>+ );+if (IS_MOBILE) {- // The id names the section here too, as a class: it is what the right pane knows the section by,- // and there is no reason for a stylesheet (or a test) to know it by anything else.+ // On a phone the id is a class, since `OptionsSection` has no id.return (- <OptionsSection- className={id}- title={- <>- {title}- {/* The figure the desktop headings wear, in a heading that is uppercase and- letter-spaced — which a number takes no part in (see the stylesheet). */}- {count !== undefined && <SimpleBadge className="attribute-run-count" title={count} />}- </>- }- actions={buttons}- >+ <OptionsSection className={id} title={heading} actions={buttons}>{children}</OptionsSection>);}return (- <RightPanelWidget id={id} title={title} buttons={buttons} grow={grow}>+ <RightPanelWidget id={id} title={heading} buttons={buttons} grow={grow}>{children}</RightPanelWidget>);}-/**- * One run of rows under a heading that folds it away: the note's own attributes, what reaches it- * from elsewhere, the definitions behind either, and — in a development build — what Trilium wrote- * for itself. The card names the panel rather than any one of them, so each says what it is itself.- *- * A card each is what they were before, which spent four headers' worth of a hand-wide pane on- * saying which run was which. What is kept from those cards is the folding — a template's dozens of- * inherited attributes can still be put away — and what it is remembered under, so a pane that had- * them put away has them put away still.- */-function AttributeGroup({ id, title, count, children }: {- id: string;- title: string;- /** How many rows the run holds, shown beside its name rather than read ahead of it. */- count: number;- children: ComponentChildren;-}) {- const [ collapsedItems, setCollapsedItems ] = useTriliumOptionJson<string[]>("rightPaneCollapsedItems");- const [ collapsed, setCollapsed ] = useState(collapsedItems.includes(id));-- function toggle() {- const remembered = new Set(collapsedItems);- if (collapsed) {- remembered.delete(id);- } else {- remembered.add(id);- }-- setCollapsed(!collapsed);- void setCollapsedItems([ ...remembered ]);- }-- return (- // Named by its id as the card it stands in for was, which is what a stylesheet — or a test —- // knows the run by.- <div class={clsx("attribute-group", id, collapsed && "collapsed")}>- <div- class="attribute-group-header"- onClick={(e) => {- // Kept from the list, whose handler would close a form this press is not about.- e.stopPropagation();- toggle();- }}- >- <Icon className="attribute-group-chevron" icon="bx bx-chevron-down" />- <span class="attribute-group-title">{title}</span>-- {/* Beside the name rather than away at the trailing edge: it is read as part of what- the run is called. The plain badge, as the note tree counts a node's hidden- children with and as the checkbox tree counts its leaves — a bare figure, the- heading beside it saying what is being counted. */}- <SimpleBadge className="attribute-group-count" title={count} />- </div>-- {/* The rows hang together under the heading rather than each standing on its own, so that- the line drawn down from it (see the stylesheet) is one line and not one per row. */}- {!collapsed && <div class="attribute-group-body">{children}</div>}- </div>- );-}-interface AttributeRowListProps {rows: AttributeEntry[];/** The note the rows belong to, read for the definitions that type their values. */diff --git a/apps/client/src/widgets/sidebar/RightPanelWidget.tsx b/apps/client/src/widgets/sidebar/RightPanelWidget.tsxindex 33536facfe..6dfc00fa6d 100644--- a/apps/client/src/widgets/sidebar/RightPanelWidget.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelWidget.tsx@@ -28,7 +28,7 @@ export const ExpandWidgetRequests = createContext<ExpandWidgetRequest | null>(nuinterface RightPanelWidgetProps {id: string;- title: string;+ title: ComponentChildren;children: ComponentChildren;buttons?: ComponentChildren;containerRef?: RefObject<HTMLDivElement | null>;