From 4f88221bce91633bbe8283b33fa4c22c9092a9cd Mon Sep 17 00:00:00 2001 From: email Date: Tue, 29 Mar 2022 08:13:15 +0800 Subject: [PATCH] feat: update sidebar style --- web/src/components/MenuBtnsPopup.tsx | 17 ---------- web/src/components/Sidebar.tsx | 47 +++++++++++++++++++++++++--- web/src/components/UserBanner.tsx | 34 +++++--------------- web/src/less/shortcut-list.less | 13 +++----- web/src/less/siderbar.less | 32 +++++++++++++++++-- web/src/less/user-banner.less | 47 +++++++--------------------- web/tailwind.config.js | 13 ++++++++ 7 files changed, 107 insertions(+), 96 deletions(-) diff --git a/web/src/components/MenuBtnsPopup.tsx b/web/src/components/MenuBtnsPopup.tsx index 34ab3be7..0b612f4d 100644 --- a/web/src/components/MenuBtnsPopup.tsx +++ b/web/src/components/MenuBtnsPopup.tsx @@ -1,8 +1,6 @@ import { useEffect, useRef } from "react"; import { locationService, userService } from "../services"; import showAboutSiteDialog from "./AboutSiteDialog"; -import showSettingDialog from "./SettingDialog"; -import showMemoTrashDialog from "./MemoTrashDialog"; import "../less/menu-btns-popup.less"; interface Props { @@ -12,7 +10,6 @@ interface Props { const MenuBtnsPopup: React.FC = (props: Props) => { const { shownStatus, setShownStatus } = props; - const popupElRef = useRef(null); useEffect(() => { @@ -30,14 +27,6 @@ const MenuBtnsPopup: React.FC = (props: Props) => { } }, [shownStatus]); - const handleMyAccountBtnClick = () => { - showSettingDialog(); - }; - - const handleMemosTrashBtnClick = () => { - showMemoTrashDialog(); - }; - const handleAboutBtnClick = () => { showAboutSiteDialog(); }; @@ -50,12 +39,6 @@ const MenuBtnsPopup: React.FC = (props: Props) => { return (
- - diff --git a/web/src/components/Sidebar.tsx b/web/src/components/Sidebar.tsx index 492247b5..b6c09453 100644 --- a/web/src/components/Sidebar.tsx +++ b/web/src/components/Sidebar.tsx @@ -1,19 +1,56 @@ -import { useRef } from "react"; +import { useContext } from "react"; +import appContext from "../stores/appContext"; +import utils from "../helpers/utils"; +import showDailyMemoDiaryDialog from "./DailyMemoDiaryDialog"; +import showSettingDialog from "./SettingDialog"; +import showMemoTrashDialog from "./MemoTrashDialog"; import UserBanner from "./UserBanner"; import ShortcutList from "./ShortcutList"; -import UsageHeatMap from "./UsageHeatMap"; import "../less/siderbar.less"; interface Props {} const Sidebar: React.FC = () => { - const wrapperElRef = useRef(null); + const { + memoState: { memos, tags }, + userState: { user }, + } = useContext(appContext); + const createdDays = user ? Math.ceil((Date.now() - utils.getTimeStampByDate(user.createdAt)) / 1000 / 3600 / 24) : 0; + + const handleMyAccountBtnClick = () => { + showSettingDialog(); + }; + + const handleMemosTrashBtnClick = () => { + showMemoTrashDialog(); + }; return ( -