From 361575ae91749478a37300663ff727577de9a8f3 Mon Sep 17 00:00:00 2001 From: Ozan Tellioglu Date: Sun, 16 Apr 2023 19:12:12 +0200 Subject: [PATCH] Calendar Type Implementation --- src/components/calendar.tsx | 6 +++++- src/settings/settings.ts | 22 ++++++++++++++++++++++ styles.css | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/calendar.tsx b/src/components/calendar.tsx index d1096a9..0c0e20e 100644 --- a/src/components/calendar.tsx +++ b/src/components/calendar.tsx @@ -87,8 +87,10 @@ export default function MyCalendar(params: { plugin: OZCalendarPlugin }) { return null; }; + const fixedCalendarClass = plugin.settings.fixedCalendar ? 'fixed' : ''; + return ( -
+
{ if (props.action === 'next') { diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 9557eed..f3d2a5a 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -6,9 +6,11 @@ export type OpenFileBehaviourType = 'new-tab' | 'new-tab-group' | 'current-tab' export type SortingOption = 'name' | 'name-rev'; export type DateSourceOption = 'filename' | 'yaml'; export type NewNoteDateType = 'current-date' | 'active-date'; +export type CalendarType = 'US' | 'ISO 8601'; export interface OZCalendarPluginSettings { openViewOnStart: boolean; + calendarType: CalendarType; dateSource: DateSourceOption; yamlKey: string; dateFormat: string; @@ -23,6 +25,7 @@ export interface OZCalendarPluginSettings { export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { openViewOnStart: true, + calendarType: 'ISO 8601', dateSource: 'yaml', yamlKey: 'created', dateFormat: 'YYYY-MM-DD hh:mm:ss', @@ -85,6 +88,25 @@ export class OZCalendarPluginSettingsTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName('Calendar Type') + .setDesc( + ` + Select the calendar type to be displayed. While the week in the US type starts from Sunday, + in the ISO 8601 type, the week starts from Monday` + ) + .addDropdown((dropdown) => { + dropdown + .addOption('ISO 8601', 'ISO 8601') + .addOption('US', 'US') + .setValue(this.plugin.settings.calendarType) + .onChange((newValue: CalendarType) => { + this.plugin.settings.calendarType = newValue; + this.plugin.saveSettings(); + this.plugin.calendarForceUpdate(); + }); + }); + new Setting(containerEl) .setName('Open File Behaviour') .setDesc('Select the behaviour you want to have when you click on file name in the calendar view') diff --git a/styles.css b/styles.css index bdefc00..3a1b74c 100644 --- a/styles.css +++ b/styles.css @@ -239,7 +239,7 @@ settings: } .oz-calendar-plugin-view.fixed .react-calendar { - height: 255px; + height: 295px; } .oz-calendar-plugin-view.fixed #oz-calendar-divider {