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): stand the all-day toggle and the repeats on one line
Elian Doranf509a409dee5
diff --git a/apps/client/src/widgets/collections/calendar/DetailDock.tsx b/apps/client/src/widgets/collections/calendar/DetailDock.tsxindex d1f384bad2..5649406201 100644--- a/apps/client/src/widgets/collections/calendar/DetailDock.tsx+++ b/apps/client/src/widgets/collections/calendar/DetailDock.tsx@@ -141,8 +141,10 @@ function DockContent({ note, parentNote, isEditable, onClose }: {notes are days, and a day neither moves nor recurs. */}{isEditable && (<EventFieldList>- <EventDatesEditor note={note} />- <RecurrenceEditor note={note} />+ {/* The repeats field is handed to the dates editor to stand beside its+ all-day switch, the two being the one line of shape-of-the-event+ switches (see EventDatesEditor). */}+ <EventDatesEditor note={note} repeats={<RecurrenceEditor note={note} />} /></EventFieldList>)}diff --git a/apps/client/src/widgets/collections/calendar/EventDatesEditor.css b/apps/client/src/widgets/collections/calendar/EventDatesEditor.cssindex 41564e3c0e..2ced0daf54 100644--- a/apps/client/src/widgets/collections/calendar/EventDatesEditor.css+++ b/apps/client/src/widgets/collections/calendar/EventDatesEditor.css@@ -1,3 +1,12 @@+/* The toggle stood at the height of the control beside it, so the row's two fields meet on one+ line; the toggle itself is the app's own (see FormToggle). */+.calendar-all-day-switch {+ display: flex;+ align-items: center;+ flex: 1;+ min-height: 2em;+}+/* A range said in one line — the days an event spans, or the hours within its day: the two endsshare the row evenly, the dash between them taking only its own width. */.calendar-event-range {diff --git a/apps/client/src/widgets/collections/calendar/EventDatesEditor.tsx b/apps/client/src/widgets/collections/calendar/EventDatesEditor.tsxindex 7bb04d953a..9f1d6bf1dd 100644--- a/apps/client/src/widgets/collections/calendar/EventDatesEditor.tsx+++ b/apps/client/src/widgets/collections/calendar/EventDatesEditor.tsx@@ -1,13 +1,14 @@import "./EventDatesEditor.css";+import { ComponentChildren } from "preact";import { useEffect, useState } from "preact/hooks";import FNote from "../../../entities/fnote";import { t } from "../../../services/i18n";import LabelValueInput from "../../attribute_widgets/label_value_input";-import FormCheckbox from "../../react/FormCheckbox";+import FormToggle from "../../react/FormToggle";import { useNoteLabel, useUniqueName } from "../../react/hooks";-import { EventField, EventFieldControls } from "./EventField";+import { EventField, EventFieldControls, EventFieldRow } from "./EventField";/*** Edits when the event happens, through the date and time labels the calendar draws it by (see@@ -18,12 +19,18 @@ import { EventField, EventFieldControls } from "./EventField";** Only the stock label names, as the dock reads only those (see EVENT_LABELS in DetailDock.tsx).*/-export default function EventDatesEditor({ note }: { note: FNote }) {+export default function EventDatesEditor({ note, repeats }: {+ note: FNote;+ /** The repeats field, handed in to stand beside the all-day switch: how the event repeats+ * belongs to the recurrence editor, but the room next to the switch is this editor's to give. */+ repeats?: ComponentChildren;+}) {const [ startDate, setStartDate ] = useNoteLabel(note, "startDate");const [ endDate, setEndDate ] = useNoteLabel(note, "endDate");const [ startTime, setStartTime ] = useNoteLabel(note, "startTime");const [ endTime, setEndTime ] = useNoteLabel(note, "endTime");const startDateId = useUniqueName("event-start-date");+ const allDayId = useUniqueName("event-all-day");// All day is the absence of a start time, which is how the event builder reads it too. Held// locally so the switch answers the press at once — the labels the press writes come back only@@ -49,11 +56,22 @@ export default function EventDatesEditor({ note }: { note: FNote }) {return (<>- <FormCheckbox- label={t("calendar.dates.all_day")}- currentValue={allDay}- onChange={toggleAllDay}- />+ {/* The two shape-of-the-event switches share the first line: whether it takes the whole+ day, and whether it comes back. The app's own toggle (see the revisions dialog),+ nameless because the field's name speaks for it — a switch rather than a checkbox,+ as it reads as the mode flip it is. */}+ <EventFieldRow>+ <EventField name={t("calendar.dates.all_day")} htmlFor={allDayId}>+ <div className="calendar-all-day-switch">+ <FormToggle+ id={allDayId}+ currentValue={allDay}+ onChange={toggleAllDay}+ />+ </div>+ </EventField>+ {repeats}+ </EventFieldRow>{/* One line whichever the shape: the day, or the days it spans. */}<EventField name={t("calendar.dates.date")} htmlFor={startDateId}>diff --git a/apps/client/src/widgets/collections/calendar/EventField.css b/apps/client/src/widgets/collections/calendar/EventField.cssindex 5e0b50fa2d..f1cb8f1ed9 100644--- a/apps/client/src/widgets/collections/calendar/EventField.css+++ b/apps/client/src/widgets/collections/calendar/EventField.css@@ -9,6 +9,17 @@gap: 4px;}+ /* Fields sharing one line, splitting it evenly whatever each holds. */+ .calendar-event-field-row {+ display: flex;+ gap: 10px;++ > * {+ flex: 1 1 0;+ min-width: 0;+ }+ }+/* Faded as the promoted grid fades its labels (see theme-next/shell.css), so the event's ownfields and the note's promoted ones read as one form when they stand in the same dock. */.calendar-event-field-name {diff --git a/apps/client/src/widgets/collections/calendar/EventField.tsx b/apps/client/src/widgets/collections/calendar/EventField.tsxindex c1d4f89ab4..0afa8cf774 100644--- a/apps/client/src/widgets/collections/calendar/EventField.tsx+++ b/apps/client/src/widgets/collections/calendar/EventField.tsx@@ -32,6 +32,14 @@ export function EventField({ name, htmlFor, children }: {);}+/**+ * Two or more whole fields sharing one line, each with its own name over its own control — for+ * fields short enough that a line apiece would leave the column mostly air.+ */+export function EventFieldRow({ children }: { children: ComponentChildren }) {+ return <div className="calendar-event-field-row">{children}</div>;+}+/*** Controls standing in one line, for a field said as a sentence — "every [2] weeks", "after [10]* times" — rather than as a single box.