From 4d2667983fd3387e6db76fb05b51dfe376899161 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 5 Aug 2026 09:05:57 +0800 Subject: [PATCH] feat(web): unify navigation in a route-aware sidebar (#6144) --- web/src/components/AboutDialog.tsx | 140 ++++ .../ActivityCalendar/CalendarCell.tsx | 14 +- .../ActivityCalendar/MonthCalendar.tsx | 10 +- .../ActivityCalendar/YearCalendar.tsx | 32 +- .../components/ActivityCalendar/constants.ts | 22 +- web/src/components/ActivityCalendar/utils.ts | 6 +- web/src/components/AppSidebar/AppSidebar.tsx | 682 ++++++++++++++++++ .../components/AppSidebar/QuickFindDialog.tsx | 126 ++++ web/src/components/AppSidebar/SidebarRow.tsx | 39 + .../AppSidebar/SidebarSectionHeader.tsx | 17 + web/src/components/AppSidebar/TagsSection.tsx | 85 +++ web/src/components/AppSidebar/index.ts | 2 + web/src/components/AppSidebar/routes.ts | 16 + .../MemoDetailSidebar/MemoDetailSidebar.tsx | 338 +++------ .../MemoDetailSidebarDrawer.tsx | 34 - .../MemoDetailSidebar/MemoOutline.tsx | 10 +- web/src/components/MemoDetailSidebar/index.ts | 3 +- .../components/MemoExplorer/MemoExplorer.tsx | 87 --- .../MemoExplorer/MemoExplorerDrawer.tsx | 48 -- .../MemoExplorer/ShortcutsSection.tsx | 117 --- .../components/MemoExplorer/TagsSection.tsx | 100 --- web/src/components/MemoExplorer/index.ts | 5 - web/src/components/MemosLogo.tsx | 20 +- web/src/components/MobileHeader.tsx | 46 -- web/src/components/Navigation.tsx | 145 ---- web/src/components/NavigationDrawer.tsx | 38 - web/src/components/SearchBar.tsx | 50 -- .../StatisticsView/MonthNavigator.tsx | 98 +-- .../StatisticsView/StatisticsView.tsx | 19 +- web/src/components/TagTree.tsx | 59 +- web/src/components/UserMenu.tsx | 93 +-- web/src/contexts/AppSidebarContext.tsx | 84 +++ web/src/contexts/GlobalMemoEditorContext.tsx | 62 -- web/src/contexts/MemoFilterContext.tsx | 13 +- web/src/hooks/useAttachmentLibrary.ts | 73 +- web/src/hooks/useDateFilterNavigation.ts | 13 +- web/src/hooks/useFilteredMemoStats.ts | 5 +- web/src/hooks/useMemoFilters.ts | 158 ++-- web/src/layouts/MainLayout.tsx | 96 +-- web/src/layouts/RootLayout.tsx | 41 +- web/src/lib/memo-views.ts | 54 ++ web/src/locales/en.json | 18 +- web/src/locales/zh-Hans.json | 25 +- web/src/locales/zh-Hant.json | 27 +- web/src/pages/About.tsx | 138 +--- web/src/pages/Archived.tsx | 3 +- web/src/pages/Attachments.tsx | 138 ++-- web/src/pages/Explore.tsx | 3 +- web/src/pages/Inboxes.tsx | 32 +- web/src/pages/MemoDetail.tsx | 67 +- web/src/pages/NotFound.tsx | 3 - web/src/pages/PermissionDenied.tsx | 3 - web/src/pages/Setting.tsx | 65 +- web/src/pages/Shortcuts.tsx | 6 +- web/src/pages/UserProfile.tsx | 31 +- web/src/types/statistics.ts | 2 - web/tests/about-page.test.tsx | 86 ++- web/tests/app-sidebar-context.test.tsx | 45 ++ web/tests/app-sidebar-logo.test.tsx | 180 +++++ web/tests/app-sidebar-routes.test.ts | 21 + web/tests/attachment-library-stats.test.ts | 76 ++ .../calendar-cell-empty-clickable.test.tsx | 17 + web/tests/date-filter-navigation.test.tsx | 39 + web/tests/global-memo-editor.test.tsx | 70 -- web/tests/memo-detail-sidebar.test.tsx | 132 ++-- web/tests/memo-filter-context.test.tsx | 45 ++ web/tests/memo-views.test.ts | 93 +++ web/tests/month-navigator.test.tsx | 23 + web/tests/navigation-logo-create.test.tsx | 46 -- web/tests/quick-find.test.ts | 35 + 70 files changed, 2685 insertions(+), 1884 deletions(-) create mode 100644 web/src/components/AboutDialog.tsx create mode 100644 web/src/components/AppSidebar/AppSidebar.tsx create mode 100644 web/src/components/AppSidebar/QuickFindDialog.tsx create mode 100644 web/src/components/AppSidebar/SidebarRow.tsx create mode 100644 web/src/components/AppSidebar/SidebarSectionHeader.tsx create mode 100644 web/src/components/AppSidebar/TagsSection.tsx create mode 100644 web/src/components/AppSidebar/index.ts create mode 100644 web/src/components/AppSidebar/routes.ts delete mode 100644 web/src/components/MemoDetailSidebar/MemoDetailSidebarDrawer.tsx delete mode 100644 web/src/components/MemoExplorer/MemoExplorer.tsx delete mode 100644 web/src/components/MemoExplorer/MemoExplorerDrawer.tsx delete mode 100644 web/src/components/MemoExplorer/ShortcutsSection.tsx delete mode 100644 web/src/components/MemoExplorer/TagsSection.tsx delete mode 100644 web/src/components/MemoExplorer/index.ts delete mode 100644 web/src/components/MobileHeader.tsx delete mode 100644 web/src/components/Navigation.tsx delete mode 100644 web/src/components/NavigationDrawer.tsx delete mode 100644 web/src/components/SearchBar.tsx create mode 100644 web/src/contexts/AppSidebarContext.tsx delete mode 100644 web/src/contexts/GlobalMemoEditorContext.tsx create mode 100644 web/src/lib/memo-views.ts create mode 100644 web/tests/app-sidebar-context.test.tsx create mode 100644 web/tests/app-sidebar-logo.test.tsx create mode 100644 web/tests/app-sidebar-routes.test.ts create mode 100644 web/tests/attachment-library-stats.test.ts create mode 100644 web/tests/date-filter-navigation.test.tsx delete mode 100644 web/tests/global-memo-editor.test.tsx create mode 100644 web/tests/memo-filter-context.test.tsx create mode 100644 web/tests/memo-views.test.ts create mode 100644 web/tests/month-navigator.test.tsx delete mode 100644 web/tests/navigation-logo-create.test.tsx create mode 100644 web/tests/quick-find.test.ts diff --git a/web/src/components/AboutDialog.tsx b/web/src/components/AboutDialog.tsx new file mode 100644 index 00000000..fb12a783 --- /dev/null +++ b/web/src/components/AboutDialog.tsx @@ -0,0 +1,140 @@ +import { ExternalLinkIcon, ScissorsIcon } from "lucide-react"; +import { Badge } from "@/components/ui/badge"; +import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; +import { useInstance } from "@/contexts/InstanceContext"; +import { WEB_CLIPPER_URL } from "@/lib/constants"; +import { useTranslate } from "@/utils/i18n"; + +const GITHUB_COMMIT_URL_PREFIX = "https://github.com/usememos/memos/commit/"; +const GITHUB_RELEASE_URL_PREFIX = "https://github.com/usememos/memos/releases/tag/v"; + +const DEFAULT_TITLE = "Memos"; +const DEFAULT_TAGLINE = "Capture first. Keep it yours."; +const DEFAULT_LOGO = "/logo.webp"; + +const isCommitSha = (commit: string) => /^[0-9a-f]{7,40}$/i.test(commit); +const isSemver = (version: string) => /^\d+\.\d+\.\d+/.test(version); + +const Chip = ({ href, children }: { href?: string; children: React.ReactNode }) => { + const className = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 font-mono text-xs text-muted-foreground"; + if (href) { + return ( + + {children} + + ); + } + return {children}; +}; + +const SectionLabel = ({ children }: { children: React.ReactNode }) => ( +

{children}

+); + +interface Props { + open: boolean; + onOpenChange: (open: boolean) => void; +} + +const AboutDialog = ({ open, onOpenChange }: Props) => { + const t = useTranslate(); + const { profile, generalSetting } = useInstance(); + + const customProfile = generalSetting.customProfile; + const instanceTitle = customProfile?.title || DEFAULT_TITLE; + const instanceTagline = customProfile?.description || DEFAULT_TAGLINE; + const instanceLogo = customProfile?.logoUrl || DEFAULT_LOGO; + const isCustomBranded = instanceTitle !== DEFAULT_TITLE; + + const hasSemver = isSemver(profile.version); + const releaseUrl = hasSemver ? `${GITHUB_RELEASE_URL_PREFIX}${profile.version}` : ""; + const versionLabel = hasSemver ? `v${profile.version}` : profile.version; + const hasCommitSha = isCommitSha(profile.commit); + const commitUrl = hasCommitSha ? `${GITHUB_COMMIT_URL_PREFIX}${profile.commit}` : ""; + const shortCommit = hasCommitSha ? profile.commit.slice(0, 7) : ""; + + const buildRows: { label: string; value: React.ReactNode }[] = []; + if (profile.version) { + buildRows.push({ label: t("common.version"), value: {versionLabel} }); + } + if (shortCommit) { + buildRows.push({ label: t("about.commit"), value: {shortCommit} }); + } + buildRows.push({ label: t("about.license"), value: MIT }); + if (isCustomBranded) { + buildRows.push({ + label: t("about.distribution"), + value: {t("about.powered-by")}, + }); + } + + const projectLinks = [ + { label: t("about.official-website"), note: t("about.official-website-note"), href: "https://usememos.com/" }, + { label: t("about.documents"), note: t("about.documents-note"), href: "https://usememos.com/docs" }, + { label: t("about.api-docs"), note: t("about.api-docs-note"), href: "https://usememos.com/docs/api" }, + { + label: t("about.github-repository"), + note: t("about.github-repository-note"), + href: "https://github.com/usememos/memos", + }, + { label: t("about.web-clipper"), note: t("about.web-clipper-platforms"), href: WEB_CLIPPER_URL, icon: ScissorsIcon }, + ]; + + return ( + + + {t("common.about")} +
+
+ +
+
+

{instanceTitle}

+ {profile.demo && {t("about.demo")}} +
+

{instanceTagline}

+
+
+ +
+ {t("about.build")} +
+ {buildRows.map((row) => ( +
+
{row.label}
+
{row.value}
+
+ ))} +
+
+ +
+ {t("about.project")} + +
+
+
+
+ ); +}; + +export default AboutDialog; diff --git a/web/src/components/ActivityCalendar/CalendarCell.tsx b/web/src/components/ActivityCalendar/CalendarCell.tsx index 1b03d50b..e3d1d426 100644 --- a/web/src/components/ActivityCalendar/CalendarCell.tsx +++ b/web/src/components/ActivityCalendar/CalendarCell.tsx @@ -27,7 +27,7 @@ export const CalendarCell = memo((props: CalendarCellProps) => { const smallExtraClasses = size === "small" ? `${SMALL_CELL_SIZE.dimensions} min-h-0` : ""; const baseClasses = cn( - "aspect-square w-full flex items-center justify-center text-center transition-all duration-150 select-none border border-border/10 bg-muted/20", + "relative aspect-square w-full flex items-center justify-center text-center transition-[background-color,color,filter,box-shadow] duration-150 ease-out select-none", sizeConfig.font, sizeConfig.borderRadius, smallExtraClasses, @@ -36,7 +36,7 @@ export const CalendarCell = memo((props: CalendarCellProps) => { const ariaLabel = day.isSelected ? `${tooltipText} (selected)` : tooltipText; if (!day.isCurrentMonth) { - return
{day.label}
; + return
{day.label}
; } const intensityClass = getCellIntensityClass(day, maxCount); @@ -46,7 +46,9 @@ export const CalendarCell = memo((props: CalendarCellProps) => { baseClasses, intensityClass, getCalendarCellStateClass(day), - isInteractive ? "cursor-pointer hover:bg-muted/40 hover:border-border/30" : "cursor-default", + isInteractive + ? "cursor-pointer hover:brightness-[0.97] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-inset" + : "cursor-default", ); const button = ( @@ -60,6 +62,12 @@ export const CalendarCell = memo((props: CalendarCellProps) => { className={buttonClasses} > {day.label} + {day.isToday && ( +