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(calendar): tint the event card by the note's own colour
Elian Doran7890089a9391
diff --git a/apps/client/src/stylesheets/theme-next-dark.css b/apps/client/src/stylesheets/theme-next-dark.cssindex 27254d3bb5..864c6057dc 100644--- a/apps/client/src/stylesheets/theme-next-dark.css+++ b/apps/client/src/stylesheets/theme-next-dark.css@@ -312,8 +312,10 @@--tooltip-kbd-background: #ffffff32;--tooltip-kbd-border: #00000060;- --note-tooltip-background-color: #3d3d3d;-+ /* Translucent, as the app's other tooltips are: the theme frosts every tooltip+ (`--tooltip-backdrop-filter`), and an opaque colour here is a blur with nothing behind it. */+ --note-tooltip-background-color: #3d3d3dd9;+--help-background-color: var(--menu-background-color);--help-card-background: var(--card-background-color);--help-card-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);@@ -393,7 +395,10 @@ body .todo-list input[type="checkbox"]:not(:checked):before {border-color: var(--muted-text-color) !important;}-.quick-edit-dialog-wrapper.with-hue {+/* The calendar's event shown as a sheet is the same thing the quick editor is — a whole note over+ whatever raised it — so it is tinted by the same colours (see EventPopover.tsx). */+.quick-edit-dialog-wrapper.with-hue,+.calendar-event-sheet.with-hue {--modal-background-color: hsl(var(--custom-color-hue), 8.8%, 11.2%);--modal-border-color: hsl(var(--custom-color-hue), 9.4%, 25.1%);--promoted-attribute-card-background-color: hsl(var(--custom-color-hue), 13.2%, 20.8%);@@ -417,6 +422,8 @@ body .todo-list input[type="checkbox"]:not(:checked):before {.note-split.with-hue,.quick-edit-dialog-wrapper.with-hue,.geo-detail-pane.with-hue,+.calendar-event-popover.with-hue,+.calendar-event-sheet.with-hue,.nested-note-list-item.with-hue,.note-book-card.with-hue .note-book-header,.ck-template-icon.with-hue {@@ -436,7 +443,31 @@ body .todo-list input[type="checkbox"]:not(:checked):before {}.note-tooltip.with-hue {- --tooltip-background-color: hsl(var(--custom-color-hue), 8.8%, 24%);+ --tooltip-background-color: hsl(var(--custom-color-hue), 8.8%, 24%, 0.85);+}++/*+ * The calendar's event card, standing beside its chip. Unlike the sheet and the tooltip this one+ * frosts the grid behind it (see `.tn-popover` in Popover.css), so its tint is stated with the+ * alpha the plain card already carries — an opaque tint would leave the blur nothing to show+ * through, which is the whole of what the card is dressed as.+ *+ * The card grown to the window gives the frosting up, and takes the same tint opaque; so does a+ * card whose blur cannot be had at all (background effects, or a reader who turned them off), both+ * reading the no-backdrop colour.+ */+.calendar-event-popover.with-hue {+ --menu-background-color: hsl(var(--custom-color-hue), 15%, 14%, 0.85);+ --menu-background-color-no-backdrop: hsl(var(--custom-color-hue), 12%, 11.2%);+ --dropdown-border-color: hsl(var(--custom-color-hue), 12%, 26%);+ --promoted-attribute-card-background-color: hsl(var(--custom-color-hue), 13.2%, 20.8%);+}++/* A reader who turned backdrop effects off, which the card must answer here rather than by the swap+ made on the body above: that swap is resolved where it is stated, so what reaches the card is the+ plain opaque colour and not the tinted one the card states on itself. */+body.backdrop-effects-disabled .calendar-event-popover.with-hue {+ --menu-background-color: var(--menu-background-color-no-backdrop);}[data-trilium-task-state] {diff --git a/apps/client/src/stylesheets/theme-next-light.css b/apps/client/src/stylesheets/theme-next-light.cssindex ef476ce3a6..e831b1710c 100644--- a/apps/client/src/stylesheets/theme-next-light.css+++ b/apps/client/src/stylesheets/theme-next-light.css@@ -311,7 +311,9 @@--tooltip-kbd-background: #ffffff32;--tooltip-kbd-border: #00000060;- --note-tooltip-background-color: white;+ /* Translucent, as the app's other tooltips are: the theme frosts every tooltip+ (`--tooltip-backdrop-filter`), and an opaque colour here is a blur with nothing behind it. */+ --note-tooltip-background-color: #ffffffd9;--help-background-color: #fffc;@@ -369,7 +371,10 @@--custom-bg-color: hsl(var(--custom-color-hue), 37%, 89%, 1);}+/* The calendar's event shown as a sheet is the same thing the quick editor is — a whole note over+ whatever raised it — so it is tinted by the same colours (see EventPopover.tsx). */.quick-edit-dialog-wrapper.with-hue,+.calendar-event-sheet.with-hue,.note-tooltip.with-hue {--modal-background-color: hsl(var(--custom-color-hue), 56%, 96%);--modal-border-color: hsl(var(--custom-color-hue), 33%, 41%);@@ -389,6 +394,8 @@.note-split.with-hue,.quick-edit-dialog-wrapper.with-hue,.geo-detail-pane.with-hue,+.calendar-event-popover.with-hue,+.calendar-event-sheet.with-hue,.nested-note-list-item.with-hue,.note-book-card.with-hue .note-book-header,.ck-template-icon.with-hue {@@ -408,7 +415,31 @@}.note-tooltip.with-hue {- --tooltip-background-color: hsl(var(--custom-color-hue), 56%, 96%);+ --tooltip-background-color: hsl(var(--custom-color-hue), 56%, 96%, 0.85);+}++/*+ * The calendar's event card, standing beside its chip. Unlike the sheet and the tooltip this one+ * frosts the grid behind it (see `.tn-popover` in Popover.css), so its tint is stated with the+ * alpha the plain card already carries — an opaque tint would leave the blur nothing to show+ * through, which is the whole of what the card is dressed as.+ *+ * The card grown to the window gives the frosting up, and takes the same tint opaque; so does a+ * card whose blur cannot be had at all (background effects, or a reader who turned them off), both+ * reading the no-backdrop colour.+ */+.calendar-event-popover.with-hue {+ --menu-background-color: hsl(var(--custom-color-hue), 56%, 96%, 0.85);+ --menu-background-color-no-backdrop: hsl(var(--custom-color-hue), 56%, 97%);+ --dropdown-border-color: hsl(var(--custom-color-hue), 30%, 78%);+ --promoted-attribute-card-background-color: hsl(var(--custom-color-hue), 40%, 88%);+}++/* A reader who turned backdrop effects off, which the card must answer here rather than by the swap+ made on the body above: that swap is resolved where it is stated, so what reaches the card is the+ plain opaque colour and not the tinted one the card states on itself. */+body.backdrop-effects-disabled .calendar-event-popover.with-hue {+ --menu-background-color: var(--menu-background-color-no-backdrop);}[data-trilium-task-state] {diff --git a/apps/client/src/widgets/collections/calendar/EventPopover.tsx b/apps/client/src/widgets/collections/calendar/EventPopover.tsxindex 202f2a499a..4a26596da2 100644--- a/apps/client/src/widgets/collections/calendar/EventPopover.tsx+++ b/apps/client/src/widgets/collections/calendar/EventPopover.tsx@@ -11,7 +11,7 @@ import TitleRow from "../../layout/TitleRow";import NoteDetail from "../../NoteDetail";import PromotedAttributes from "../../PromotedAttributes";import ActionButton from "../../react/ActionButton";-import { useLegacyComponentElement, useNote } from "../../react/hooks";+import { useLegacyComponentElement, useNote, useNoteColorClass } from "../../react/hooks";import Modal from "../../react/Modal";import Popover from "../../react/Popover";import { removeFromCalendar } from "./api";@@ -118,6 +118,11 @@ function EventPopoverShell({ note, anchorRect, updateKey, parentNote, isEditableonClose(): void;onFollowLink(noteId: string): boolean;}) {+ // The event's own colour — the one its chip is drawn in — which the card is tinted by (see the+ // `.calendar-event-popover.with-hue` rules in theme-next-{light,dark}.css). Only the hue is+ // taken and only where the note states one, so an uncoloured event keeps the plain card.+ const colorClass = useNoteColorClass(note);+// Escape closes the card whether it stands beside its chip or fills the window, as a press// outside it does and as every dialog in the app answers the key. Being grown is a way the card// is drawn rather than a mode to be let out of, and the maximize is its own way back down.@@ -131,7 +136,7 @@ function EventPopoverShell({ note, anchorRect, updateKey, parentNote, isEditablereturn (<Popover- className="calendar-event-popover"+ className={clsx("calendar-event-popover", colorClass)}placement={glob.isRtl ? "left-start" : "right-start"}getAnchorRect={anchorRect}updateKey={updateKey}@@ -177,6 +182,11 @@ function EventSheet({ note, parentNote, isEditable, onClose, onFollowLink }: {const modalRef = useRef<HTMLDivElement>(null);useLegacyComponentElement(modalRef);+ // Tinted by the event's own colour as the card beside a chip is, and by the same means the+ // quick editor is (see the `.with-hue` rules in theme-next-{light,dark}.css) — a sheet being+ // opaque, it takes the dialog's colours rather than the card's.+ const colorClass = useNoteColorClass(note);+// A link to another event switches the sheet, the calendar behind it turning to the event's// date for when the sheet comes down (see the shared hook).useFollowLinksWithin(modalRef, onFollowLink);@@ -192,7 +202,7 @@ function EventSheet({ note, parentNote, isEditable, onClose, onFollowLink }: {return (<Modal- className="calendar-event-sheet"+ className={clsx("calendar-event-sheet", colorClass)}size="lg"title={<TitleRow />}modalRef={modalRef}