diff --git a/AGENTS.md b/AGENTS.md index 5716713e3..dae4700a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ repo. If a fact here conflicts with source files or CI config, trust the source Memos is a self-hosted note-taking app. - Backend: Go 1.27.2, net/http, Connect RPC, gRPC-Gateway, Protocol Buffers. -- Frontend: React 19, TypeScript 7, Vite 8, Tailwind CSS v4, React Query v5. +- Frontend: React 19, TypeScript 7, Vite 8, Tailwind CSS v4, `@usememos/ui` on Base UI, React Query v5. - Storage: SQLite, MySQL, PostgreSQL. - Generated API outputs: `proto/gen/` for Go/OpenAPI, `web/src/types/proto/` for TypeScript. @@ -51,7 +51,7 @@ golangci-lint run --fix # Auto-fix lint, including goimports # Frontend cd web && pnpm install # Install dependencies -cd web && pnpm dev # Dev server on :3001, proxying API to :8081 +cd web && pnpm dev # Dev server on :3001, proxying API to :8081 (or $DEV_PROXY_SERVER) cd web && pnpm lint # Type check + Biome lint cd web && pnpm test # Vitest unit tests cd web && pnpm build # Production build @@ -83,7 +83,7 @@ Every root folder is named for what it holds. Read the folder's `doc.go` or `REA | `provider/` | Backends configured by instance settings: `ai`, `idp`, `storage` | proto/gen, internal | | `internal/` | Private plumbing with no memos vocabulary (`identifier`, `email`, `webhook`, `ratelimit`, …) | third party only | | `proto/api/`, `proto/store/` | Public API and internal storage proto sources; `proto/gen/` is generated | | -| `web/src/` | React SPA: `connect.ts` clients, `auth-state.ts`, `hooks/`, `contexts/`, `components/`, `themes/` | | +| `web/src/` | React SPA: `connect.ts` clients, `auth-state.ts`, `hooks/`, `contexts/`, `components/`, `lib/`, `locales/`, `themes/` | | Layering rules, enforced by `depguard` in `.golangci.yaml`: @@ -126,9 +126,24 @@ Black-box service tests live in `server/api/test/`, unit tests next to the code. - Follow Biome formatting: 2-space indent, double quotes, semicolons, 140-character line width. - Put server data in React Query hooks under `web/src/hooks/`; keep UI-only state in contexts or component state. - Show, edit and compose memos through `web/src/components/MemoEditor` (a name or draft seed plus a mode); see its `README.md`. -- Use Tailwind CSS v4 utilities, `cn()` for class merging, and CVA for variants. -- Reuse Base UI primitives and existing components before adding new UI primitives. - Keep generated proto TypeScript under `web/src/types/proto/` out of manual edits and Biome rewrites. +- UI work reads `web/node_modules/@usememos/ui/llms.txt` first: `@usememos/ui` is the design system (tokens, type classes, + components). Controls come from the package; build a part it lacks on Base UI as its `custom-components.md` describes. +- Use a package component when one fits (`Button`, `Link`, `Spinner`, `Badge`). Its class functions (`buttonClasses()`, + `menuClasses()`, `badgeClasses()`) are for elements it can't render, such as a router link or a Base UI trigger. +- Style with Tailwind CSS v4 and the package's `mu-` utilities (`bg-mu-surface`, `text-mu-ink-muted`, `rounded-mu-md`), + text with its type classes (`mu-caption`, `mu-body`, `mu-label`, `mu-title`), and `cn()` for class merging. No Tailwind + text sizes or old color names (`muted-foreground`, `destructive`, `popover`). The exceptions are the brand wordmark and + emoji glyphs, whose font size is their icon box (`SpaceIcon`, `SpaceMark`, `MemoViewIcon`, `CustomIconPicker`). +- Focus shows through `mu-focus`. Never add `ring-*` or `focus-visible:ring-*`, and never pair `mu-focus` with + `outline-none`, which overrides it. Visually hidden text uses `mu-visually-hidden`; a control that appears on focus keeps + Tailwind's `sr-only focus-visible:not-sr-only` pair. +- Report failures with `showErrorToast` from `web/src/lib/toast.ts`. A form's own validation errors go under the field + (`Field.Error`, kept in `useFieldErrors`), not in a toast. +- Every new key in `web/src/locales/en.json` is translated into all locales; `tests/locale-resources.test.ts` fails + otherwise. A plural message is stored as `key_one`, `key_other`, … and looked up by its base key with `count`. +- Lucide icons outside a package control take a size class that sets box and stroke together: `mu-icon-xs` (12px), + `mu-icon-sm` (14px) or `mu-icon` (16px). No Tailwind sizes on 12–16px icons and no `strokeWidth`. ## Database And Proto Rules diff --git a/web/components.json b/web/components.json deleted file mode 100644 index 2082f482a..000000000 --- a/web/components.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "new-york", - "rsc": false, - "tsx": true, - "tailwind": { - "config": "", - "css": "src/index.css", - "baseColor": "zinc", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} \ No newline at end of file diff --git a/web/index.html b/web/index.html index 321a36eef..ffe06d8ba 100644 --- a/web/index.html +++ b/web/index.html @@ -9,8 +9,8 @@ - - + + diff --git a/web/package.json b/web/package.json index 8dcd34e53..738cfe612 100644 --- a/web/package.json +++ b/web/package.json @@ -17,7 +17,7 @@ "test:coverage": "vitest run --coverage" }, "dependencies": { - "@base-ui/react": "^1.7.0", + "@base-ui/react": "1.9.0", "@connectrpc/connect": "^2.1.1", "@connectrpc/connect-web": "^2.1.1", "@github/relative-time-element": "^5.0.0", @@ -27,6 +27,7 @@ "@tanstack/react-query": "^5.100.9", "@tanstack/react-query-devtools": "^5.100.9", "@usememos/editor": "26.11.0", + "@usememos/ui": "26.11.7", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "copy-to-clipboard": "^4.0.2", @@ -44,7 +45,6 @@ "pele": "1.13.0", "react": "^19.2.6", "react-dom": "^19.2.6", - "react-hot-toast": "^2.6.0", "react-i18next": "^17.0.11", "react-leaflet": "^5.0.0", "react-leaflet-cluster": "^4.1.3", @@ -69,7 +69,6 @@ "@vitejs/plugin-react": "^6.0.1", "babel-plugin-react-compiler": "1.0.0", "jsdom": "^29.1.1", - "tw-animate-css": "^1.4.0", "typescript": "^7.0.2", "vite": "^8.0.11", "vitest": "^4.1.5" diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index f44b447f9..ce0713234 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: .: dependencies: '@base-ui/react': - specifier: ^1.7.0 - version: 1.7.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) + specifier: 1.9.0 + version: 1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) '@connectrpc/connect': specifier: ^2.1.1 version: 2.1.1(@bufbuild/protobuf@2.12.0(patch_hash=9d60cec35402ba36bc21a72fefc68ccef8db0acb883504cc47c05a00a0029f8c)) @@ -41,6 +41,9 @@ importers: '@usememos/editor': specifier: 26.11.0 version: 26.11.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6) + '@usememos/ui': + specifier: 26.11.7 + version: 26.11.7(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6) class-variance-authority: specifier: ^0.7.1 version: 0.7.1 @@ -92,9 +95,6 @@ importers: react-dom: specifier: ^19.2.6 version: 19.2.6(react@19.2.6) - react-hot-toast: - specifier: ^2.6.0 - version: 2.6.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6) react-i18next: specifier: ^17.0.11 version: 17.0.11(i18next@26.3.6(typescript@7.0.2))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(typescript@7.0.2) @@ -162,9 +162,6 @@ importers: jsdom: specifier: ^29.1.1 version: 29.1.1 - tw-animate-css: - specifier: ^1.4.0 - version: 1.4.0 typescript: specifier: ^7.0.2 version: 7.0.2 @@ -278,8 +275,8 @@ packages: resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==} engines: {node: '>=6.9.0'} - '@base-ui/react@1.7.0': - resolution: {integrity: sha512-j+8QjX44C32jrXD/qyEAGpFr70FRpGL2CY61mQd9nBPWN737CK0xxD1ceJ055rW4RtdvFDT1e7otzdlfxvsYug==} + '@base-ui/react@1.9.0': + resolution: {integrity: sha512-S8CSYosASBKtpL8SWUfS78rFElfLijiCgA7oHOK22jCJ95FULsYyKwBNFOgudt0RA+/7yNc7F81bOvQnRgbBiQ==} engines: {node: '>=14.0.0'} peerDependencies: '@date-fns/tz': ^1.2.0 @@ -295,8 +292,8 @@ packages: date-fns: optional: true - '@base-ui/utils@0.3.2': - resolution: {integrity: sha512-oWy1aq/I2GmYjpl4PhEAhzflF8VPGKgZeq0xAWTbfD5KBWyxcN0ZP2+WHSUm/5Z6lVMBDLReLcoXwSYoRc/zNQ==} + '@base-ui/utils@0.5.0': + resolution: {integrity: sha512-dYGGcEttjkYiMoa5nHm8vLaJ2UcuTWxo3BFAwOYXeRg/q7UVVvA6cacEIXEs3FgBfK1CGtW1ptElqs7wsx+t9A==} peerDependencies: '@types/react': ^17 || ^18 || ^19 react: ^17 || ^18 || ^19 @@ -962,6 +959,14 @@ packages: react-dom: optional: true + '@usememos/ui@26.11.7': + resolution: {integrity: sha512-DwDZMoBSNLuPb841L9E6P9++URgAeoekKIRgqdPzDqZt7/gZsp8TtuaF6pkuQabC4yvXU4VsnPmU4/O0iwrB7g==} + peerDependencies: + '@base-ui/react': 1.9.0 + lucide-react: '>=1.0.0' + react: '>=18' + react-dom: '>=18' + '@vitejs/plugin-react@6.0.1': resolution: {integrity: sha512-l9X/E3cDb+xY3SWzlG1MOGt2usfEHGMNIaegaUGFsLkb3RCn/k8/TOXBcab+OndDI4TBtktT8/9BwwW8Vi9KUQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1165,11 +1170,6 @@ packages: gl-matrix@3.4.4: resolution: {integrity: sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ==} - goober@2.1.18: - resolution: {integrity: sha512-2vFqsaDVIT9Gz7N6kAL++pLpp41l3PfDuusHcjnGLfR6+huZkl6ziX+zgVC3ZxpqWhzH6pyDdGrCeDhMIvwaxw==} - peerDependencies: - csstype: ^3.0.10 - graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -1416,13 +1416,6 @@ packages: peerDependencies: react: ^19.2.6 - react-hot-toast@2.6.0: - resolution: {integrity: sha512-bH+2EBMZ4sdyou/DPrfgIouFpcRLCJ+HoCA32UoAYHn6T3Ur5yfcDCeSr5mwldl6pFOsiocmrXMuoCJ1vV8bWg==} - engines: {node: '>=10'} - peerDependencies: - react: '>=16' - react-dom: '>=16' - react-i18next@17.0.11: resolution: {integrity: sha512-cDtkXgxjuFTWUH6V+aQn1Ve5vDiUztCNPWW5GtSHDccsgRXO1nE6QFWCEmc1KAutrb3OUv87wFShJL5RhUwPXg==} peerDependencies: @@ -1487,8 +1480,8 @@ packages: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} - reselect@5.2.0: - resolution: {integrity: sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==} + reselect@5.3.0: + resolution: {integrity: sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg==} resolve-protobuf-schema@2.1.0: resolution: {integrity: sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==} @@ -1578,9 +1571,6 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} - tw-animate-css@1.4.0: - resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==} - typescript@7.0.2: resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} engines: {node: '>=16.20.0'} @@ -1604,6 +1594,11 @@ packages: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + use-sync-external-store@1.7.0: + resolution: {integrity: sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + uuid@11.1.0: resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} hasBin: true @@ -1859,26 +1854,26 @@ snapshots: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.28.5 - '@base-ui/react@1.7.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': + '@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': dependencies: - '@babel/runtime': 7.29.2 - '@base-ui/utils': 0.3.2(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) + '@babel/runtime': 7.29.7 + '@base-ui/utils': 0.5.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) '@floating-ui/react-dom': 2.1.9(react-dom@19.2.6(react@19.2.6))(react@19.2.6) '@floating-ui/utils': 0.2.12 react: 19.2.6 react-dom: 19.2.6(react@19.2.6) - use-sync-external-store: 1.6.0(react@19.2.6) + use-sync-external-store: 1.7.0(react@19.2.6) optionalDependencies: '@types/react': 19.2.14 - '@base-ui/utils@0.3.2(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': + '@base-ui/utils@0.5.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 '@floating-ui/utils': 0.2.12 react: 19.2.6 react-dom: 19.2.6(react@19.2.6) - reselect: 5.2.0 - use-sync-external-store: 1.6.0(react@19.2.6) + reselect: 5.3.0 + use-sync-external-store: 1.7.0(react@19.2.6) optionalDependencies: '@types/react': 19.2.14 @@ -2378,6 +2373,13 @@ snapshots: react: 19.2.6 react-dom: 19.2.6(react@19.2.6) + '@usememos/ui@26.11.7(@base-ui/react@1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6))(lucide-react@1.34.0(react@19.2.6))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': + dependencies: + '@base-ui/react': 1.9.0(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) + lucide-react: 1.34.0(react@19.2.6) + react: 19.2.6 + react-dom: 19.2.6(react@19.2.6) + '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0)(@babel/runtime@7.29.7)(rolldown@1.0.0-rc.18)(vite@8.0.11(@types/node@24.12.2)(jiti@2.6.1)))(babel-plugin-react-compiler@1.0.0)(vite@8.0.11(@types/node@24.12.2)(jiti@2.6.1))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.7 @@ -2545,10 +2547,6 @@ snapshots: gl-matrix@3.4.4: {} - goober@2.1.18(csstype@3.2.3): - dependencies: - csstype: 3.2.3 - graceful-fs@4.2.11: {} html-encoding-sniffer@6.0.0: @@ -2761,13 +2759,6 @@ snapshots: react: 19.2.6 scheduler: 0.27.0 - react-hot-toast@2.6.0(react-dom@19.2.6(react@19.2.6))(react@19.2.6): - dependencies: - csstype: 3.2.3 - goober: 2.1.18(csstype@3.2.3) - react: 19.2.6 - react-dom: 19.2.6(react@19.2.6) - react-i18next@17.0.11(i18next@26.3.6(typescript@7.0.2))(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(typescript@7.0.2): dependencies: '@babel/runtime': 7.29.2 @@ -2820,7 +2811,7 @@ snapshots: require-from-string@2.0.2: {} - reselect@5.2.0: {} + reselect@5.3.0: {} resolve-protobuf-schema@2.1.0: dependencies: @@ -2907,8 +2898,6 @@ snapshots: tslib@2.8.1: optional: true - tw-animate-css@1.4.0: {} - typescript@7.0.2: optionalDependencies: '@typescript/typescript-aix-ppc64': 7.0.2 @@ -2946,6 +2935,10 @@ snapshots: dependencies: react: 19.2.6 + use-sync-external-store@1.7.0(react@19.2.6): + dependencies: + react: 19.2.6 + uuid@11.1.0: {} vite@8.0.11(@types/node@24.12.2)(jiti@2.6.1): diff --git a/web/src/components/ActivityCalendar/CalendarCell.tsx b/web/src/components/ActivityCalendar/CalendarCell.tsx index f86093fc0..10ada4a5e 100644 --- a/web/src/components/ActivityCalendar/CalendarCell.tsx +++ b/web/src/components/ActivityCalendar/CalendarCell.tsx @@ -1,5 +1,5 @@ +import { Tooltip } from "@usememos/ui"; import { memo } from "react"; -import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import { getChipClassName } from "./cellStyles"; import type { CalendarDayCell } from "./types"; @@ -52,12 +52,12 @@ export const CalendarCell = memo(({ day, maxCount, tooltipText, onClick }: Calen } return ( - - - + + +

