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
feat(embedded-note): lay a grown pane's promoted fields out as a note's
Elian Doran04b701baee0b
diff --git a/apps/client/src/widgets/EmbeddedNotePane.css b/apps/client/src/widgets/EmbeddedNotePane.cssindex 10d4642afd..d66c7629a7 100644--- a/apps/client/src/widgets/EmbeddedNotePane.css+++ b/apps/client/src/widgets/EmbeddedNotePane.css@@ -1,53 +1,48 @@-/*- * The body of a pane holding an embedded note (see EmbeddedNotePane.tsx): the note's own widgets,- * laid out for a third of the width they are written for. The class goes on the element that holds- * them — the geo pane's body, the calendar dock's body — which brings the column they stand in;- * whatever else that element is (its padding, whether it scrolls) stays with its own class.- */.tn-embedded-note-pane {display: flex;flex-direction: column;gap: 10px;- /*- * The note fills the rest of the pane rather than ending where its content does, so that- * clicking below a short note still puts the caret in it — as it does in a note of its own.- */.note-detail {flex: 1;- /* Written for a note split, where the split hands it one; there is no split here, and an- unset `--max-content-width` would leave `max-width` invalid rather than absent. */max-width: none;- /* A floor rather than the 0 a flex item needs to scroll its own content: the fields above- it are as many as the note asks for, and without one they would squeeze the note out of- the pane instead of the body scrolling. Above the floor a long note still scrolls within- itself. */min-height: 120px;}- /*- * The note's promoted fields. A field reads across one line — its name, then what it holds —- * and stays that way here; what changes is the row they stand in. Across a note they stand side- * by side, each as wide as what it holds; in the pane there is room for one, so they come down- * the column instead, each taking the whole width.- */.promoted-attributes-container {- flex-direction: column;- flex-wrap: nowrap;- align-items: stretch;gap: 8px;margin: 0;- /* The body of the pane is the one thing that scrolls; a scroller inside it would take the- wheel off whichever of the two the pointer happened to be over. */max-height: none;overflow: visible;}.promoted-attribute-cell {margin: 0;+ }++ .promoted-attributes-widget:not(:has(.promoted-attribute-cell)) {+ display: none;+ }++ .tn-embedded-note-actions {+ display: flex;+ align-items: center;+ gap: 4px;++ .tn-embedded-note-color {+ margin-inline-start: auto;+ }+ }+}++.tn-embedded-note-pane:not(.tn-embedded-note-pane-wide) {+ .promoted-attributes-container {+ flex-direction: column;+ flex-wrap: nowrap;+ align-items: stretch;+ }- /* The field takes whatever its name leaves, rather than the width of what it holds: a card- standing alone on its line has that room whether it needs it or not. */+ .promoted-attribute-cell {> .input-group,> .promoted-attribute-values {flex: 1;@@ -55,15 +50,11 @@margin-inline-start: 8px;}- /* Both are given a width in ems, which is a card's own width where cards stand side by- side. Marked as the theme marks them, there being no other way past it. */input[type="text"],input[type="number"] {width: auto !important;}- /* A name longer than the pane is cut short rather than pushing the field it names off the- end. */> label {min-width: 0;overflow: hidden;@@ -75,42 +66,12 @@padding: 0;}}-- /* The widget stands whether the note promotes anything or not, and an empty one would still- take its share of the gap between what stands above and below it. */- .promoted-attributes-widget:not(:has(.promoted-attribute-cell)) {- display: none;- }-- /* The row of actions at the head of the pane (see EmbeddedNoteActions). */- .tn-embedded-note-actions {- display: flex;- align-items: center;- gap: 4px;-- /* Those that write rather than read stand apart from the ones being reached for repeatedly,- so the pointer cannot land on one of them by being a moment early. The gap falls before- the first of them, which is the colour: they are drawn together or not at all, a- read-only host having none of them. */- .tn-embedded-note-color {- margin-inline-start: auto;- }- }}:root .tn-embedded-note-pane .tn-embedded-note-remove.icon-action {color: var(--dropdown-item-icon-destructive-color);}-/*- * The maximize button (see MaximizeToQuickEditAction), dressed as the X it stands beside: the- * compact round surface the theme reserves for close crosses (`.icon-action.bx-x` in- * theme-next/forms.css), minus the red close hover. The icon keeps the stock ratio rather than the- * X's 0.8 — the expand glyph fills its em box where the X's does not, so the stock size is what- * stands at the X's visual weight. Stated from `:root` and with the icon's own class doubled on,- * so as to outweigh the theme's blanket `border-radius` whichever way the stylesheets are ordered- * (the bargain the attribute list's delete button strikes; see AttributeList.css).- */:root .icon-action.bx-expand-alt.tn-embedded-note-maximize {--icon-button-size: 24px;diff --git a/apps/client/src/widgets/collections/calendar/EventPopover.tsx b/apps/client/src/widgets/collections/calendar/EventPopover.tsxindex e6857db4c1..202f2a499a 100644--- a/apps/client/src/widgets/collections/calendar/EventPopover.tsx+++ b/apps/client/src/widgets/collections/calendar/EventPopover.tsx@@ -1,5 +1,6 @@import "./EventPopover.css";+import clsx from "clsx";import { useCallback, useEffect, useRef, useState } from "preact/hooks";import FNote from "../../../entities/fnote";@@ -248,7 +249,7 @@ function EventDetails({ note, parentNote, isEditable, maximized, setMaximized, o/></div>- <EventDetailsBody note={note} parentNote={parentNote} isEditable={isEditable} onClose={onClose} />+ <EventDetailsBody note={note} parentNote={parentNote} isEditable={isEditable} maximized={maximized} onClose={onClose} /></div>);}@@ -258,10 +259,14 @@ function EventDetails({ note, parentNote, isEditable, maximized, setMaximized, o* promoted attributes and the note. Shared by the two shells, which differ only in what they put* around this and how they are dismissed.*/-function EventDetailsBody({ note, parentNote, isEditable, onClose }: {+function EventDetailsBody({ note, parentNote, isEditable, maximized, onClose }: {note: FNote;parentNote: FNote;isEditable: boolean;+ /** The card fills the window, so what it holds is laid out for a note's width rather than a+ * card's (see `tn-embedded-note-pane-wide` in EmbeddedNotePane.css). Never a sheet's, which is+ * a phone's whole screen and still only one field wide. */+ maximized?: boolean;onClose(): void;}) {// The labels the body's own fields already speak for, so the promoted grid does not repeat@@ -270,7 +275,7 @@ function EventDetailsBody({ note, parentNote, isEditable, onClose }: {const eventLabels = useEventLabelOmissions(note);return (- <div className="calendar-event-popover-body tn-embedded-note-pane">+ <div className={clsx("calendar-event-popover-body tn-embedded-note-pane", maximized && "tn-embedded-note-pane-wide")}>{/* What can be done with the event: the ways of opening its note (seeOpenNoteActions), then the ways of changing it — left out rather than disabledwhere the calendar may not be edited, as the geo pane leaves them out. */}diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsxindex 978f13d380..d15130b901 100644--- a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx@@ -690,8 +690,15 @@ describe("DetailPane", () => {pane()?.querySelector<HTMLButtonElement>(".tn-overlay-panel-header-actions button.tn-embedded-note-maximize")?.click();});+ const body = () => pane()?.querySelector(".geo-detail-pane-body");+ expect(body()?.classList.contains("tn-embedded-note-pane-wide")).toBe(false);+await maximize();expect(pane()?.classList.contains("maximized")).toBe(true);+ // Having a note's width, what it holds is laid out for one: the promoted fields+ // stand side by side as the quick editor shows them, rather than one to a line+ // (see `tn-embedded-note-pane-wide` in EmbeddedNotePane.css).+ expect(body()?.classList.contains("tn-embedded-note-pane-wide")).toBe(true);// The same editor, never having been away.expect(pane()?.querySelector(".note-detail-stub")).toBe(editorEl);// Neither a hand-over to another surface nor a dismissal: the pane is still up, anddiff --git a/apps/client/src/widgets/collections/geomap/DetailPane.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.tsxindex 25d6a3f9a5..7299796c6a 100644--- a/apps/client/src/widgets/collections/geomap/DetailPane.tsx+++ b/apps/client/src/widgets/collections/geomap/DetailPane.tsx@@ -443,7 +443,9 @@ function MarkerDetails({ note, parentNote, isReadOnly, maximized, onMaximizedCha}close={{ text: t("geo-map.close-details"), onClick: onClose }}>- <OverlayPanelBody className="geo-detail-pane-body tn-embedded-note-pane">+ {/* Grown over the map, the pane has a note's width, so what it holds is laid out for one+ (see `tn-embedded-note-pane-wide` in EmbeddedNotePane.css). */}+ <OverlayPanelBody className={clsx("geo-detail-pane-body tn-embedded-note-pane", maximized && "tn-embedded-note-pane-wide")}><MarkerLocation note={note} /><MarkerActions note={note} parentNote={parentNote} isReadOnly={isReadOnly} onRelocate={onRelocate} />