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: tweak the appearance
Adorian Doranf0080558b18d
diff --git a/apps/client/src/widgets/collections/board/card.tsx b/apps/client/src/widgets/collections/board/card.tsxindex 4159ffbe42..72248f660b 100644--- a/apps/client/src/widgets/collections/board/card.tsx+++ b/apps/client/src/widgets/collections/board/card.tsx@@ -59,6 +59,9 @@ function Card({const editorRef = useRef<HTMLInputElement>(null);const cardRef = useRef<HTMLDivElement>(null);const [ isArchived ] = useNoteLabelBoolean(note, "archived");+ // The card stays the one just made until another is, so what has already been shown is+ // remembered here rather than played again by every redraw of the column.+ const [ isRevealed, setIsRevealed ] = useState(false);const [ title, setTitle ] = useState(note.title);// Tracks the `iconClass` label, which an attribute change carries and the note row never does.const icon = useNoteIcon(note);@@ -141,7 +144,12 @@ function Card({return (<divref={cardRef}- className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""} ${isNew ? "appearing" : ""}`}+ className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""} ${isNew && !isRevealed ? "appearing" : ""}`}+ onAnimationEnd={(e) => {+ if (e.animationName === "board-card-appear") {+ setIsRevealed(true);+ }+ }}data-note-id={note.noteId}onContextMenu={handleContextMenu}onClick={!isEditing ? handleOpen : undefined}diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.cssindex 523dcf897a..9310787744 100644--- a/apps/client/src/widgets/collections/board/index.css+++ b/apps/client/src/widgets/collections/board/index.css@@ -234,7 +234,8 @@ body.mobile .board-view-container .board-add-column {min-height: 0;overflow-x: hidden;overflow-y: auto;- padding: 0.5em;+ /* No padding below: the last card's own gap stands between it and the footer. */+ padding: 0.5em 0.5em 0;}.board-view-container .board-column > .board-new-item {@@ -471,6 +472,12 @@ body.mobile .board-view-container .board-add-column {padding: 0;}+.board-view-container .board-new-item textarea.form-control {+ /* One line stands exactly as tall as the closed button; typing more grows it from there. */+ min-height: calc(var(--card-line-height) * 1em + 2 * var(--card-padding));+ height: calc(var(--card-line-height) * 1em + 2 * var(--card-padding));+}+.board-view-container .board-note.editing textarea,.board-view-container .board-new-item textarea.form-control {background: transparent;@@ -538,7 +545,9 @@ body.mobile .board-view-container .board-add-column {}.board-new-item {- padding: 0.25em 0.5em;+ /* The same box the editor it opens into has, so clicking it changes nothing but its content. */+ padding: var(--card-padding);+ line-height: var(--card-line-height);border-radius: 5px;color: var(--muted-text-color);cursor: pointer;diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsxindex 640974bc49..60fae8aff2 100644--- a/apps/client/src/widgets/collections/board/index.spec.tsx+++ b/apps/client/src/widgets/collections/board/index.spec.tsx@@ -1171,7 +1171,7 @@ describe("Board column rename", () => {* scrolled to and faded in rather than appearing wherever the reader is not looking.*/it("reveals the card the editor just made", async () => {- const { container } = await setup();+ const { note, container } = await setup();const card = container.querySelector<HTMLElement>(".board-note");const noteId = card?.getAttribute("data-note-id");const column = card?.closest<HTMLElement>(".board-column");@@ -1203,6 +1203,31 @@ describe("Board column rename", () => {expect(card.classList.contains("appearing")).toBe(true);expect(content.scrollTop).toBe(500);+ // Shown once: the card stays the one just made, and a redraw of the column must not play+ // the reveal again.+ await act(async () => {+ card.dispatchEvent(new AnimationEvent("animationend", {+ animationName: "board-card-appear", bubbles: true+ }));+ await flush();+ });+ expect(card.classList.contains("appearing")).toBe(false);++ await act(async () => {+ render(+ <ParentComponent.Provider value={new Component()}>+ <Harness+ note={note}+ noteIds={[ ...note.getChildNoteIds() ]}+ initialConfig={DEFAULT_CONFIG}+ />+ </ParentComponent.Provider>,+ container+ );+ await flush();+ });+ expect(card.classList.contains("appearing")).toBe(false);+// The cards that were already there are left alone.const others = [ ...container.querySelectorAll(".board-note") ].filter(other => other !== card);