From a65d2a1bbab6fb15f1147623f157df768bdcddca Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 4 Dec 2025 21:24:25 +0200 Subject: [PATCH] chore(react/launch_bar): reintroduce year selector --- apps/client/src/widgets/buttons/calendar.ts | 26 ------------------- .../src/widgets/launch_bar/CalendarWidget.css | 4 +++ .../src/widgets/launch_bar/CalendarWidget.tsx | 26 +++++++++++++++++-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/client/src/widgets/buttons/calendar.ts b/apps/client/src/widgets/buttons/calendar.ts index 22a62e193..731678cd1 100644 --- a/apps/client/src/widgets/buttons/calendar.ts +++ b/apps/client/src/widgets/buttons/calendar.ts @@ -10,32 +10,6 @@ import type { EventData } from "../../components/app_context.js"; import { dayjs, type Dayjs } from "@triliumnext/commons"; import type { AttributeRow, OptionDefinitions } from "@triliumnext/commons"; - - -const DROPDOWN_TPL = ` -
-
-
- - - -
- -
- - - - - -
-
- - -
`; - interface WeekCalculationOptions { firstWeekType: number; minDaysInFirstWeek: number; diff --git a/apps/client/src/widgets/launch_bar/CalendarWidget.css b/apps/client/src/widgets/launch_bar/CalendarWidget.css index 314439846..72249b997 100644 --- a/apps/client/src/widgets/launch_bar/CalendarWidget.css +++ b/apps/client/src/widgets/launch_bar/CalendarWidget.css @@ -174,4 +174,8 @@ background-color: var(--hover-item-background-color); color: var(--hover-item-text-color); text-decoration: underline; +} + +.calendar-dropdown-widget .form-control { + padding: 0; } \ No newline at end of file diff --git a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx index cda7b8444..f1cdfe20b 100644 --- a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx +++ b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx @@ -9,6 +9,7 @@ import ActionButton from "../react/ActionButton"; import Dropdown from "../react/Dropdown"; import { t } from "../../services/i18n"; import FormDropdownList from "../react/FormDropdownList"; +import FormTextBox from "../react/FormTextBox"; const MONTHS = [ t("calendar.january"), @@ -60,6 +61,7 @@ function CalendarHeader(props: CalendarHeaderProps) { return (
+
) } @@ -70,7 +72,6 @@ function CalendarMonthSelector({ date, setDate }: CalendarHeaderProps) { index: index.toString(), text }))) ), []); - console.log("Got months ", months); return (
@@ -87,9 +88,30 @@ function CalendarMonthSelector({ date, setDate }: CalendarHeaderProps) { ); } +function CalendarYearSelector({ date, setDate }: CalendarHeaderProps) { + return ( +
+ + { + const year = parseInt(newValue, 10); + if (!Number.isNaN(year)) { + setDate(date.set("year", year)); + } + }} + data-calendar-input="year" + /> + +
+ ) +} + function AdjustDateButton({ date, setDate, unit, direction }: CalendarHeaderProps & { direction: "prev" | "next", - unit: "month" + unit: "month" | "year" }) { return (