Skip to content

Build your personal knowledge base with Trilium Notes

fix(calendar): give event chips a grey body and a dark leading bar

Elian Doran4d80d6e70416
diff --git a/apps/client/src/widgets/collections/calendar/index.css b/apps/client/src/widgets/collections/calendar/index.css
index a4fdd802bc..c4a133d957 100644
--- a/apps/client/src/widgets/collections/calendar/index.css
+++ b/apps/client/src/widgets/collections/calendar/index.css
@@ -128,26 +128,33 @@
font-weight: 500;
}
-.calendar-view a.fc-timegrid-event,
-.calendar-view a.fc-daygrid-event {
- --border-color: transparent;
-
- border: 2px solid;
- border-left-width: 4px;
- border-color: var(--border-color) var(--border-color) var(--border-color)
- var(--fc-event-text-color) !important;
- background: var(--fc-event-bg-color) !important;
-
- padding-left: 8px;
+/*
+ * Forma draws a chip out of a single accent colour: a solid bar down its leading edge, and a 30%
+ * tint of that same colour for the body. Trilium's chip is a pair rather than a derivation — a
+ * black bar over a flat #eaeaea body — so the two are split. The accent is handed to the bar
+ * through the palette's --fc-forma-event, and the body is stated here, on a class eventClass puts
+ * on every chip.
+ */
+.calendar-view .calendar-event {
+ background: var(--calendar-coll-event-background-color, var(--accented-background-color));
}
-.calendar-view .fc-timegrid-event.with-hue,
-.calendar-view .fc-daygrid-event.with-hue {
- --fc-event-text-color: var(--custom-color);
-
- --fc-event-bg-color: hsl(var(--custom-color-hue),
+/*
+ * A note carrying a colour of its own says both: the bar takes the colour, the body a pale wash of
+ * the same hue. Said as border-color rather than through --fc-event-color, which FullCalendar
+ * writes inline on the chip and a stylesheet therefore cannot reach.
+ */
+.calendar-view .calendar-event.with-hue {
+ border-color: var(--custom-color);
+ background: hsl(var(--custom-color-hue),
var(--calendar-coll-event-background-saturation, 80%),
- var(--calendar-coll-event-background-lightness, 95%)) !important;
+ var(--calendar-coll-event-background-lightness, 95%));
+}
+
+/* Flat body and all, a chip still has to answer the pointer; Forma's own hover tint is what the
+ rule above overrides. */
+.calendar-view .calendar-event:hover {
+ filter: var(--calendar-coll-event-hover-filter, none);
}
.calendar-view a.fc-timegrid-event:focus-visible,
diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsx
index cc08cbe9cd..058bbc1825 100644
--- a/apps/client/src/widgets/collections/calendar/index.tsx
+++ b/apps/client/src/widgets/collections/calendar/index.tsx
@@ -9,6 +9,7 @@ import "./palette.css";
import "./index.css";
import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
+import clsx from "clsx";
import { Calendar as FullCalendar, DateClickInfo, DateSelectInfo, EventChangeInfo, EventClickInfo, EventDisplayInfo, EventSourceFuncInfo, LocaleInput, MountInfo, PluginInput } from "fullcalendar";
import { RefObject } from "preact";
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
@@ -341,9 +342,14 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarVi
// preview would, at full length and editable, and the two are drawn beside the
// same chip. The geo map's marker previews keep clear of its detail pane the same
// way (see Tooltips there).
- eventClass={(arg) => selection && "noteId" in selection && arg.event.extendedProps.noteId === selection.noteId
- ? "calendar-event-selected no-tooltip-preview"
- : undefined}
+ eventClass={(arg) => clsx(
+ // What the chip's own colouring hangs off, Forma's single-accent chip not
+ // being able to say Trilium's pair of a dark bar over a flat body (see
+ // index.css).
+ "calendar-event",
+ selection && "noteId" in selection && arg.event.extendedProps.noteId === selection.noteId
+ && "calendar-event-selected no-tooltip-preview"
+ )}
eventDidMount={eventDidMount}
viewDidMount={({ view }) => {
if (initialView.current !== view.type) {
diff --git a/apps/client/src/widgets/collections/calendar/palette.css b/apps/client/src/widgets/collections/calendar/palette.css
index 2c252e095c..0c9a1bc4ff 100644
--- a/apps/client/src/widgets/collections/calendar/palette.css
+++ b/apps/client/src/widgets/collections/calendar/palette.css
@@ -52,8 +52,13 @@
* Events, read through the same calendar-specific variables the collection already honours so
* that a theme customising those keeps its say. Only the Next themes define them, hence the
* fallbacks for the legacy pair.
+ *
+ * The accent is the *text* colour, not the background one: Forma spends this on the solid bar
+ * down a chip's leading edge, so handing it Trilium's already-pale #eaeaea left the bar all but
+ * invisible. The body it derives from the same colour is overridden in index.css, Trilium's
+ * chip being a flat grey rather than a tint of its bar.
*/
- --fc-forma-event: var(--calendar-coll-event-background-color, var(--accented-background-color));
+ --fc-forma-event: var(--calendar-coll-event-text-color, var(--main-text-color));
--fc-forma-event-contrast: var(--calendar-coll-event-text-color, var(--main-text-color));
--fc-forma-background-event: var(--link-color);