From 00fcd170281a75fc0e95ec4f2f54f43d32fe81bd Mon Sep 17 00:00:00 2001 From: johnnyjoygh Date: Sun, 22 Nov 2026 17:02:15 +0800 Subject: [PATCH] style(web): tune sidebar type, spacing and alignment Sidebar text is one size: rows and the open nav label are 13px medium in secondary ink, so a row leads by weight and the rail stays quieter than the memos beside it. Section headers step down to the 11px label on the same 28px box as a row, and sections sit 16px apart. Trailing controls share one axis, 26px from the edge: the month arrows, section actions, view row menus and counts now line up under compose and search. Nav pills are a true 28px square, which lets the Timeline label fit whole at the new 272px default width instead of truncating. The calendar's chips are 24px inside their 28px cells, the heat ramp stops at 30% so a busy day cannot pass for a picked one, days without memos recede to secondary ink, and today is outlined instead of dotted. Text is antialiased across the app, matching the UI package's controls. --- .../ActivityCalendar/CalendarCell.tsx | 10 +---- .../ActivityCalendar/MonthCalendar.tsx | 4 +- .../components/ActivityCalendar/cellStyles.ts | 33 +++++++++----- web/src/components/AppSidebar/AppSidebar.tsx | 45 ++++++++++--------- .../AppSidebar/CommonSidebarContent.tsx | 6 ++- web/src/components/AppSidebar/SidebarRow.tsx | 32 ++++++++++--- .../components/AppSidebar/SidebarSection.tsx | 3 +- .../AppSidebar/SidebarSectionHeader.tsx | 10 +++-- web/src/components/AppSidebar/TagsSection.tsx | 6 +-- .../components/AppSidebar/ViewsSection.tsx | 3 +- .../components/AppSidebar/sidebar-layout.ts | 14 ++++-- .../components/AppSidebar/useSidebarWidth.ts | 3 +- .../StatisticsView/MonthNavigator.tsx | 5 ++- web/src/components/TagTree.tsx | 16 +++---- web/src/components/WelcomeGuide/headers.tsx | 7 ++- web/src/index.css | 4 +- web/tests/app-sidebar-logo.test.tsx | 12 ++--- .../calendar-cell-empty-clickable.test.tsx | 16 +++++-- web/tests/sidebar-row-grammar.test.tsx | 7 ++- 19 files changed, 146 insertions(+), 90 deletions(-) diff --git a/web/src/components/ActivityCalendar/CalendarCell.tsx b/web/src/components/ActivityCalendar/CalendarCell.tsx index 10ada4a5e..3e1315871 100644 --- a/web/src/components/ActivityCalendar/CalendarCell.tsx +++ b/web/src/components/ActivityCalendar/CalendarCell.tsx @@ -35,15 +35,7 @@ export const CalendarCell = memo(({ day, maxCount, tooltipText, onClick }: Calen aria-disabled={!isInteractive} className={cn(CELL_CLASSES, "p-0 focus-visible:outline-none", isInteractive ? "cursor-pointer" : "cursor-default")} > - - {day.label} - {day.isToday && ( - + {day.label} ); diff --git a/web/src/components/ActivityCalendar/MonthCalendar.tsx b/web/src/components/ActivityCalendar/MonthCalendar.tsx index 79724d2ca..cfe144179 100644 --- a/web/src/components/ActivityCalendar/MonthCalendar.tsx +++ b/web/src/components/ActivityCalendar/MonthCalendar.tsx @@ -13,8 +13,8 @@ import { calculateMaxCount, getTooltipText } from "./utils"; * leftover width goes into the column gaps, which keeps the first and last columns on the rails. */ const CALENDAR_GRID_CLASSES = "grid grid-cols-[repeat(7,28px)] justify-between gap-y-1"; -/** Weekday initials: caption weight in muted ink, so they sit under the day numbers rather than beside them. */ -const WEEKDAY_LABEL_CLASSES = "mu-caption text-mu-text-secondary"; +/** Weekday initials: the 11px caption in muted ink inside their 20px row, a step below the day numbers they head. */ +const WEEKDAY_LABEL_CLASSES = "mu-caption-xs text-mu-text-secondary"; /** Localized weekday labels starting on the instance's first day of the week. */ export const useWeekdayLabels = (weekStartDayOffset: number) => { diff --git a/web/src/components/ActivityCalendar/cellStyles.ts b/web/src/components/ActivityCalendar/cellStyles.ts index 11dd657b5..d5c55f04e 100644 --- a/web/src/components/ActivityCalendar/cellStyles.ts +++ b/web/src/components/ActivityCalendar/cellStyles.ts @@ -4,27 +4,35 @@ import { type ActivityLevel, getActivityLevel } from "./utils"; /** * The square chip inside a cell carries every visual. The grid's columns are 28px (see - * CALENDAR_GRID_CLASSES), so the chip is a 28px square; `max-w-7` keeps it there should a - * wider container ever hand the cell more. + * CALENDAR_GRID_CLASSES) and the cell takes the pointer across all of it; the chip is a 24px + * square inside (`max-w-6`), so the fills of neighbouring days never run together. The + * transparent border reserves the line that marks today. */ const CHIP_BASE = - "relative flex aspect-square w-full max-w-7 items-center justify-center rounded-mu-md text-center mu-caption tabular-nums transition-[background-color,color,filter,box-shadow] duration-150 ease-out"; + "relative flex aspect-square w-full max-w-6 items-center justify-center rounded-mu-md border border-transparent text-center mu-caption tabular-nums transition-[background-color,border-color,color,filter] duration-150 ease-out"; /** Hover reads off the cell (`group/day`), not the chip, so the whole column responds to the pointer. */ const INTERACTIVE_CHIP = "group-hover/day:brightness-[0.97] group-focus-visible/day:outline-2 group-focus-visible/day:outline-solid group-focus-visible/day:-outline-offset-2 group-focus-visible/day:outline-mu-focus"; const OUTSIDE_MONTH_CHIP = "bg-transparent text-mu-text-secondary/25"; -const EMPTY_CHIP = "bg-transparent text-mu-text/75 group-hover/day:bg-mu-well/40"; +/** A day without memos recedes to secondary ink, so the days that have them lead. */ +const EMPTY_CHIP = "bg-transparent text-mu-text-secondary group-hover/day:bg-mu-well/40"; /** A picked day is a checked filter like a view or tag row: it takes the accent, not a ring. */ const SELECTED_CHIP = "z-10 bg-mu-primary text-mu-on-primary"; +/** Today is outlined, quieter than a picked day's fill; a picked today shows the fill alone. */ +const TODAY_CHIP = "border-mu-text/40 text-mu-text"; -/** Primary-tinted activity levels; the small chip can carry a stronger wash than a full day cell. */ +/** + * Primary-tinted activity levels; the small chip can carry a stronger wash than a full day cell. + * The ramp stops at 30% so the busiest day never passes for a picked one, and every step keeps + * text ink: a day with memos is told from an empty one by its ink as well as its fill. + */ const INTENSITY_TINTS: Record, string> = { - 1: "bg-mu-primary/12 text-mu-text/75", - 2: "bg-mu-primary/22 text-mu-text/80", - 3: "bg-mu-primary/34 text-mu-text/80", - 4: "bg-mu-primary/48 text-mu-text/85", + 1: "bg-mu-primary/8 text-mu-text", + 2: "bg-mu-primary/14 text-mu-text", + 3: "bg-mu-primary/21 text-mu-text", + 4: "bg-mu-primary/30 text-mu-text", }; /** @@ -50,4 +58,9 @@ const getFillClass = (day: CalendarDayCell, maxCount: number): string => { }; export const getChipClassName = (day: CalendarDayCell, maxCount: number, isInteractive: boolean): string => - cn(CHIP_BASE, getFillClass(day, maxCount), isInteractive && day.isCurrentMonth && INTERACTIVE_CHIP); + cn( + CHIP_BASE, + getFillClass(day, maxCount), + day.isCurrentMonth && day.isToday && !day.isSelected && TODAY_CHIP, + isInteractive && day.isCurrentMonth && INTERACTIVE_CHIP, + ); diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsx index 0ef7c37a0..2dc04b11a 100644 --- a/web/src/components/AppSidebar/AppSidebar.tsx +++ b/web/src/components/AppSidebar/AppSidebar.tsx @@ -43,7 +43,7 @@ import { User_Role, UserNotification_Status } from "@/types/proto/api/user_servi import { useTranslate } from "@/utils/i18n"; import CommonSidebarContent from "./CommonSidebarContent"; import { getSidebarRouteKind } from "./routes"; -import SidebarRow, { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, sidebarRowStateClasses } from "./SidebarRow"; +import SidebarRow, { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, sidebarRowStateAttributes, sidebarRowStateClasses } from "./SidebarRow"; import SidebarSection, { SIDEBAR_SECTION_STACK_CLASSES } from "./SidebarSection"; import SpaceSwitcher from "./SpaceSwitcher"; import { @@ -209,17 +209,21 @@ const SettingsSidebarContent = () => { const basic = SETTINGS_SECTIONS.filter((section) => section.scope === "basic"); const admin = SETTINGS_SECTIONS.filter((section) => section.scope === "admin"); const renderSections = (sections: typeof SETTINGS_SECTIONS) => - sections.map((section) => ( - setMobileOpen(false)} - className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(currentSection === section.key ? "current" : "idle"))} - > - - {t(section.labelKey)} - - )); + sections.map((section) => { + const state = currentSection === section.key ? "current" : "idle"; + return ( + setMobileOpen(false)} + {...sidebarRowStateAttributes(state)} + className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(state))} + > + + {t(section.labelKey)} + + ); + }); return (
{renderSections(basic)} @@ -287,13 +291,14 @@ interface NavPillProps { } /** - * The compact navigator is intentionally horizontal. Its 16px glyph plus 6px padding - * on each side makes the collapsed control an exact 28px square, the same box as the - * header's compose control. Expanding the label only opens the text track, so the - * artwork and surface never jump. + * The compact navigator is intentionally horizontal. Its 16px glyph plus 5px padding and + * the 1px focus border on each side makes the collapsed control an exact 28px square, the + * same box as the header's compose control. Expanding the label only opens the text track, + * so the artwork and surface never jump. * - * Actions are separated by 4px; icons and labels by 6px. Below a 230px row the current - * page stays a filled square with its tooltip, leaving room for the other actions. + * Actions are separated by 4px; icons and labels by 6px. Below a 240px row the current + * page stays a filled square with its tooltip, leaving room for the other actions: the + * label opens whole or not at all, never as a three-letter truncation. * Timeline's trailing arrow shares its surface, with a separate click target. */ const NavPill = ({ label, icon: Icon, to, onClick, active = false, expanded = false, className }: NavPillProps) => { @@ -325,11 +330,11 @@ const NavPill = ({ label, icon: Icon, to, onClick, active = false, expanded = fa aria-hidden="true" className={cn( "grid min-w-0 grid-cols-[0fr] ps-0 transition-[grid-template-columns,padding] duration-200 ease-out motion-reduce:transition-none", - expanded && "@min-[230px]:grid-cols-[1fr] @min-[230px]:ps-1.5", + expanded && "@min-[240px]:grid-cols-[1fr] @min-[240px]:ps-1.5", )} > - + {label} diff --git a/web/src/components/AppSidebar/CommonSidebarContent.tsx b/web/src/components/AppSidebar/CommonSidebarContent.tsx index 95532753b..01df3b923 100644 --- a/web/src/components/AppSidebar/CommonSidebarContent.tsx +++ b/web/src/components/AppSidebar/CommonSidebarContent.tsx @@ -5,7 +5,7 @@ import { MEMOS_API_DOCUMENTATION_URL, MEMOS_DOCUMENTATION_URL, MEMOS_GITHUB_URL import { cn } from "@/lib/utils"; import { ROUTES } from "@/router/routes"; import { useTranslate } from "@/utils/i18n"; -import { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, sidebarRowStateClasses } from "./SidebarRow"; +import { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, sidebarRowStateAttributes, sidebarRowStateClasses } from "./SidebarRow"; import SidebarSection, { SIDEBAR_SECTION_STACK_CLASSES } from "./SidebarSection"; interface ResourceLink { @@ -25,6 +25,7 @@ const CommonSidebarContent = () => { const location = useLocation(); const { setMobileOpen } = useAppSidebar(); const aboutActive = Boolean(matchPath(ROUTES.ABOUT, location.pathname)); + const aboutState = aboutActive ? "current" : "idle"; return (
@@ -33,7 +34,8 @@ const CommonSidebarContent = () => { to={ROUTES.ABOUT} aria-current={aboutActive ? "page" : undefined} onClick={() => setMobileOpen(false)} - className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(aboutActive ? "current" : "idle"))} + {...sidebarRowStateAttributes(aboutState)} + className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(aboutState))} > {t("common.about")} diff --git a/web/src/components/AppSidebar/SidebarRow.tsx b/web/src/components/AppSidebar/SidebarRow.tsx index 22a43240e..0dcbd97d8 100644 --- a/web/src/components/AppSidebar/SidebarRow.tsx +++ b/web/src/components/AppSidebar/SidebarRow.tsx @@ -1,4 +1,4 @@ -import type { LucideIcon } from "lucide-react"; +import { HashIcon, type LucideIcon } from "lucide-react"; import type { ReactNode } from "react"; import { cn } from "@/lib/utils"; import { SCOPE_PANEL_ICON_CLASSES, SIDEBAR_LEADING_SLOT_CLASSES, sidebarSurfaceVariants } from "./sidebar-layout"; @@ -15,8 +15,9 @@ export const SIDEBAR_ROW_BOX_CLASSES = `${sidebarSurfaceVariants({ role: "row" } export const SIDEBAR_ROW_CLASSES = `${SIDEBAR_ROW_BOX_CLASSES} border border-transparent mu-focus focus-visible:border-mu-focus`; export const SIDEBAR_ROW_ICON_CLASSES = - // The md row's 16px icon at the md stroke, beside its 14px label, in the row's own muted ink. - "mu-icon me-auto shrink-0 group-data-checked:text-mu-primary"; + // The md row's 16px icon at the md stroke. It sits a step behind the label at rest, so the + // label leads; it takes the row's ink on the current page and the accent when checked. + "mu-icon me-auto shrink-0 text-mu-text-secondary/70 group-data-current:text-current group-data-checked:text-mu-primary"; const SIDEBAR_ROW_COUNT_CLASSES = "mu-caption tabular-nums text-mu-text-secondary group-data-checked:text-mu-primary"; /** @@ -36,8 +37,11 @@ export const SIDEBAR_ROW_SLOT_CLASSES = SIDEBAR_LEADING_SLOT_CLASSES; /** A slot that is itself a control (disclosure, row menu): same box plus the hover chip. */ export const SIDEBAR_ROW_SLOT_BUTTON_CLASSES = `${SIDEBAR_ROW_SLOT_CLASSES} relative rounded hover:bg-mu-hover after:absolute after:-inset-0.5 after:content-[''] border border-transparent mu-focus focus-visible:border-mu-focus`; -/** Trailing rail for counts, wide enough that digits align down the list. */ -export const SIDEBAR_ROW_COUNT_RAIL_CLASSES = `${SIDEBAR_ROW_COUNT_CLASSES} min-w-[3ch] shrink-0 text-end`; +/** + * Trailing rail for counts, wide enough that digits align down the list. Counts stay + * end-aligned; the 1px end margin is optical, centring a single digit on the action axis. + */ +export const SIDEBAR_ROW_COUNT_RAIL_CLASSES = `${SIDEBAR_ROW_COUNT_CLASSES} me-px min-w-[3ch] shrink-0 text-end`; /** The standard icon-in-slot pairing, so every list renders its glyphs identically. */ export const SidebarRowIconSlot = ({ icon: Icon }: { icon: LucideIcon }) => ( @@ -46,6 +50,21 @@ export const SidebarRowIconSlot = ({ icon: Icon }: { icon: LucideIcon }) => ( ); +/** + * A tag row's # mark, one icon step below the row's: the same glyph repeats down the whole + * list, so it is texture beside the label rather than a sign to read. + */ +export const SidebarTagMark = ({ className }: { className?: string }) => ( +