{tooltipText}

-
-
+ + ); }); diff --git a/web/src/components/ActivityCalendar/MonthCalendar.tsx b/web/src/components/ActivityCalendar/MonthCalendar.tsx index fceda818a..2efcb4e9a 100644 --- a/web/src/components/ActivityCalendar/MonthCalendar.tsx +++ b/web/src/components/ActivityCalendar/MonthCalendar.tsx @@ -9,7 +9,13 @@ import type { MonthCalendarProps } from "./types"; import { calculateMaxCount, getTooltipText } from "./utils"; /** The type of a weekday column label, shared by every month grid. */ -export const WEEKDAY_LABEL_CLASSES = "text-2xs font-medium uppercase tracking-[0.04em] text-muted-foreground/50"; +/** + * Seven 28px columns, the sidebar's one control height, so day cells land on whole pixels; the + * 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. */ +export const WEEKDAY_LABEL_CLASSES = "mu-caption text-mu-ink-muted"; /** Localized weekday labels starting on the instance's first day of the week. */ export const useWeekdayLabels = (weekStartDayOffset: number) => { @@ -46,9 +52,9 @@ export const MonthCalendar = memo(({ month, data, selectedDate, onClick, timeBas }); return ( -
+
{/* Every day button already announces its full date, so the initials are decoration. */} -