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/collections/board: make the card use the same layout in editing/normal mode
Adorian Doran6aa29c7c1790
diff --git a/apps/client/src/widgets/collections/board/card.spec.tsx b/apps/client/src/widgets/collections/board/card.spec.tsxindex 133599500d..f9ea137aeb 100644--- a/apps/client/src/widgets/collections/board/card.spec.tsx+++ b/apps/client/src/widgets/collections/board/card.spec.tsx@@ -371,6 +371,22 @@ describe("Board card", () => {}});+ /**+ * The card is the same height either way, so opening the editor neither drops what the card+ * shows nor moves the cards below it.+ */+ it("keeps the badges it shows while its title is being edited", async () => {+ const { first } = await renderBoard();+ // Held on to: the editor takes the place of the title the lookup goes by.+ const element = card(first);+ expect(element.querySelector(".user-attributes")).toBeTruthy();++ await act(async () => { press(element, "F2"); });++ expect(element.querySelector("textarea")).toBeTruthy();+ expect(element.querySelector(".user-attributes")).toBeTruthy();+ });+it("offers the card menu on a right click", async () => {const { first } = await renderBoard();const show = vi.spyOn(contextMenu, "show").mockImplementation(async () => {});diff --git a/apps/client/src/widgets/collections/board/card.tsx b/apps/client/src/widgets/collections/board/card.tsxindex 9b217b2357..537a580ba1 100644--- a/apps/client/src/widgets/collections/board/card.tsx+++ b/apps/client/src/widgets/collections/board/card.tsx@@ -259,12 +259,6 @@ function Card({title={t("board_view.edit-note-title")}onClick={handleEdit}/>- <UserAttributesDisplay- note={note}- ignoredAttributes={[statusAttribute]}- shownAttributes={shownAttributes}- badges={isOutsideFilter && <OutsideFilterBadge />}- /></>) : (<TitleEditor@@ -283,6 +277,14 @@ function Card({}}/>)}+ {/* Drawn while the title is being edited as well, so a card keeps what it shows and+ stands the same height either way. */}+ <UserAttributesDisplay+ note={note}+ ignoredAttributes={[statusAttribute]}+ shownAttributes={shownAttributes}+ badges={isOutsideFilter && <OutsideFilterBadge />}+ /></div>)}diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.cssindex 9ad1bc4758..8f02ea1a3e 100644--- a/apps/client/src/widgets/collections/board/index.css+++ b/apps/client/src/widgets/collections/board/index.css@@ -50,6 +50,8 @@--card-font-size: 0.9em;--card-line-height: 1.2;--card-padding: 0.6em;+ /* What stands between a card's title and the row of badges under it, in both modes. */+ --card-badge-gap: 8px;/* The icon a card carries, and where it and the title stand from the card's leading edge. Thecard and the editor it opens into are laid out from these, so switching between them movesnothing. All three are worked out in the card's own font. */@@ -651,6 +653,27 @@ body.mobile .board-view-container .board-add-column {padding: 0;}+/* A card being edited stacks the field over what it shows, rather than standing them side by side:+ the badges are drawn either way, so the card keeps its own height as the editor opens. */+.board-view-container .board-note.editing {+ flex-direction: column;+ align-items: stretch;+}++/* The card gives its padding to the field while one is open, so what stands under it is inset by+ the card's own instead. The field's foot padding already stands between the text and this row,+ so only what is left of the gap is added, and the card is the height it is either way. */+.board-view-container .board-note.editing .user-attributes {+ margin-block-start: calc(var(--card-badge-gap) - var(--card-padding));+ padding-inline: var(--card-padding);+ padding-block-end: var(--card-padding);+}++/* Named here as well, so both modes are worked out from the one value. */+.board-view-container .board-note .user-attributes {+ margin-block-start: var(--card-badge-gap);+}+/* One line stands exactly as tall as the card, or as the closed button; typing more grows it fromthere. Stated rather than left to the field's own intrinsic height, which rounds a line of 1.2emup to a whole pixel and leaves a card being edited a fraction taller than the same card is when