From 1325a746c955450d1341975dd8fef627fd515059 Mon Sep 17 00:00:00 2001 From: Hayden Chen Date: Wed, 23 Mar 2022 19:15:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 33 +++++++++++--- src/components/Checkbox.tsx | 17 +++++++ src/components/Sidebar.tsx | 88 +++++++++++++++++++++++++++++-------- src/index.css | 38 ++++++++++++++++ 4 files changed, 150 insertions(+), 26 deletions(-) create mode 100644 src/components/Checkbox.tsx diff --git a/src/App.tsx b/src/App.tsx index 29952705..1c60121d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useEffect, useMemo, useRef, useState } from 'react' import Calendar, { ISchedule } from 'tui-calendar' import { Button, Modal, Select, Tooltip } from 'antd' import { LeftOutlined, RightOutlined, SettingOutlined, ReloadOutlined, FullscreenOutlined, FullscreenExitOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons' @@ -11,7 +11,7 @@ import ModifySchedule from './components/ModifySchedule' import type { IScheduleValue } from './components/ModifySchedule' import dayjs, { Dayjs } from 'dayjs' import { getSchedules } from './util/schedule' -import { ISettingsForm } from './util/type' +import { ICustomCalendar, ISettingsForm } from './util/type' import { updateBlock } from './util/logseq' import { getDefaultCalendarOptions, getInitalSettings } from './util/baseInfo' import 'tui-calendar/dist/tui-calendar.css' @@ -23,8 +23,12 @@ const App: React.FC<{ env: string }> = ({ env }) => { const calendarOptions = getDefaultCalendarOptions() + const { calendarList, subscriptionList, logKey } = getInitalSettings() + const enabledCalendarList: ICustomCalendar[] = (logKey?.enabled ? [logKey] : []).concat((calendarList as ICustomCalendar[])?.filter(calendar => calendar.enabled)) + const enabledSubscriptionList: ICustomCalendar[] = subscriptionList ? subscriptionList?.filter(subscription => subscription.enabled) : [] + const [isFullScreen, setIsFullScreen] = useState(false) - const [isFold, setIsFold] = useState(false) + const [isFold, setIsFold] = useState(true) const [currentView, setCurrentView] = useState(logseq.settings?.defaultView || 'month') const [showDate, setShowDate] = useState() const [showExportWeekly, setShowExportWeekly] = useState(Boolean(logseq.settings?.logKey?.enabled) && logseq.settings?.defaultView === 'week') @@ -176,6 +180,17 @@ const App: React.FC<{ env: string }> = ({ env }) => { logseq.hideMainUI() } } + const onShowCalendarChange = (showCalendarList: string[]) => { + const enabledCalendarIds = enabledCalendarList.concat(enabledSubscriptionList)?.map(calendar => calendar.id) + + enabledCalendarIds.forEach(calendarId => { + if (showCalendarList.includes(calendarId)) { + calendarRef.current?.toggleSchedules(calendarId, false) + } else { + calendarRef.current?.toggleSchedules(calendarId, true) + } + }) + } useEffect(() => { managePluginTheme() @@ -284,7 +299,7 @@ const App: React.FC<{ env: string }> = ({ env }) => {
-