Skip to content

Build your personal knowledge base with Trilium Notes

feat(calendar): head the event card with its toolbar

Elian Doran4bfe950e0319
diff --git a/apps/client/src/widgets/EmbeddedNotePane.css b/apps/client/src/widgets/EmbeddedNotePane.css
index 4e7e504a95..ffeb7401e6 100644
--- a/apps/client/src/widgets/EmbeddedNotePane.css
+++ b/apps/client/src/widgets/EmbeddedNotePane.css
@@ -23,15 +23,15 @@
.promoted-attributes-widget:not(:has(.promoted-attribute-cell)) {
display: none;
}
+}
- .tn-embedded-note-actions {
- display: flex;
- align-items: center;
- gap: 4px;
+.tn-embedded-note-actions {
+ display: flex;
+ align-items: center;
+ gap: 4px;
- .tn-embedded-note-color {
- margin-inline-start: auto;
- }
+ .tn-embedded-note-color {
+ margin-inline-start: auto;
}
}
@@ -68,7 +68,7 @@
}
}
-:root .tn-embedded-note-pane .tn-embedded-note-remove.icon-action {
+:root .tn-embedded-note-actions .tn-embedded-note-remove.icon-action {
color: var(--dropdown-item-icon-destructive-color);
}
diff --git a/apps/client/src/widgets/collections/calendar/EventPopover.css b/apps/client/src/widgets/collections/calendar/EventPopover.css
index d0e2836b4e..0af700435d 100644
--- a/apps/client/src/widgets/collections/calendar/EventPopover.css
+++ b/apps/client/src/widgets/collections/calendar/EventPopover.css
@@ -25,12 +25,23 @@
.calendar-event-popover-header {
display: flex;
- align-items: center;
+ flex-direction: column;
gap: 4px;
- padding: 4px 9px;
+ padding: 4px 9px 8px;
border-bottom: 1px solid var(--main-border-color);
flex-shrink: 0;
+ /* Lines the toolbar up with the body's fields, whose padding is 1px wider. */
+ > .tn-embedded-note-actions {
+ padding-inline: 1px;
+ }
+ }
+
+ .calendar-event-popover-title {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+
> .title-row {
flex: 1;
min-width: 0;
diff --git a/apps/client/src/widgets/collections/calendar/EventPopover.tsx b/apps/client/src/widgets/collections/calendar/EventPopover.tsx
index b45fbe7c75..25ef2a6411 100644
--- a/apps/client/src/widgets/collections/calendar/EventPopover.tsx
+++ b/apps/client/src/widgets/collections/calendar/EventPopover.tsx
@@ -1,6 +1,7 @@
import "./EventPopover.css";
import clsx from "clsx";
+import { ComponentChildren } from "preact";
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import FNote from "../../../entities/fnote";
@@ -209,12 +210,9 @@ function EventSheet({ note, parentNote, isEditable, onClose, onFollowLink }: {
show={shown}
onHidden={onClose}
>
- <EventDetailsBody
- note={note}
- parentNote={parentNote}
- isEditable={isEditable}
- onClose={() => setShown(false)}
- />
+ <EventDetailsBody note={note} isEditable={isEditable}>
+ <EventActions note={note} parentNote={parentNote} isEditable={isEditable} onClose={() => setShown(false)} />
+ </EventDetailsBody>
</Modal>
);
}
@@ -244,40 +242,45 @@ function EventDetails({ note, parentNote, isEditable, maximized, setMaximized, o
return (
<div className="calendar-event-popover-inner" ref={innerRef}>
+ {/* The toolbar heads the card with the title, so it stays in view while the body
+ scrolls. */}
<div className="calendar-event-popover-header">
- <TitleRow compact />
- {/* A sheet is offered no maximize: it already has the whole screen to grow into. */}
- <MaximizeAction
- icon={maximized ? "bx bx-collapse-alt" : "bx bx-expand-alt"}
- text={maximized ? t("calendar.restore_details") : t("calendar.expand_details")}
- onClick={() => setMaximized(!maximized)}
- />
- <ActionButton
- icon="bx bx-x"
- text={t("calendar.close_details")}
- onClick={onClose}
- />
+ <div className="calendar-event-popover-title">
+ <TitleRow compact />
+ {/* A sheet is offered no maximize: it already has the whole screen to grow into. */}
+ <MaximizeAction
+ icon={maximized ? "bx bx-collapse-alt" : "bx bx-expand-alt"}
+ text={maximized ? t("calendar.restore_details") : t("calendar.expand_details")}
+ onClick={() => setMaximized(!maximized)}
+ />
+ <ActionButton
+ icon="bx bx-x"
+ text={t("calendar.close_details")}
+ onClick={onClose}
+ />
+ </div>
+ <EventActions note={note} parentNote={parentNote} isEditable={isEditable} onClose={onClose} />
</div>
- <EventDetailsBody note={note} parentNote={parentNote} isEditable={isEditable} maximized={maximized} onClose={onClose} />
+ <EventDetailsBody note={note} isEditable={isEditable} maximized={maximized} />
</div>
);
}
/**
- * The event itself, under whatever heads it: what can be done with it, its own fields, the note's
- * promoted attributes and the note. Shared by the two shells, which differ only in what they put
- * around this and how they are dismissed.
+ * The event itself, under whatever heads it: its own fields, the note's promoted attributes and
+ * the note. Shared by the two shells, which differ only in what they put around this and how they
+ * are dismissed. The popover puts {@link EventActions} in its header; the sheet passes them as
+ * `children`, above the fields.
*/
-function EventDetailsBody({ note, parentNote, isEditable, maximized, onClose }: {
+function EventDetailsBody({ note, isEditable, maximized, children }: {
note: FNote;
- parentNote: FNote;
isEditable: boolean;
+ children?: ComponentChildren;
/** 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
// them: the dates the calendar draws the event by and the recurrence — under the stock names
@@ -286,30 +289,7 @@ function EventDetailsBody({ note, parentNote, isEditable, maximized, onClose }:
return (
<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 (see
- OpenNoteActions), then the ways of changing it — left out rather than disabled
- where the calendar may not be edited, as the geo pane leaves them out. */}
- <EmbeddedNoteActions>
- <OpenNoteActions note={note} />
-
- {isEditable && <>
- {/* Named for the chip it dresses, the colour it sets being worn everywhere
- the note shows (see NoteColorPicker). */}
- <NoteColorAction note={note} title={t("calendar_view.event_color")} />
-
- <ActionButton
- className="tn-embedded-note-remove"
- icon="bx bx-trash"
- text={t("calendar_view.remove_from_calendar")}
- // Whether the note goes with its event is asked before anything
- // happens, the two being different wishes. Closed by hand where
- // something was done: a removed event is still a note of the
- // collection, so no watcher stands the popover down.
- onClick={() => void removeFromCalendar(note, parentNote)
- .then((removed) => removed && onClose())}
- />
- </>}
- </EmbeddedNoteActions>
+ {children}
{/* The event's own fields — when it happens, how it repeats — which are ways of
changing it, so they go where the calendar may be edited: a calendar root's day
@@ -329,6 +309,42 @@ function EventDetailsBody({ note, parentNote, isEditable, maximized, onClose }:
);
}
+/**
+ * The toolbar of an event: the ways of opening its note (see OpenNoteActions), then the ways of
+ * changing it, left out rather than disabled where the calendar can't be edited, as the geo pane
+ * leaves them out.
+ */
+function EventActions({ note, parentNote, isEditable, onClose }: {
+ note: FNote;
+ parentNote: FNote;
+ isEditable: boolean;
+ onClose(): void;
+}) {
+ return (
+ <EmbeddedNoteActions>
+ <OpenNoteActions note={note} />
+
+ {isEditable && <>
+ {/* Named for the chip it dresses, the colour it sets being worn everywhere
+ the note shows (see NoteColorPicker). */}
+ <NoteColorAction note={note} title={t("calendar_view.event_color")} />
+
+ <ActionButton
+ className="tn-embedded-note-remove"
+ icon="bx bx-trash"
+ text={t("calendar_view.remove_from_calendar")}
+ // Whether the note goes with its event is asked before anything
+ // happens, the two being different wishes. Closed by hand where
+ // something was done: a removed event is still a note of the
+ // collection, so no watcher stands the popover down.
+ onClick={() => void removeFromCalendar(note, parentNote)
+ .then((removed) => removed && onClose())}
+ />
+ </>}
+ </EmbeddedNoteActions>
+ );
+}
+
/**
* Where the popover stands: beside the event's own chip, read back off the grid by the note id the
* chips are tagged with (see eventDidMount in index.tsx). An event crossing rows draws a chip per