mirror of
https://github.com/usememos/memos.git
synced 2026-12-02 08:49:14 +01:00
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.
This commit is contained in:
@@ -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")}
|
||||
>
|
||||
<span className={getChipClassName(day, maxCount, isInteractive)}>
|
||||
{day.label}
|
||||
{day.isToday && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute bottom-[3px] left-1/2 size-[3px] -translate-x-1/2 rounded-full bg-current opacity-70"
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
<span className={getChipClassName(day, maxCount, isInteractive)}>{day.label}</span>
|
||||
</button>
|
||||
);
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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<Exclude<ActivityLevel, 0>, 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,
|
||||
);
|
||||
|
||||
@@ -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) => (
|
||||
<Link
|
||||
key={section.key}
|
||||
to={`${ROUTES.SETTING}#${section.key}`}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(currentSection === section.key ? "current" : "idle"))}
|
||||
>
|
||||
<SidebarRowIconSlot icon={section.icon} />
|
||||
<span className="truncate">{t(section.labelKey)}</span>
|
||||
</Link>
|
||||
));
|
||||
sections.map((section) => {
|
||||
const state = currentSection === section.key ? "current" : "idle";
|
||||
return (
|
||||
<Link
|
||||
key={section.key}
|
||||
to={`${ROUTES.SETTING}#${section.key}`}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
{...sidebarRowStateAttributes(state)}
|
||||
className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses(state))}
|
||||
>
|
||||
<SidebarRowIconSlot icon={section.icon} />
|
||||
<span className="truncate">{t(section.labelKey)}</span>
|
||||
</Link>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className={SIDEBAR_SECTION_STACK_CLASSES}>
|
||||
<SidebarSection label={t("common.basic")}>{renderSections(basic)}</SidebarSection>
|
||||
@@ -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",
|
||||
)}
|
||||
>
|
||||
<span className="flex min-w-0 items-center overflow-hidden">
|
||||
<span data-sidebar-label className="min-w-0 truncate mu-body">
|
||||
<span data-sidebar-label className="min-w-0 truncate mu-label-sm">
|
||||
{label}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -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 (
|
||||
<div className={SIDEBAR_SECTION_STACK_CLASSES}>
|
||||
@@ -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))}
|
||||
>
|
||||
<SidebarRowIconSlot icon={InfoIcon} />
|
||||
<span className="min-w-0 flex-1 truncate">{t("common.about")}</span>
|
||||
|
||||
@@ -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 }) => (
|
||||
</span>
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 }) => (
|
||||
<HashIcon aria-hidden="true" className={cn(SIDEBAR_ROW_ICON_CLASSES, "mu-icon-sm", className)} />
|
||||
);
|
||||
|
||||
/** The tag mark in the standard leading slot. */
|
||||
export const SidebarTagMarkSlot = () => (
|
||||
<span className={SIDEBAR_ROW_SLOT_CLASSES} aria-hidden="true">
|
||||
<SidebarTagMark />
|
||||
</span>
|
||||
);
|
||||
|
||||
/**
|
||||
* The scope panel's leading icon (see sidebar-layout): links, actions and submenu triggers in
|
||||
* the panel share the 20px leading slot with the sidebar rows above them.
|
||||
@@ -76,8 +95,9 @@ export const sidebarRowStateClasses = (state: SidebarRowState = "idle") => {
|
||||
return `text-mu-text-secondary ${SIDEBAR_ROW_HOVER_CLASSES}`;
|
||||
};
|
||||
|
||||
/** Goes on the row box so the icon slot and count rail inside it can take the checked colour. */
|
||||
/** Goes on the row box so the icon slot and count rail inside it can take the row's state colour. */
|
||||
export const sidebarRowStateAttributes = (state: SidebarRowState) => ({
|
||||
"data-current": state === "current" ? "" : undefined,
|
||||
"data-checked": state === "checked" ? "" : undefined,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { ReactNode } from "react";
|
||||
import SidebarSectionHeader from "./SidebarSectionHeader";
|
||||
|
||||
export const SIDEBAR_SECTION_STACK_CLASSES = "flex flex-col gap-3";
|
||||
// 16px between sections: with the header on a 28px row box, a section break is clearly more than a row gap.
|
||||
export const SIDEBAR_SECTION_STACK_CLASSES = "flex flex-col gap-4";
|
||||
export const SIDEBAR_SECTION_CONTENT_CLASSES = "flex flex-col gap-0.5";
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -6,10 +6,12 @@ interface Props {
|
||||
}
|
||||
|
||||
const SidebarSectionHeader = ({ children, action }: Props) => (
|
||||
<div className="mb-0.5 flex h-6 min-w-0 items-center justify-between gap-2">
|
||||
{/* Sentence case at the small label weight: it reads apart from the 400-weight muted rows by
|
||||
weight and space, not by capitals or a size below the type scale. */}
|
||||
<h2 className="min-w-0 truncate ps-2 mu-label-sm text-mu-text-secondary select-none">{children}</h2>
|
||||
// The header sits on the same 28px box as a row, so every list keeps one 30px pitch. Its
|
||||
// 20px action ends 16px from the edge, centred on the rail's action axis (see sidebar-layout).
|
||||
<div className="mb-0.5 flex h-7 min-w-0 items-center justify-between gap-2 pe-1">
|
||||
{/* Sentence case, one type step below the 13px medium rows it labels: it reads apart by
|
||||
size and space, not by capitals or a darker ink. */}
|
||||
<h2 className="min-w-0 truncate ps-2 mu-label-xs text-mu-text-secondary select-none">{children}</h2>
|
||||
{action}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Button, Menu, Tooltip } from "@usememos/ui";
|
||||
import { HashIcon, ListTreeIcon, MoreHorizontalIcon } from "lucide-react";
|
||||
import { ListTreeIcon, MoreHorizontalIcon } from "lucide-react";
|
||||
import { forwardRef, useMemo } from "react";
|
||||
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
|
||||
import { useLocalStorage, useOverflowTitle } from "@/hooks";
|
||||
@@ -9,7 +9,7 @@ import TagTree, { tagRowAriaLabel } from "../TagTree";
|
||||
import {
|
||||
SIDEBAR_ROW_CLASSES,
|
||||
SIDEBAR_ROW_COUNT_RAIL_CLASSES,
|
||||
SidebarRowIconSlot,
|
||||
SidebarTagMarkSlot,
|
||||
sidebarRowStateAttributes,
|
||||
sidebarRowStateClasses,
|
||||
} from "./SidebarRow";
|
||||
@@ -62,7 +62,7 @@ const FlatTagRow = ({ tag, amount, active, ariaLabel, onClick }: FlatTagRowProps
|
||||
onClick={onClick}
|
||||
>
|
||||
{/* Same leading slot as the tree, so the # marks hold their line when switching modes. */}
|
||||
<SidebarRowIconSlot icon={HashIcon} />
|
||||
<SidebarTagMarkSlot />
|
||||
<TagPath ref={ref} tag={tag} />
|
||||
<span className={SIDEBAR_ROW_COUNT_RAIL_CLASSES}>{amount}</span>
|
||||
</button>
|
||||
|
||||
@@ -98,7 +98,8 @@ const ViewsSection = ({ manageActive = false }: { manageActive?: boolean }) => {
|
||||
<div
|
||||
key={memoView.name}
|
||||
{...sidebarRowStateAttributes(state)}
|
||||
className={cn(SIDEBAR_ROW_BOX_CLASSES, "group/view", sidebarRowStateClasses(state))}
|
||||
// `pe-1` puts the 20px row menu on the action axis, under the section's own action.
|
||||
className={cn(SIDEBAR_ROW_BOX_CLASSES, "group/view pe-1", sidebarRowStateClasses(state))}
|
||||
>
|
||||
<button type="button" onClick={() => handleView(id)} aria-pressed={active || undefined} className={SIDEBAR_ROW_LABEL_CLASSES}>
|
||||
<span className={SIDEBAR_ROW_SLOT_CLASSES} aria-hidden="true">
|
||||
|
||||
@@ -8,11 +8,19 @@ import { cva } from "class-variance-authority";
|
||||
* artwork column. The sidebar carries the package's `mu-compact`, so its md rows and
|
||||
* controls are 28px tall: rows read their height and radius from the md row variables,
|
||||
* and compact navigation is a 28px square like the header's compose control.
|
||||
*
|
||||
* Text is one size, 13px: rows and open nav labels are `mu-label-sm`, so a row leads by
|
||||
* weight in secondary ink and stays quieter than the memos beside the rail.
|
||||
*
|
||||
* The end of the rail mirrors its start with one action axis, 26px from the edge: the centre
|
||||
* of a 28px control sitting on the 12px inset (compose, search, the calendar's last column).
|
||||
* Every trailing 20px control centres on it, so its box ends 16px from the edge: a box that
|
||||
* holds one (a section header, the month row, a view row) pads its end by 4px (`pe-1`).
|
||||
*/
|
||||
export const SIDEBAR_RAIL_CLASSES = "px-3";
|
||||
// Content rows reserve 20px so 16px icons and 20px marks share a stable label rail.
|
||||
export const SIDEBAR_LEADING_SLOT_CLASSES = "flex size-5 shrink-0 items-center justify-center";
|
||||
// Compact nav uses the visible 16px glyph itself as the cell, keeping 6px x/y padding.
|
||||
// Compact nav uses the visible 16px glyph itself as the cell: 5px padding plus the 1px focus border each side.
|
||||
export const SIDEBAR_NAV_LEADING_SLOT_CLASSES = "flex size-4 shrink-0 items-center justify-center";
|
||||
|
||||
/**
|
||||
@@ -25,8 +33,8 @@ export const SIDEBAR_NAV_LEADING_SLOT_CLASSES = "flex size-4 shrink-0 items-cent
|
||||
export const sidebarSurfaceVariants = cva("min-w-0 items-center", {
|
||||
variants: {
|
||||
role: {
|
||||
row: "mu-s-md flex h-(--mu-row-height) w-full gap-1 rounded-(--mu-row-radius) px-2 mu-body",
|
||||
navPill: "mu-s-md relative flex h-(--mu-row-height) shrink-0 rounded-(--mu-row-radius) px-1.5",
|
||||
row: "mu-s-md flex h-(--mu-row-height) w-full gap-1 rounded-(--mu-row-radius) px-2 mu-label-sm",
|
||||
navPill: "mu-s-md relative flex h-(--mu-row-height) shrink-0 rounded-(--mu-row-radius) px-[5px]",
|
||||
headerBrand: "flex h-9 max-w-full gap-2 rounded-mu-md px-2",
|
||||
mobileBrand: "flex h-9 max-w-full gap-1.5 rounded-mu-md px-1",
|
||||
account: "flex h-9 w-full gap-1 rounded-none px-5",
|
||||
|
||||
@@ -11,7 +11,8 @@ export const SIDEBAR_WIDTH_VAR = "--app-sidebar-width";
|
||||
export const SIDEBAR_MIN_WIDTH = 224;
|
||||
/** Wider than this only starves the feed: its columns need 260px each and the rail holds short labels. */
|
||||
export const SIDEBAR_MAX_WIDTH = 400;
|
||||
export const SIDEBAR_DEFAULT_WIDTH = 256;
|
||||
/** The narrowest width at which the open nav label (Timeline) fits whole beside the other pills, with room to spare. */
|
||||
export const SIDEBAR_DEFAULT_WIDTH = 272;
|
||||
|
||||
/** The rail may never take more than this share of the window. */
|
||||
const MAX_VIEWPORT_SHARE = 0.4;
|
||||
|
||||
@@ -14,8 +14,9 @@ export const MonthNavigator = memo(({ visibleMonth, onMonthChange }: MonthNaviga
|
||||
const handleNextMonth = () => onMonthChange(addMonths(visibleMonth, 1));
|
||||
|
||||
return (
|
||||
<header className={cn(SIDEBAR_ROW_BOX_CLASSES, "mb-2 justify-between")}>
|
||||
<h2 className="min-w-0 truncate mu-label text-mu-text select-none">{monthLabel}</h2>
|
||||
// `pe-1` puts the next-month arrow on the sidebar's action axis.
|
||||
<header className={cn(SIDEBAR_ROW_BOX_CLASSES, "mb-2 justify-between pe-1")}>
|
||||
<h2 className="min-w-0 truncate text-mu-text select-none">{monthLabel}</h2>
|
||||
|
||||
<nav className="flex shrink-0 items-center gap-0.5" aria-label={t("common.month-navigation")}>
|
||||
<Tooltip.Root>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ChevronRightIcon, HashIcon } from "lucide-react";
|
||||
import { ChevronRightIcon } from "lucide-react";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import {
|
||||
SIDEBAR_ROW_BOX_CLASSES,
|
||||
SIDEBAR_ROW_COUNT_RAIL_CLASSES,
|
||||
SIDEBAR_ROW_ICON_CLASSES,
|
||||
SIDEBAR_ROW_LABEL_CLASSES,
|
||||
SIDEBAR_ROW_SLOT_BUTTON_CLASSES,
|
||||
SIDEBAR_ROW_SLOT_CLASSES,
|
||||
SidebarRowIconSlot,
|
||||
SidebarTagMark,
|
||||
SidebarTagMarkSlot,
|
||||
sidebarRowStateAttributes,
|
||||
sidebarRowStateClasses,
|
||||
} from "@/components/AppSidebar/SidebarRow";
|
||||
@@ -42,7 +42,7 @@ interface TagTreeExpansion {
|
||||
const EMPTY_EXPANSION: TagTreeExpansion = { expanded: [] };
|
||||
|
||||
// A structural row toggles like any other, so it hovers like one too — just quieter at rest.
|
||||
const STRUCTURAL_ROW_CLASSES = cn(sidebarRowStateClasses(), "font-medium text-mu-text-secondary/65");
|
||||
const STRUCTURAL_ROW_CLASSES = cn(sidebarRowStateClasses(), "text-mu-text-secondary/65");
|
||||
|
||||
/** One announcement for a tag row in either layout, so tree and flat mode never drift apart. */
|
||||
export const tagRowAriaLabel = (t: ReturnType<typeof useTranslate>, tag: string, amount: number) =>
|
||||
@@ -88,10 +88,6 @@ const parentPathsOf = (tag: string): string[] => {
|
||||
return segments.slice(0, -1).map((_, index) => segments.slice(0, index + 1).join("/"));
|
||||
};
|
||||
|
||||
const TagMark = ({ className }: { className?: string }) => (
|
||||
<HashIcon aria-hidden="true" className={cn(SIDEBAR_ROW_ICON_CLASSES, className)} />
|
||||
);
|
||||
|
||||
const Chevron = ({ open, className }: { open: boolean; className?: string }) => (
|
||||
<ChevronRightIcon
|
||||
aria-hidden="true"
|
||||
@@ -152,7 +148,7 @@ const TagItem = ({ tag, depth, activeTag, expanded, onTagClick, onToggle }: TagI
|
||||
className={SIDEBAR_ROW_SLOT_BUTTON_CLASSES}
|
||||
onClick={() => onToggle(tag.text)}
|
||||
>
|
||||
<TagMark className="group-hover:hidden group-has-[:focus-visible]:hidden" />
|
||||
<SidebarTagMark className="group-hover:hidden group-has-[:focus-visible]:hidden" />
|
||||
<Chevron open={open} className="hidden group-hover:block group-has-[:focus-visible]:block" />
|
||||
</button>
|
||||
)}
|
||||
@@ -165,7 +161,7 @@ const TagItem = ({ tag, depth, activeTag, expanded, onTagClick, onToggle }: TagI
|
||||
className={SIDEBAR_ROW_LABEL_CLASSES}
|
||||
onClick={() => onTagClick(tag.text)}
|
||||
>
|
||||
{!hasSubTags && <SidebarRowIconSlot icon={HashIcon} />}
|
||||
{!hasSubTags && <SidebarTagMarkSlot />}
|
||||
<span ref={labelRef} className="min-w-0 flex-1 truncate">
|
||||
{tag.key}
|
||||
</span>
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
CalendarDaysIcon,
|
||||
ChevronDownIcon,
|
||||
EllipsisIcon,
|
||||
HashIcon,
|
||||
LibraryIcon,
|
||||
ListChecksIcon,
|
||||
LockIcon,
|
||||
@@ -15,7 +14,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import type { ReactNode } from "react";
|
||||
import { MonthCalendar } from "@/components/ActivityCalendar/MonthCalendar";
|
||||
import { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, sidebarRowStateClasses } from "@/components/AppSidebar/SidebarRow";
|
||||
import { SIDEBAR_ROW_CLASSES, SidebarRowIconSlot, SidebarTagMarkSlot, sidebarRowStateClasses } from "@/components/AppSidebar/SidebarRow";
|
||||
import SidebarSection from "@/components/AppSidebar/SidebarSection";
|
||||
import { sidebarSurfaceVariants } from "@/components/AppSidebar/sidebar-layout";
|
||||
import { MEMO_CARD_BASE_CLASSES } from "@/components/MemoView/constants";
|
||||
@@ -140,7 +139,7 @@ export const KeepHeader = () => {
|
||||
const { month, today } = currentMonth();
|
||||
const days = [today, today - 1, today - 2, today - 9, today - 15].filter((day) => day >= 1);
|
||||
const data = Object.fromEntries(days.map((day, index) => [`${month}-${String(day).padStart(2, "0")}`, index === 0 ? 2 : 1]));
|
||||
const pillClasses = cn(sidebarSurfaceVariants({ role: "navPill" }), sidebarRowStateClasses("current"), "gap-1.5 px-2 mu-body");
|
||||
const pillClasses = cn(sidebarSurfaceVariants({ role: "navPill" }), sidebarRowStateClasses("current"), "gap-1.5 px-2 mu-label-sm");
|
||||
return (
|
||||
<Still className="grid gap-4 pt-1 sm:grid-cols-[minmax(0,1fr)_160px]">
|
||||
<div className="mu-caption">
|
||||
@@ -171,7 +170,7 @@ export const KeepHeader = () => {
|
||||
[t("welcome.sample.tag-project"), 2],
|
||||
].map(([tag, count]) => (
|
||||
<span key={String(tag)} className={cn(SIDEBAR_ROW_CLASSES, sidebarRowStateClasses("idle"))}>
|
||||
<SidebarRowIconSlot icon={HashIcon} />
|
||||
<SidebarTagMarkSlot />
|
||||
<span className="min-w-0 flex-1 truncate">{tag}</span>
|
||||
<span className="mu-caption text-mu-text-secondary/60 tabular-nums">{count}</span>
|
||||
</span>
|
||||
|
||||
+3
-1
@@ -48,8 +48,10 @@
|
||||
background-color: color-mix(in oklch, var(--mu-text-secondary) 65%, transparent);
|
||||
}
|
||||
|
||||
/* Antialiased everywhere, as @usememos/ui sets on its own controls: one rendering mode for
|
||||
the whole app, so plain text never sits heavier than the control beside it. */
|
||||
body {
|
||||
@apply bg-mu-canvas text-mu-text;
|
||||
@apply bg-mu-canvas text-mu-text antialiased;
|
||||
}
|
||||
|
||||
/* Search hits in memo bodies (CSS Custom Highlight API, registered by useSearchMatchHighlight).
|
||||
|
||||
@@ -165,20 +165,20 @@ const render = (ui: Parameters<typeof testingLibraryRender>[0]) =>
|
||||
);
|
||||
|
||||
const expectCollapsedNavPill = (pill: HTMLElement, label: string) => {
|
||||
expect(pill).toHaveClass("mu-s-md", "h-(--mu-row-height)", "rounded-(--mu-row-radius)", "px-1.5");
|
||||
expect(pill).toHaveClass("mu-s-md", "h-(--mu-row-height)", "rounded-(--mu-row-radius)", "px-[5px]");
|
||||
expect(pill.firstElementChild).toHaveClass("size-4");
|
||||
const labelTrack = pill.querySelector('span.grid[aria-hidden="true"]');
|
||||
expect(labelTrack).toHaveClass("grid-cols-[0fr]", "ps-0");
|
||||
expect(labelTrack).not.toHaveClass("@min-[230px]:grid-cols-[1fr]");
|
||||
expect(labelTrack).not.toHaveClass("@min-[240px]:grid-cols-[1fr]");
|
||||
expect(labelTrack).toHaveTextContent(label);
|
||||
};
|
||||
|
||||
const expectExpandedNavPill = (pill: HTMLElement, label: string) => {
|
||||
expect(pill).toHaveClass("mu-s-md", "h-(--mu-row-height)", "rounded-(--mu-row-radius)", "px-1.5");
|
||||
expect(pill).toHaveClass("mu-s-md", "h-(--mu-row-height)", "rounded-(--mu-row-radius)", "px-[5px]");
|
||||
expect(pill.firstElementChild).toHaveClass("size-4");
|
||||
const labelTrack = pill.querySelector("span.grid");
|
||||
// The label opens only where the row can afford it; the control's aria-label names it regardless.
|
||||
expect(labelTrack).toHaveClass("@min-[230px]:grid-cols-[1fr]", "@min-[230px]:ps-1.5");
|
||||
expect(labelTrack).toHaveClass("@min-[240px]:grid-cols-[1fr]", "@min-[240px]:ps-1.5");
|
||||
expect(labelTrack).toHaveAttribute("aria-hidden", "true");
|
||||
expect(pill.querySelector("[data-sidebar-label]")).toHaveTextContent(label);
|
||||
};
|
||||
@@ -248,7 +248,7 @@ describe("App sidebar logo", () => {
|
||||
expect(compose).toHaveClass("mu-button", "mu-button-neutral", "mu-button-icon", "mu-s-md");
|
||||
expect(compose).not.toHaveClass("rounded-full");
|
||||
expect(header).not.toContainElement(search);
|
||||
expect(search).toHaveClass("ms-auto", "h-(--mu-row-height)", "px-1.5");
|
||||
expect(search).toHaveClass("ms-auto", "h-(--mu-row-height)", "px-[5px]");
|
||||
expect(search.querySelector(".lucide-search")).toHaveClass("mu-icon");
|
||||
|
||||
fireEvent.click(search);
|
||||
@@ -398,7 +398,7 @@ describe("App sidebar logo", () => {
|
||||
expect(primaryNavigation).toHaveClass("h-(--mu-row-height)", "items-center", "gap-1", "px-3");
|
||||
expect(primaryNavigation).not.toHaveClass("flex-col");
|
||||
const navigation = within(primaryNavigation);
|
||||
expect(navigation.getByRole("button", { name: "common.search" })).toHaveClass("ms-auto", "h-(--mu-row-height)", "px-1.5");
|
||||
expect(navigation.getByRole("button", { name: "common.search" })).toHaveClass("ms-auto", "h-(--mu-row-height)", "px-[5px]");
|
||||
expectActiveNavPill(navigation.getByRole("link", { name: "common.timeline" }), "common.timeline");
|
||||
const calendar = navigation.getByRole("link", { name: "common.calendar" });
|
||||
expect(calendar).toHaveAttribute("href", "/calendar");
|
||||
|
||||
@@ -47,12 +47,22 @@ describe("CalendarCell empty-day clickability", () => {
|
||||
expect(onClick).toHaveBeenCalledWith("2025-05-01");
|
||||
});
|
||||
|
||||
it("marks today with a dot without changing the numeral weight", () => {
|
||||
it("outlines today without changing the numeral weight", () => {
|
||||
render(<CalendarCell day={makeDay({ isToday: true })} maxCount={5} tooltipText="May 1, 2025" onClick={() => {}} />);
|
||||
|
||||
const button = screen.getByRole("button", { name: /May 1, 2025/ });
|
||||
expect(button).toHaveAttribute("aria-current", "date");
|
||||
expect(button).not.toHaveClass("font-semibold", "font-bold");
|
||||
expect(button.querySelector('[aria-hidden="true"]')).toHaveClass("rounded-full");
|
||||
expect(chipOf(button)).toHaveClass("border", "border-mu-text/40", "text-mu-text");
|
||||
expect(chipOf(button)).not.toHaveClass("border-transparent");
|
||||
});
|
||||
|
||||
it("shows a picked today by its fill alone", () => {
|
||||
render(<CalendarCell day={makeDay({ isToday: true, isSelected: true })} maxCount={5} tooltipText="May 1, 2025" onClick={() => {}} />);
|
||||
|
||||
const chip = chipOf(screen.getByRole("button", { name: /May 1, 2025/ }));
|
||||
expect(chip).toHaveClass("bg-mu-primary", "text-mu-on-primary", "border-transparent");
|
||||
expect(chip).not.toHaveClass("border-mu-text/40");
|
||||
});
|
||||
|
||||
it("fills a selected day with the accent like a checked filter row, keeping the numeral weight", () => {
|
||||
@@ -81,7 +91,7 @@ describe("CalendarCell empty-day clickability", () => {
|
||||
// The square lives on the capped chip. Putting it back on the button would make row
|
||||
// height track the column width again, which is what made a widened rail so tall.
|
||||
expect(button).not.toHaveClass("aspect-square");
|
||||
expect(chipOf(button)).toHaveClass("aspect-square", "max-w-7");
|
||||
expect(chipOf(button)).toHaveClass("aspect-square", "max-w-6");
|
||||
});
|
||||
|
||||
it("does not render out-of-month days as interactive (no role=button)", () => {
|
||||
|
||||
@@ -27,7 +27,10 @@ describe("sidebar row grammar", () => {
|
||||
</SidebarSection>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole("heading", { name: "Statistics", level: 2 })).toHaveClass("mu-label-sm");
|
||||
const heading = screen.getByRole("heading", { name: "Statistics", level: 2 });
|
||||
// The header is one type step below the 13px rows it labels, on the same 28px box as a row.
|
||||
expect(heading).toHaveClass("mu-label-xs");
|
||||
expect(heading.parentElement).toHaveClass("h-7", "pe-1");
|
||||
expect(screen.getByRole("button", { name: "August 2026" }).parentElement).toHaveClass(...SIDEBAR_SECTION_CONTENT_CLASSES.split(" "));
|
||||
});
|
||||
|
||||
@@ -36,7 +39,7 @@ describe("sidebar row grammar", () => {
|
||||
|
||||
const row = screen.getByRole("button", { name: "Tasks3" });
|
||||
expect(row).toHaveClass(...boxClasses);
|
||||
expect(row).toHaveClass("mu-s-md", "h-(--mu-row-height)", "w-full", "gap-1", "rounded-(--mu-row-radius)", "px-2", "mu-body");
|
||||
expect(row).toHaveClass("mu-s-md", "h-(--mu-row-height)", "w-full", "gap-1", "rounded-(--mu-row-radius)", "px-2", "mu-label-sm");
|
||||
expect(row).not.toHaveClass("-mx-1");
|
||||
// Icon in the shared slot and count in the shared rail, so every list — nav rows,
|
||||
// views, tags in both modes — keeps its icons and digits on the same vertical lines.
|
||||
|
||||
Reference in New Issue
Block a user