diff --git a/DESIGN.md b/DESIGN.md index 901b489..feaa5ba 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -72,3 +72,40 @@ Primer is the open-source design system that powers GitHub. It is built to be ac - **Subtle Depth:** Uses thin borders and very soft shadows (`0 1px 0 rgba(27,31,35,0.04)`) rather than large drop shadows. - **High Contrast Focus:** Focus states are highly visible, usually using a 2px blue ring. - **Hover States:** Most interactive elements use a subtle background color shift (e.g., `bgColor-muted`) to indicate interactivity. + + +## Product interface and motion (2026-10-28) + +The accepted references live in `docs/assets/ui/2026-10-28/`. Their layout, +component geometry, and hierarchy guide the six application routes. Keep the +existing SubMan mark, horizontal route navigation, system fonts, and Octicons. +Use local CJK platform font fallbacks alongside the Latin system stack. + +- The main canvas is `canvas.default` in both themes. Use `canvas.subtle` for + mastheads, table headings, disclosures, and supporting regions. Avoid enclosing + every toolbar or metadata group in another bordered box. +- Page titles and their short descriptions establish the primary hierarchy. + Lists use one heading band, readable secondary metadata, restrained protocol + labels, and consistent row actions. Resource checkboxes enable resources; + they never imply bulk selection. +- Overview columns fit their own content. Aggregation and client exports share + a primary editor/preview and a quieter 320px publication rail. Related actions + appear once in their working context. +- Shared dialogs own focus containment, Escape, focus restoration, background + inertness, and the scroll lock. Small-screen editors use bottom sheets with + fixed action footers and safe-area spacing. Do not show a drag handle without + a drag gesture. Use 44px touch targets. +- Hover/press feedback takes 120ms; navigation, disclosure, and surface entry + take 180ms; surface exit takes 140ms. Route content enters over 160ms with 4px + travel. Copy acknowledgement lasts 1.2 seconds after clipboard success. +- Motion never delays data readiness or business completion. Honor reduced + motion in CSS, Svelte transitions, route animation, and preview drag sorting. + Finish active finite UI motion when the preference changes. +- Only the shared operation presenter maps Workspace results to `pending`, + `success`, `attention`, or `error` feedback. Only `remote-committed` permits + success wording and draft finalization. Queued or blocked operations retain + drafts; clipboard acknowledgement is separate from cloud publication. + +The root `data-theme` always holds the resolved light/dark palette, including +automatic mode. `data-theme-mode` and persisted preference keep the user choice. +The first-paint script retains its SvelteKit CSP nonce. diff --git a/docs/archive/plans/2026-10-28-primer-interaction-system.md b/docs/archive/plans/2026-10-28-primer-interaction-system.md new file mode 100644 index 0000000..ad07802 --- /dev/null +++ b/docs/archive/plans/2026-10-28-primer-interaction-system.md @@ -0,0 +1,151 @@ +# Primer interface and interaction system + +## Isolation and approved references + +- Worktree: `/root/Clouds/SubMan-premium-ui` +- Branch: `feat/primer-interaction-system` +- Base: `4e01863dd5f9f378ec035099d26049ae86c2f6ca` +- The user approved all six routes and subtle, perceptible interaction motion. +- Approved planning artwork, generated with the built-in image tool: + [nodes](../../assets/ui/2026-10-28/nodes-concept.png), + [aggregation](../../assets/ui/2026-10-28/aggregate-concept.png), and + [mobile editing](../../assets/ui/2026-10-28/mobile-edit-concept.png). +- The mobile drag handle is intentionally omitted, as approved. Demo records + in the artwork are not application defaults or a source of business data. +- Local implementation, verification, and atomic commits are authorized. + Remote publication, merging, Wiki publication, and deployment remain separate. + +## Extracted design system + +- Main backgrounds: true white `#ffffff`, dark `#0d1117`; subtle surface + `#f6f8fa` / `#161b22`; neutral border `#d0d7de` / `#30363d`. +- Retain existing blue links, green primary actions, coral active underlines, + semantic attention/danger colors, and first-paint theme behavior. +- System sans and local CJK fallbacks; monospace for URI/configuration content. + Strong page headings, 18px resource titles, readable 12-14px metadata, + consistent 40px desktop controls, and 44px narrow-screen touch targets. +- Restrained 6px controls and 8px dialog geometry; 12px top sheet corners. + Use fine rules for lists and form groups and reserve elevation for overlays. +- Existing Octicons supply navigation, status, search, chevrons, edit, copy, + delete, preview, publication, and dismiss actions. The existing brand is reused. +- Existing shared components and new page header, dialog, action button, copy + button, and operation feedback primitives own repeated behavior. +- Native Svelte/HTML/CSS render every control and string. Artwork is reference + evidence only; no generated UI bitmap appears in the product. + +## Content and interaction inventory + +- Keep navigation meaning: Overview, Nodes, Aggregate, Exports, Gists, Settings. + Keep connected, pending, loading, and repair status visible and truthful. +- Nodes retain source tabs, filtering, creation, import, enable, edit, preview, + copy, and delete. Header copy: "Manage nodes and subscription sources." +- Aggregation retains all source/rule fields, advanced options, preview and + sorting, target CRUD, publication, and save-and-publish. Header copy: + "Combine sources, preview rules, and publish output." +- Exports retain profile CRUD, preview generation, copy/download, publication, + and confirmed remote links. Gists retain safe file ownership/deletion rules. + Settings retain authentication, migration preview/confirmation, and recovery. +- Cloud gating, Workspace identity, mutation IDs, revisions, journaling, and + confirmed publication baselines continue through the existing boundaries. +- Shared operation feedback is derived in the presenter. Button busy state + prevents duplicate submission; pending/attention never imply remote success. +- Dialogs trap/restore focus, make background content inert, lock scrolling, + and expose keyboard and visible close actions. Menus retain keyboard behavior. +- Reduced motion removes decorative transitions and movement while retaining + state text and progress meaning. Rapid interactions cancel obsolete animation. + +## Validation + +Use Bun 1.3.14 and isolated dependencies, output, local Worker state, browser +contexts, and ports. Browser plugin is absent; use Playwright Chromium. +Validate all six routes, both themes/languages, native concept sizes, desktop, +tablet, 390px/320px layouts, normal/reduced motion, and slow/error/confirmed +cloud states. No production credentials or real Gists are used. The completed +execution evidence follows. + +## Implementation and local verification + +The implementation uses shared native Svelte components and actions. No runtime +dependency was added. The public API, Workspace document, storage boundaries, +mutation protocol, and credential handling are unchanged. Automatic theme mode +now applies the resolved palette both before first paint and after an OS theme +change; the first-paint nonce and response security headers remain intact. + +All commands use Bun 1.3.14 in the isolated worktree. Local Workers and browser +fixtures use temporary state and synthetic Gist responses. Wrangler deployment +validation is a dry run; no production deployment or real-provider write occurs. + +| Check | Result | +| --- | --- | +| `bun run docs:check` | 37 Wiki pages; paired languages and local links valid | +| `bun test` | 678 passed; 3,073 assertions | +| `bun run test:sing-box` | 15 generated outbounds valid with sing-box 1.14.0 | +| `bun run check` | No Svelte/type warnings or errors; Worker types reproducible | +| `bun run lint` | 203 files checked without fixes | +| `bun run build` | Production Worker and browser bundles built | +| `bun run test:cf` | 8 local Worker integration tests passed | +| `bun run deploy:check` | Wrangler 4.127.0 dry run completed | +| `bun run test:e2e` with isolated local Worker configuration | 63 Chromium tests passed | +| Responsive visual matrix | 96 views passed: six routes, two themes, two languages, four widths | + +Browser verification uses installed Playwright Chromium because the Browser +plugin is unavailable. Its server lifecycle owns a local compiled Worker on +port 8467 and stops it after each run. Soft keyboard sizing is simulated through +VisualViewport events; physical iOS/Android keyboards and Safari/Firefox are +outside this local evidence. + +The responsive matrix covers 1440px, 768px, 390px, and 320px. Browser evidence: + +| Rendered check | Result | +| --- | --- | +| Page identity | All six final URLs and document titles match their routes after cloud readiness | +| Meaningful content | Route headings and the seeded business/settings content are present | +| Framework overlay | No development error overlay appears | +| Console health | No page errors or relevant console warnings/errors in the 96-view matrix | +| Screenshots | Desktop, narrow layouts, both themes, native reference sizes, edit and pending states captured and inspected | +| Interaction proof | Clipboard success/failure, held cloud confirmation, retry drafts, keyboard/focus, nested menu Escape, mobile scroll/keyboard sizing, rapid disclosure and theme preference tests pass | + +The edit flow opens a resource, changes a draft, submits once, and holds the +mocked mutation response. The editor and loading action stay visible without a +success notice. Releasing cloud confirmation finalizes the draft and closes the +editor. Retryable delivery instead keeps the draft and pending presentation. +The clipboard flow shows its check only after a successful write and reports a +failed write without showing success. + +The temporary Playwright configurations use the repository's `test:e2e` script +with `--config /tmp/subman-premium-ui-qa/playwright.theme.config.mts` for the +full suite and `--config /tmp/subman-premium-ui-qa/playwright.visual.config.mts` +for screenshots and geometry checks. Final visual checks also verify file +header/row column alignment and the rule picker's single-line desktop actions. + +## Reference comparison + +Compare the approved artwork directly with rendered screenshots at 1505x1045 +(nodes), 1504x1045 (aggregation), and 390x844 (mobile editing). Generated artwork +supplies visual direction; controls, text, and business state remain native UI. + +| Comparison point | Implemented result | +| --- | --- | +| Canvas and palette | White/dark main canvas, subtle masthead and list headings, fine neutral rules, blue links, green primary actions, coral active line | +| Shell and hierarchy | Two horizontal header bands, shared gutters, strong page heading and short description, actions in the same working context | +| Nodes list | Open filters, one heading band with enable meaning and counts, 18px resource names, readable metadata, aligned persistent row actions | +| Aggregation | Editor and preview share one surface; a 320px publication rail keeps target settings, publication actions, and confirmed output together | +| Controls and typography | 40px desktop controls, 44px mobile targets, restrained geometry, system sans/CJK fallbacks and monospace URI content | +| Mobile editing | Bottom sheet, focused first field, scrollable content, fixed footer, safe-area and VisualViewport sizing, background scroll lock and focus restoration | +| Feedback and motion | Sliding active line, short route/surface/disclosure motion, clipboard acknowledgement, truthful asynchronous action states, reduced-motion support | + +Intentional differences from artwork: + +- Keep actual timestamps, region flags, publication prerequisites, and existing + rule/target deletion controls. Demo values do not replace application data. +- Use platform system fonts and existing Octicons. CJK glyph shapes and text + metrics therefore differ from the raster concepts. +- Omit the approved decorative sheet drag handle. No drag-to-dismiss behavior + is implied. +- At widths of 360px or less, move the project GitHub action beside navigation + overflow to preserve the brand and connection controls without overlap. +- Retain a selectable full publication URI with visual ellipsis and a copy + action. Confirmed publication metadata comes from the cloud baseline. + +Temporary QA logs and screenshots remain under `/tmp/subman-premium-ui-qa` and +`/tmp/subman-premium-*.log`. Only the approved source artwork is versioned. diff --git a/docs/assets/ui/2026-10-28/aggregate-concept.png b/docs/assets/ui/2026-10-28/aggregate-concept.png new file mode 100644 index 0000000..a5194b3 Binary files /dev/null and b/docs/assets/ui/2026-10-28/aggregate-concept.png differ diff --git a/docs/assets/ui/2026-10-28/mobile-edit-concept.png b/docs/assets/ui/2026-10-28/mobile-edit-concept.png new file mode 100644 index 0000000..5f67766 Binary files /dev/null and b/docs/assets/ui/2026-10-28/mobile-edit-concept.png differ diff --git a/docs/assets/ui/2026-10-28/nodes-concept.png b/docs/assets/ui/2026-10-28/nodes-concept.png new file mode 100644 index 0000000..3193d00 Binary files /dev/null and b/docs/assets/ui/2026-10-28/nodes-concept.png differ diff --git a/docs/wiki/Changelog.md b/docs/wiki/Changelog.md index f7d8cc4..0e1df5f 100644 --- a/docs/wiki/Changelog.md +++ b/docs/wiki/Changelog.md @@ -8,6 +8,21 @@ production deployment and real-provider acceptance require separate evidence. ## Unreleased +### 2026-10-28 - Primer interface and interaction system + +- Unified the six routes around the approved GitHub-style concepts: white/dark + main canvases, clearer page headings, open filter bars, one resource heading + band, content-sized overview columns, and consistent editor/publication layouts. +- Added shared dialogs, copy acknowledgement, asynchronous action feedback, + animated navigation, disclosure and surface transitions, and reduced-motion + handling. Mobile editors use accessible bottom sheets with fixed action footers. +- Kept cloud confirmation authoritative: pending, retrying, blocked, and uncertain + results retain drafts; only confirmed remote commits receive success feedback. +- Fixed automatic theme resolution before first paint and when the system + preference changes, while keeping explicit light/dark preferences authoritative. +- Preserved the public API, Workspace schema, persistence, and delivery protocol. + + ### 2026-10-27 - UI hierarchy and interaction polish - Separated the linked brand toolbar from navigation, aligned the header with the diff --git a/docs/wiki/Changelog.zh-CN.md b/docs/wiki/Changelog.zh-CN.md index e75e73a..281291d 100644 --- a/docs/wiki/Changelog.zh-CN.md +++ b/docs/wiki/Changelog.zh-CN.md @@ -7,6 +7,18 @@ ## 未发布 +### 2026-10-28 - Primer 界面与交互系统 + +- 按已确认的 GitHub 风格概念稿统一六个页面:明暗主画布、更清楚的页面标题、 + 开放式筛选栏、单层资源表头、随内容自然增高的首页分栏,以及一致的编辑与发布布局。 +- 增加共享弹层、复制确认、异步操作反馈、导航指示线、展开和进出场动效, + 并统一适配减少动态效果偏好;手机编辑采用固定操作栏的无障碍底部弹层。 +- 继续以云端确认为准:等待、重试、阻塞和确认不确定时保留草稿, + 仅在远端提交确认后显示成功反馈。 +- 修复自动主题在首屏及系统偏好变化时未应用页面颜色的问题,显式明暗选择继续优先。 +- 对外 API、Workspace 结构、持久化和投递协议保持不变。 + + ### 2026-10-27 - 页面层级与交互优化 - 区分可返回首页的品牌工具栏与业务导航,统一页头和正文对齐;增加可见的云端状态、 diff --git a/e2e/ui-interactions.spec.ts b/e2e/ui-interactions.spec.ts new file mode 100644 index 0000000..b0f672d --- /dev/null +++ b/e2e/ui-interactions.spec.ts @@ -0,0 +1,308 @@ +import { expect, test } from "@playwright/test"; +import { defaultUiData, seedUiWorkspace } from "./ui-workspace-fixture"; + +const mutationRoute = "**/api/workspaces/**/mutations"; + +test.beforeEach(async ({ page, context }) => { + await seedUiWorkspace(page, context); + await page.goto("/nodes"); + await expect(page.locator(".app-header-link-connected")).toBeVisible(); +}); + +test("copy feedback acknowledges only a successful clipboard write", async ({ + page, +}) => { + await page.evaluate(() => { + Object.defineProperty(navigator, "clipboard", { + configurable: true, + value: { writeText: async () => {} }, + }); + }); + const button = page.getByRole("button", { name: "Copy URI", exact: true }); + await button.click(); + await expect(button).toHaveAttribute("data-feedback", "copied"); + await expect( + page.getByRole("status").filter({ hasText: "Copied to clipboard" }), + ).toBeVisible(); + await expect(button).toHaveAttribute("data-feedback", "idle"); + await page.evaluate(() => { + Object.defineProperty(navigator, "clipboard", { + configurable: true, + value: { + writeText: async () => { + throw new Error("Fixture denied"); + }, + }, + }); + }); + await button.click(); + await expect( + page.getByRole("status").filter({ hasText: "Copy failed" }), + ).toBeVisible(); + await expect(button).toHaveAttribute("data-feedback", "idle"); +}); + +test("edit stays open and busy until the original cloud mutation is confirmed", async ({ + page, + context, +}) => { + let release = () => {}; + const gate = new Promise((resolve) => { + release = resolve; + }); + let requests = 0; + await context.route(mutationRoute, async (route) => { + requests++; + const mutation = route.request().postDataJSON(); + await gate; + const data = structuredClone(defaultUiData); + data.nodes = [mutation.payload.node]; + await route.fulfill({ + json: { + status: "committed", + mutationId: mutation.mutationId, + workspaceId: mutation.workspaceId, + committedRevision: mutation.expectedRevision + 1, + committedAt: mutation.createdAt, + receipt: { kind: mutation.kind, entityId: mutation.payload.node.id }, + document: { + version: 2, + schemaVersion: 2, + workspaceId: mutation.workspaceId, + revision: mutation.expectedRevision + 1, + updatedAt: mutation.createdAt, + lastMutationId: mutation.mutationId, + data, + tombstones: { + nodes: [], + subscriptions: [], + aggregates: [], + publishTargets: [], + clientExports: [], + }, + }, + }, + }); + }); + await page.getByRole("button", { name: "Edit node", exact: true }).click(); + const dialog = page.getByRole("dialog", { name: "Edit Node", exact: true }); + await dialog + .getByRole("textbox", { name: "Name", exact: true }) + .fill("Cloud-confirmed edit"); + const save = dialog.getByRole("button", { name: "Save", exact: true }); + await save.click(); + await expect.poll(() => requests).toBe(1); + await expect(dialog).toBeVisible(); + await expect(dialog.locator(".gh-action-button")).toHaveAttribute( + "aria-busy", + "true", + ); + await expect(dialog.locator(".gh-action-button")).toBeDisabled(); + await expect( + dialog.getByRole("textbox", { name: "Name", exact: true }), + ).toHaveValue("Cloud-confirmed edit"); + await expect( + page.getByRole("status").filter({ hasText: "Node updated" }), + ).toHaveCount(0); + release(); + await expect(dialog).toBeHidden(); + await expect( + page.getByRole("button", { name: "Cloud-confirmed edit", exact: true }), + ).toBeVisible(); + expect(requests).toBe(1); +}); + +test("retryable cloud delivery retains the editor and pending presentation", async ({ + page, + context, +}) => { + await context.route(mutationRoute, (route) => + route.fulfill({ + status: 503, + json: { + error: { + code: "upstream-unavailable", + disposition: "retryable-upstream", + message: "Fixture temporarily unavailable", + }, + }, + }), + ); + await page.getByRole("button", { name: "Edit node", exact: true }).click(); + const dialog = page.getByRole("dialog", { name: "Edit Node", exact: true }); + await dialog + .getByRole("textbox", { name: "Name", exact: true }) + .fill("Retained edit"); + await dialog.getByRole("button", { name: "Save", exact: true }).click(); + await expect(dialog.locator(".gh-operation-feedback")).toHaveAttribute( + "data-feedback", + "pending", + ); + await expect(dialog).toBeVisible(); + await expect( + dialog.getByRole("textbox", { name: "Name", exact: true }), + ).toHaveValue("Retained edit"); + await expect(dialog.locator(".gh-action-button")).toBeDisabled(); + await expect(dialog.locator('[data-feedback="success"]')).toHaveCount(0); +}); + +test("navigation and menus respect reduced motion without losing keyboard focus", async ({ + page, +}) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + const nav = page.getByRole("navigation", { name: "Primary" }); + await nav.getByRole("link", { name: "Aggregate", exact: true }).click(); + await expect(page).toHaveURL(/\/aggregate$/); + await expect( + nav.getByRole("link", { name: "Aggregate", exact: true }), + ).toHaveAttribute("aria-current", "page"); + await expect + .poll(() => + nav.evaluate((element) => + getComputedStyle(element, "::after") + .transitionDuration.split(",") + .every((value) => Number.parseFloat(value) === 0), + ), + ) + .toBe(true); + await nav.getByRole("link", { name: "Nodes", exact: true }).click(); + await page.getByRole("button", { name: "Edit node", exact: true }).click(); + const dialog = page.getByRole("dialog", { name: "Edit Node", exact: true }); + await expect( + dialog.getByRole("textbox", { name: "Name", exact: true }), + ).toBeFocused(); + await page.keyboard.press("Escape"); + await expect(dialog).toBeHidden(); + await expect( + page.getByRole("button", { name: "Edit node", exact: true }), + ).toBeFocused(); + await expect(page.locator("main")).not.toHaveAttribute("inert"); +}); + +test("mobile editor locks background scrolling and retains drafts through selection menus", async ({ + page, +}) => { + await page.setViewportSize({ width: 320, height: 844 }); + const header = await page.evaluate(() => ({ + brand: + document.querySelector(".app-repo-title span")?.getBoundingClientRect() + .right ?? 0, + actions: + document.querySelector(".app-repo-actions")?.getBoundingClientRect() + .left ?? 0, + })); + expect(header.brand).toBeLessThan(header.actions); + await expect( + page.getByRole("link", { name: "Open project on GitHub", exact: true }), + ).toBeVisible(); + await page.setViewportSize({ width: 390, height: 844 }); + await page.getByRole("button", { name: "Edit node", exact: true }).click(); + const dialog = page.getByRole("dialog", { name: "Edit Node", exact: true }); + await expect(page.locator("body")).toHaveCSS("overflow", "hidden"); + const name = dialog.getByRole("textbox", { name: "Name", exact: true }); + await name.fill("Mobile draft"); + await dialog.locator('[aria-haspopup="menu"]').click(); + await page.keyboard.press("Escape"); + await expect(dialog).toBeVisible(); + await expect(name).toHaveValue("Mobile draft"); + await page.evaluate(async () => { + await Promise.all( + document + .getAnimations() + .filter( + (animation) => animation.effect?.getTiming().iterations !== Infinity, + ) + .map((animation) => animation.finished.catch(() => {})), + ); + }); + const bounds = await dialog.boundingBox(); + expect(bounds?.x).toBe(0); + expect(bounds && bounds.y + bounds.height).toBeCloseTo(844, 0); + await page.evaluate(() => { + Object.defineProperty(visualViewport, "height", { + configurable: true, + value: 500, + }); + visualViewport?.dispatchEvent(new Event("resize")); + }); + await expect + .poll(async () => { + const box = await dialog.boundingBox(); + return Math.round((box?.y ?? 0) + (box?.height ?? 0)); + }) + .toBe(500); + await expect(name).toHaveValue("Mobile draft"); + await page.evaluate(() => { + if (visualViewport) Reflect.deleteProperty(visualViewport, "height"); + visualViewport?.dispatchEvent(new Event("resize")); + }); + + await dialog.getByRole("button", { name: "Cancel", exact: true }).click(); + await expect(dialog).toBeHidden(); + await expect(page.locator("body")).not.toHaveCSS("overflow", "hidden"); +}); + +test("advanced disclosure handles rapid toggles and keeps unsaved field values", async ({ + page, +}) => { + await page + .getByRole("navigation", { name: "Primary" }) + .getByRole("link", { name: "Aggregate", exact: true }) + .click(); + const panel = page.locator("details.gh-advanced-options"); + await panel.locator("summary").click(); + const rename = panel.getByRole("textbox", { + name: "Rename Rules", + exact: true, + }); + await rename.fill("Old = New"); + await panel.locator("summary").dblclick(); + await expect(panel).toHaveAttribute("open"); + await expect(rename).toHaveValue("Old = New"); + await panel.locator("summary").click(); + await expect(panel).not.toHaveAttribute("open"); + await panel.locator("summary").click(); + await expect(rename).toHaveValue("Old = New"); +}); + +test("automatic theme follows the OS while explicit light mode stays fixed", async ({ + page, +}) => { + await page.emulateMedia({ colorScheme: "dark" }); + await expect(page.locator("html")).toHaveAttribute( + "data-theme-mode", + "system", + ); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(13, 17, 23)", + ); + await page.reload(); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(13, 17, 23)", + ); + await page.locator(".theme-menu-button").click(); + await page.getByRole("menuitemradio", { name: "Light", exact: true }).click(); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(255, 255, 255)", + ); + await page.emulateMedia({ colorScheme: "light" }); + await page.emulateMedia({ colorScheme: "dark" }); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(255, 255, 255)", + ); + await page.locator(".theme-menu-button").click(); + await page.getByRole("menuitemradio", { name: "Auto", exact: true }).click(); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(13, 17, 23)", + ); + await page.emulateMedia({ colorScheme: "light" }); + await expect(page.locator("body")).toHaveCSS( + "background-color", + "rgb(255, 255, 255)", + ); +}); diff --git a/src/app-css.test.ts b/src/app-css.test.ts index 76c9e07..a3c8b5a 100644 --- a/src/app-css.test.ts +++ b/src/app-css.test.ts @@ -14,7 +14,7 @@ test("global theme uses Primer system font stacks without remote font imports", expect(appCssSource).not.toContain('"Roboto"'); expect(appCssSource).not.toContain('"Roboto Mono"'); expect(appCssSource).toContain( - '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif', + '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial', ); expect(appCssSource).toContain( 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono"', @@ -28,8 +28,8 @@ test("global theme uses Primer system font stacks without remote font imports", test("desktop theme keeps stable base size while increasing tabs", () => { expect(appCssSource).toContain("@media (min-width: 1024px)"); - expect(appCssSource).toContain("html {\n\tfont-size: 14px;"); + expect(appCssSource).toContain("font-size: 14px;"); expect(appCssSource).not.toContain("html {\n\t\tfont-size: 15px;"); expect(appCssSource).toContain(".gh-underlinenav-item,\n\t.gh-tab"); - expect(appCssSource).toContain("font-size: 1rem;"); + expect(appCssSource).toContain("font-size: 16px;"); }); diff --git a/src/app.css b/src/app.css index 0b71be4..5a0a414 100644 --- a/src/app.css +++ b/src/app.css @@ -3,7 +3,8 @@ @theme { --font-sans: - -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, + -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, + "PingFang SC", "Microsoft YaHei", "WenQuanYi Zen Hei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", @@ -60,6 +61,10 @@ --header-hover: rgba(240, 246, 252, 0.08); --header-border: rgba(240, 246, 252, 0.1); --radius: 6px; + --motion-fast: 120ms; + --motion-normal: 180ms; + --motion-exit: 140ms; + --motion-easing: cubic-bezier(0.2, 0.8, 0.2, 1); --control-bg: #ffffff; --control-border: #d0d7de; --control-shadow: inset 0 1px 0 rgba(208, 215, 222, 0.2); @@ -102,13 +107,14 @@ } html { + scrollbar-gutter: stable; font-size: 14px; - background: var(--canvas-subtle); + background: var(--canvas-default); -webkit-text-size-adjust: 100%; } body { - background: var(--canvas-subtle); + background: var(--canvas-default); color: var(--fg-default); font-family: var(--font-sans); font-size: 1rem; @@ -166,11 +172,11 @@ pre { } .gh-box-header { - @apply flex min-h-10 items-center justify-between gap-3 border-b border-border-default bg-canvas-subtle px-4 py-2 text-sm font-semibold; + @apply flex min-h-14 items-center justify-between gap-3 border-b border-border-default bg-canvas-subtle px-5 py-3 text-sm font-semibold; } .gh-box-row { - @apply border-b border-border-default px-4 py-3 last:border-b-0; + @apply border-b border-border-muted px-5 py-4 last:border-b-0; } .gh-box-row:hover { @@ -178,10 +184,12 @@ pre { } .gh-btn { - @apply inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border-default px-3 py-1.5 text-sm font-medium text-fg-default transition-colors disabled:cursor-not-allowed disabled:opacity-60; - min-height: 32px; + @apply inline-flex h-10 items-center justify-center gap-2 rounded-md border border-border-default px-3.5 py-2 text-sm font-medium text-fg-default transition-colors disabled:cursor-not-allowed disabled:opacity-60; + min-height: 40px; background: var(--button-bg); box-shadow: var(--shadow-sm); + transition-duration: var(--motion-fast); + transition-timing-function: var(--motion-easing); } .gh-btn:hover { @@ -228,11 +236,12 @@ pre { } .gh-btn-invisible:hover { - background: var(--canvas-subtle); + background: var(--canvas-default); } .gh-btn-sm { - @apply px-2 py-1 text-xs; + @apply h-9 px-2.5 py-1 text-sm; + min-height: 36px; } .gh-btn-group { @@ -256,21 +265,22 @@ pre { } .gh-icon-button { - @apply inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-fg-muted transition-colors; + @apply inline-flex h-9 w-9 items-center justify-center rounded-md border border-transparent text-fg-muted transition-colors; } .gh-icon-button:hover { - background: var(--canvas-subtle); + background: var(--canvas-default); color: var(--fg-default); } .gh-input, .gh-select { - @apply h-8 w-full rounded-md border px-3 text-sm text-fg-default transition-[border-color,box-shadow,background-color] placeholder:text-fg-subtle focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:text-fg-subtle; + @apply h-10 w-full rounded-md border px-3 text-sm text-fg-default transition-[border-color,box-shadow,background-color] placeholder:text-fg-subtle focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:text-fg-subtle; background-color: var(--control-bg); border-color: var(--control-border); box-shadow: var(--control-shadow); line-height: 20px; + height: 40px; } .gh-input:hover:not(:disabled), @@ -367,7 +377,9 @@ input[type="checkbox"]:indeterminate { } .gh-underlinenav-item { - @apply inline-flex h-12 items-center gap-2 px-2.5 text-sm font-medium text-fg-default transition-colors; + min-height: 64px; + font-size: 16px; + @apply inline-flex h-14 items-center gap-2 px-3 text-sm font-medium text-fg-default transition-colors; border-bottom: 2px solid transparent; white-space: nowrap; } @@ -388,6 +400,8 @@ input[type="checkbox"]:indeterminate { } .gh-tab { + font-size: 16px; + min-height: 46px; @apply inline-flex items-center gap-1.5 rounded-t-md px-3 py-2 text-sm font-medium text-fg-muted transition-colors; border-bottom: 2px solid transparent; } @@ -404,11 +418,11 @@ input[type="checkbox"]:indeterminate { @media (min-width: 1024px) { .gh-underlinenav-item, .gh-tab { - font-size: 1rem; + font-size: 16px; } .gh-underlinenav-item { - @apply h-13 px-3; + @apply h-14 px-3.5; } .gh-tab { @@ -425,8 +439,7 @@ input[type="checkbox"]:indeterminate { } .gh-filter-bar { - @apply flex flex-col gap-3 rounded-md border border-border-default bg-canvas-default p-3 sm:flex-row sm:items-center sm:justify-between; - box-shadow: var(--shadow-sm); + @apply flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between; } .gh-filter-controls { @@ -434,23 +447,27 @@ input[type="checkbox"]:indeterminate { } .gh-page { - @apply flex flex-col gap-4 pb-10; + @apply flex flex-col pb-12; + gap: 32px; } .gh-page-header { - @apply flex flex-wrap items-center justify-between gap-3 border-b border-border-default pb-4; + @apply flex flex-wrap items-start justify-between gap-4 pb-1; } .gh-page-heading { - @apply min-w-0 space-y-1; + @apply min-w-0 space-y-2; } .gh-page-title { - @apply text-2xl font-semibold leading-tight text-fg-default; + @apply font-semibold leading-tight text-fg-default; + font-size: 36px; + font-weight: 700; + letter-spacing: -0.025em; } .gh-page-actions { - @apply flex flex-wrap items-center gap-2; + @apply flex flex-wrap items-center gap-2 pt-1; } .gh-list-header { @@ -502,7 +519,8 @@ input[type="checkbox"]:indeterminate { } .gh-row-title { - @apply min-w-0 truncate text-left text-sm font-semibold text-accent-fg; + @apply min-w-0 truncate text-left font-semibold text-accent-fg; + font-size: 16px; } .gh-row-title:hover { @@ -510,7 +528,7 @@ input[type="checkbox"]:indeterminate { } .gh-row-actions { - @apply flex shrink-0 items-center justify-start gap-0 sm:justify-self-end; + @apply flex shrink-0 items-center justify-start gap-2 sm:justify-self-end; } .gh-section { @@ -531,11 +549,11 @@ input[type="checkbox"]:indeterminate { } .gh-section-body { - @apply flex flex-col gap-4 p-4; + @apply flex flex-col gap-5 p-5; } .gh-section-footer { - @apply flex flex-col gap-2 border-t border-border-default bg-canvas-subtle p-4 sm:flex-row sm:items-center sm:justify-end; + @apply flex flex-wrap items-center justify-end gap-2 border-t border-border-default bg-canvas-subtle p-5; } .gh-checkbox-row { @@ -597,22 +615,24 @@ input[type="checkbox"]:indeterminate { } .gh-layout-sidebar { - @apply grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_296px]; + @apply grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_320px]; } .gh-layout-main, .gh-layout-aside { - @apply flex min-w-0 flex-col gap-4; + @apply flex min-w-0 flex-col gap-6; } .app-repo-meta, .app-repo-tabs-track, .app-main-container { - @apply mx-auto w-full max-w-[92rem] px-4 sm:px-6 lg:px-8; + @apply mx-auto w-full max-w-[1400px] px-4 sm:px-6 lg:px-8; } .app-brand-mark { - @apply h-8 w-8 shrink-0 object-contain; + width: 36px; + height: 36px; + @apply shrink-0 object-contain; } .theme-menu { @@ -658,7 +678,8 @@ input[type="checkbox"]:indeterminate { } .app-repo-meta { - @apply flex min-h-16 items-center justify-between gap-3 py-3; + min-height: 68px; + @apply flex items-center justify-between gap-3 py-3; } .app-repo-main { @@ -670,7 +691,7 @@ input[type="checkbox"]:indeterminate { } .app-repo-tabs { - @apply w-full border-y border-border-default bg-canvas-default; + @apply w-full border-b border-border-default bg-canvas-default; } .app-repo-tabs-track { @@ -697,7 +718,8 @@ input[type="checkbox"]:indeterminate { } .app-repo-title { - @apply flex min-w-0 items-center gap-2.5 rounded-md text-lg font-semibold leading-7; + font-size: 22px; + @apply flex min-w-0 items-center gap-3 rounded-md font-semibold leading-7; color: var(--fg-default); } @@ -747,6 +769,7 @@ input[type="checkbox"]:indeterminate { .nodes-filter-search .gh-input, .gh-search-input.gh-input { + height: 40px; padding-left: 36px; } @@ -755,7 +778,7 @@ input[type="checkbox"]:indeterminate { } .gh-config-group { - @apply flex min-w-0 flex-col gap-4; + @apply flex min-w-0 flex-col gap-6; } .gh-advanced-options { @@ -781,13 +804,14 @@ input[type="checkbox"]:indeterminate { } .gh-row-actions > .gh-btn { - min-width: 40px; - min-height: 40px; + min-width: 44px; + min-height: 44px; } } .app-main-container { - @apply flex-1 py-5; + @apply flex-1; + padding-block: 40px; } .repo-overview { @@ -800,7 +824,7 @@ input[type="checkbox"]:indeterminate { .repo-overview-main, .repo-overview-sidebar { - @apply flex min-w-0 flex-col gap-4; + @apply flex min-w-0 flex-col gap-6; } .overview-panel-header { @@ -840,11 +864,11 @@ input[type="checkbox"]:indeterminate { } .repo-metric-label { - @apply flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-fg-muted; + @apply flex items-center gap-2 text-xs font-medium text-fg-muted; } .repo-metric-value { - @apply text-2xl font-semibold leading-none text-fg-default; + @apply text-3xl font-semibold leading-none text-fg-default; } .repo-workflow-row { @@ -918,10 +942,536 @@ input[type="checkbox"]:indeterminate { @media (max-width: 767px) { body { - background: var(--canvas-subtle); + background: var(--canvas-default); } .app-main-container { @apply py-4; } } + +/* Shared product surfaces and interaction feedback. */ +.gh-page-description { + color: var(--fg-muted); + font-size: 16px; + line-height: 1.6; +} +.gh-box-row { + transition: background-color var(--motion-fast) var(--motion-easing); +} +.gh-box-row:focus-within { + background-color: var(--canvas-subtle); +} +.gh-underlinenav { + padding-right: 2px; + position: relative; +} +.gh-underlinenav[data-indicator-ready]::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + height: 2px; + width: var(--nav-indicator-width); + transform: translateX(var(--nav-indicator-x)); + border-radius: 2px; + background: var(--border-accent); + pointer-events: none; +} +.gh-underlinenav[data-indicator-animated]::after { + transition: + transform var(--motion-normal) var(--motion-easing), + width var(--motion-normal) var(--motion-easing); +} +.gh-underlinenav[data-indicator-ready] .gh-underlinenav-item-active { + border-bottom-color: transparent; +} +.gh-underlinenav-item:hover { + background: var(--canvas-subtle); +} +.gh-dropdown-menu { + transform-origin: top center; +} +.gh-dropdown-item { + min-height: 36px; + font-size: 14px; +} +.gh-dropdown-item:focus-visible { + outline-offset: -2px; + background: var(--canvas-subtle); +} +.gh-dialog-layer { + position: fixed; + inset: 0; + top: var(--dialog-viewport-top, 0px); + bottom: auto; + height: var(--dialog-viewport-height, 100dvh); + z-index: 150; + display: flex; + align-items: center; + justify-content: center; + padding: 32px; +} +.gh-dialog-backdrop { + position: fixed; + inset: 0; + background: rgb(0 0 0 / 45%); +} +.gh-dialog { + position: relative; + display: flex; + flex-direction: column; + width: 100%; + max-height: calc(var(--dialog-viewport-height, 100dvh) - 64px); + box-shadow: var(--shadow-medium); + border-radius: 8px; +} +.gh-dialog > .gh-box-header { + font-size: 18px; + flex-shrink: 0; + background: var(--canvas-default); +} +.gh-dialog > .gh-section-body { + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; +} +.gh-dialog > .gh-section-footer { + flex-shrink: 0; +} +.gh-action-button { + position: relative; +} +.gh-action-button:not([data-has-icon]) { + padding-inline: 28px; +} +:where(.gh-action-button:not([data-has-icon])) > .gh-feedback-icon { + position: absolute; + left: 9px; +} +.gh-action-label { + display: inline-grid; + align-items: center; +} +.gh-action-progress { + grid-area: 1 / 1; + white-space: nowrap; +} +.gh-action-label > span:first-child { + grid-area: 1 / 1; +} +.gh-feedback-icon { + display: inline-flex; + flex-shrink: 0; +} +.gh-copy-button[data-feedback="copied"] { + color: var(--success-fg); + border-color: var(--success-emphasis); +} +.gh-copy-button[data-feedback="copied"] .gh-feedback-icon { + animation: feedback-in var(--motion-fast) var(--motion-easing); +} +.gh-operation-feedback { + display: flex; + align-items: flex-start; + gap: 8px; + color: var(--fg-muted); + font-size: 12px; + overflow-wrap: anywhere; +} +.gh-dialog .gh-operation-feedback { + margin-top: 4px; +} +.gh-operation-feedback[data-feedback="success"] { + color: var(--success-fg); +} +.gh-operation-feedback[data-feedback="error"] { + color: var(--danger-fg); +} +.gh-operation-feedback[data-feedback="attention"] { + color: var(--attention-fg); +} +.gh-resource-list { + border-right: 0; + border-left: 0; + border-radius: 0; + box-shadow: none; +} +.gh-resource-header { + min-height: 56px; + display: grid; + grid-template-columns: 64px minmax(0, 1fr) auto auto; + align-items: center; + gap: 16px; + padding: 16px 20px; + border-bottom: 1px solid var(--border-default); + background: var(--canvas-subtle); + color: var(--fg-muted); + font-size: 12px; + font-weight: 600; +} +.gh-resource-summary { + font-weight: 400; +} +.gh-resource-list .gh-box-row { + padding: 18px 20px; +} +.gh-resource-list .gh-row-main { + gap: 60px; +} +.gh-resource-list input[type="checkbox"] { + width: 20px; + height: 20px; +} +.gh-resource-list .gh-list-meta { + gap: 8px; + margin-top: 2px; + font-size: 13px; +} +.gh-resource-list .gh-list-meta > span + span::before { + content: "·"; + margin-right: 8px; +} +.gh-resource-list .gh-row-title { + font-size: 18px; +} +.gh-resource-list .gh-label { + min-height: 24px; + padding-inline: 6px; +} +.gh-resource-list .gh-row-actions { + align-self: center; +} +.gh-resource-list .gh-row-actions .gh-btn { + width: 40px; + height: 40px; + padding: 0; + background: var(--canvas-default); + box-shadow: none; +} +.gh-resource-list .gh-row-actions .gh-btn:hover { + background: var(--canvas-subtle); +} +.gh-resource-disabled .gh-row-title { + color: var(--fg-muted); +} +.gh-editor-layout { + grid-template-columns: minmax(0, 1fr) 320px; +} +.gh-publish-panel > .gh-box-header { + border-bottom: 0; + background: var(--canvas-default); + font-size: 16px; +} +.gh-publish-panel .gh-section-body { + padding-top: 8px; +} +.gh-editor-panel > .gh-box-header { + min-height: 56px; +} +.gh-editor-panel > .gh-section-body { + gap: 24px; + padding: 24px; +} +.gh-preview-section { + border-top: 1px solid var(--border-default); +} +.gh-preview-section > .gh-box-header { + background: var(--canvas-default); + border-bottom: 0; +} +.gh-preview-row { + min-height: 48px; + border-bottom: 1px solid var(--border-muted); +} +.gh-preview-row:last-child { + border-bottom: 0; +} +.gh-preview-row:focus-within { + background: var(--canvas-subtle); +} +.gh-overview-columns { + display: grid; + grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); + gap: 24px; + align-items: start; +} +.gh-settings-page { + max-width: 100%; +} +.gh-settings-page .gh-section-body { + gap: 24px; + padding: 24px; +} +.gh-skeleton-list { + display: grid; + gap: 16px; + padding-block: 12px; +} +.gh-skeleton-list span { + display: block; + height: 14px; + width: 75%; + border-radius: 4px; + background: var(--border-muted); +} +.gh-skeleton-list span:nth-child(2) { + width: 55%; +} +.gh-skeleton-list span:nth-child(3) { + width: 65%; +} +:root[data-theme-changing] body, +:root[data-theme-changing] .gh-box, +:root[data-theme-changing] .app-repo-masthead, +:root[data-theme-changing] .app-repo-tabs { + transition: + background-color 150ms, + color 150ms, + border-color 150ms; +} +@keyframes feedback-in { + from { + opacity: 0; + transform: scale(0.8); + } + to { + opacity: 1; + transform: scale(1); + } +} +@media (max-width: 1023px) { + .gh-editor-layout { + grid-template-columns: minmax(0, 1fr); + } + .gh-overview-columns { + grid-template-columns: minmax(0, 1fr); + } +} +@media (max-width: 639px) { + html { + scrollbar-gutter: auto; + } + .gh-underlinenav-item { + min-height: 48px; + font-size: 14px; + } + .gh-filter-controls { + display: grid; + grid-template-columns: minmax(0, 1fr) 100px; + } + .nodes-filter-tabs { + grid-column: 1 / -1; + } + .nodes-filter-status { + min-width: 0; + } + .gh-resource-list .gh-row-actions .gh-btn { + min-width: 44px; + min-height: 44px; + } + + .gh-page { + gap: 24px; + } + .gh-page-title { + font-size: 26px; + } + .gh-page-description { + font-size: 14px; + } + .gh-page-actions { + padding-top: 0; + } + .gh-btn, + .gh-icon-button, + .theme-menu-button, + .app-header-link, + .gh-dropdown-item { + min-height: 44px; + } + .gh-icon-button, + .theme-menu-button, + .app-header-link { + min-width: 44px; + } + .gh-input:not(textarea), + .gh-select { + min-height: 44px; + } + .gh-resource-header { + grid-template-columns: 36px minmax(0, 1fr) auto; + gap: 8px; + padding: 12px 8px; + } + .gh-resource-header > span:last-child { + display: none; + } + .gh-resource-summary { + font-size: 11px; + } + .gh-resource-list .gh-box-row { + padding: 16px 8px; + } + .gh-resource-list .gh-row-main { + gap: 16px; + } + .gh-resource-list .gh-row-actions { + padding-left: 36px; + } + .gh-resource-list .gh-list-meta { + font-size: 12px; + } + .gh-dialog-layer { + padding: 16px; + } + .gh-dialog-sheet { + align-items: flex-end; + padding: 16px 0 0; + } + .gh-dialog-sheet .gh-dialog { + border-radius: 12px 12px 0 0; + max-height: calc(var(--dialog-viewport-height, 100dvh) - 16px); + padding-bottom: env(safe-area-inset-bottom); + } + .gh-dialog-sheet .gh-section-footer { + padding: 16px 20px; + } + .gh-dialog .gh-box-header { + min-height: 60px; + } + .gh-dialog .gh-textarea { + min-height: 96px; + } + .gh-dialog .gh-input, + .gh-dialog .gh-select { + font-size: 16px; + } + .gh-dialog .gh-section-body { + padding: 20px; + } + .gh-editor-panel > .gh-section-body { + padding: 20px; + } +} +@media (prefers-reduced-motion: reduce) { + :root { + --motion-fast: 0ms; + --motion-normal: 0ms; + --motion-exit: 0ms; + } + *, + *::before, + *::after { + scroll-behavior: auto; + } + .animate-spin, + .gh-copy-button .gh-feedback-icon { + animation: none; + } + :root[data-theme-changing] body, + :root[data-theme-changing] .gh-box, + :root[data-theme-changing] .app-repo-masthead, + :root[data-theme-changing] .app-repo-tabs { + transition: none; + } +} + +.app-project-link-narrow { + display: none; +} +@media (max-width: 639px) { + .app-nav-scroll { + min-width: 44px; + min-height: 44px; + } +} +@media (max-width: 360px) { + .app-repo-title { + font-size: 16px; + gap: 6px; + } + .app-brand-mark { + width: 28px; + height: 28px; + } + .app-project-link { + display: none; + } + .app-project-link-narrow { + display: inline-flex; + } +} + +.gh-publish-target-actions, +.gh-publication-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; +} +.gh-publication-actions { + justify-content: space-between; +} +.gh-publication-details { + display: flex; + flex-direction: column; + gap: 10px; + border-top: 1px solid var(--border-default); + padding-top: 16px; +} +.gh-published-url { + display: block; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 11px; + color: var(--fg-muted); +} +.gh-preview-name { + font-size: 16px; + font-weight: 500; + color: var(--accent-fg); +} +.gh-preview-section > .gh-box-header > div { + flex-wrap: wrap; +} +.gh-editor-panel > .gh-box-header { + font-size: 18px; +} +.gh-rule-header { + flex-wrap: wrap; +} +.gh-rule-header-actions { + display: flex; + width: 244px; + max-width: 100%; + align-items: center; + gap: 8px; + margin-left: auto; +} +.gh-rule-header-actions > .gh-icon-button { + flex-shrink: 0; +} +.gh-rule-header-actions > .gh-select { + min-width: 0; + width: 200px; + flex: 1; +} +.gh-editor-panel h2 { + font-size: 16px; +} +.gh-file-list-header { + display: none; + padding-inline: 1.25rem; +} +@media (min-width: 640px) { + .gh-file-list-header, + .gh-file-list-row { + display: grid; + grid-template-columns: minmax(0, 1fr) 120px 96px 120px; + gap: 16px; + align-items: center; + } +} diff --git a/src/app.html b/src/app.html index 07c9817..f9f0742 100644 --- a/src/app.html +++ b/src/app.html @@ -18,14 +18,11 @@ root.dataset.themeMode = mode; root.style.colorScheme = resolved; - if (mode === "system") { - delete root.dataset.theme; - return; - } - - root.dataset.theme = mode; + root.dataset.theme = resolved; } catch { - document.documentElement.style.colorScheme = window.matchMedia(mediaQuery).matches ? "dark" : "light"; + const resolved = window.matchMedia(mediaQuery).matches ? "dark" : "light"; + document.documentElement.style.colorScheme = resolved; + document.documentElement.dataset.theme = resolved; } })(); diff --git a/src/lib/actions/disclosure.ts b/src/lib/actions/disclosure.ts new file mode 100644 index 0000000..fe8a3de --- /dev/null +++ b/src/lib/actions/disclosure.ts @@ -0,0 +1,52 @@ +import { motionDuration } from "$lib/ui-motion"; + +export function disclosure(node: HTMLDetailsElement) { + const summary = node.querySelector("summary"); + let animation: Animation | undefined; + let expanded = node.open; + const overflow = node.style.overflow; + const toggle = (event: MouseEvent) => { + event.preventDefault(); + const start = node.getBoundingClientRect().height; + expanded = animation ? !expanded : !node.open; + animation?.cancel(); + if (!motionDuration()) { + node.open = expanded; + node.style.overflow = overflow; + animation = undefined; + return; + } + node.open = true; + const style = getComputedStyle(node); + const end = expanded + ? node.scrollHeight + 2 + : (summary?.offsetHeight ?? 0) + + Number.parseFloat(style.paddingTop) + + Number.parseFloat(style.paddingBottom) + + 2; + node.style.overflow = "hidden"; + const current = node.animate( + [{ height: `${start}px` }, { height: `${end}px` }], + { + duration: 180, + easing: "cubic-bezier(0.2, 0.8, 0.2, 1)", + }, + ); + animation = current; + void current.finished + .then(() => { + if (animation !== current) return; + node.open = expanded; + node.style.overflow = overflow; + animation = undefined; + }) + .catch(() => {}); + }; + summary?.addEventListener("click", toggle); + return { + destroy() { + animation?.cancel(); + summary?.removeEventListener("click", toggle); + }, + }; +} diff --git a/src/lib/actions/modal.ts b/src/lib/actions/modal.ts new file mode 100644 index 0000000..1d1e3be --- /dev/null +++ b/src/lib/actions/modal.ts @@ -0,0 +1,133 @@ +import { tick } from "svelte"; + +type ModalOptions = { onclose: () => void; initialFocus?: string }; +const layers: HTMLElement[] = []; +const inertCounts = new Map< + HTMLElement, + { count: number; original: boolean } +>(); +let originalOverflow = ""; +let originalRootOverflow = ""; + +function focusable(surface: HTMLElement | null) { + return Array.from( + surface?.querySelectorAll( + 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', + ) ?? [], + ).filter( + (element) => + element.getClientRects().length > 0 && + !element.matches(":disabled") && + !element.closest("[inert]"), + ); +} + +export function handleModalKeydown(event: KeyboardEvent, onclose: () => void) { + const surface = event.currentTarget as HTMLElement; + const node = surface.closest(".gh-dialog-layer"); + if (layers.at(-1) !== node || event.defaultPrevented) return; + if (event.key === "Escape") { + event.preventDefault(); + onclose(); + } else if (event.key === "Tab") { + const items = focusable(surface); + const first = items[0]; + const last = items.at(-1); + if (!first) { + event.preventDefault(); + surface.focus(); + } else if ( + event.shiftKey && + (document.activeElement === first || document.activeElement === surface) + ) { + event.preventDefault(); + last?.focus(); + } else if (!event.shiftKey && document.activeElement === last) { + event.preventDefault(); + first.focus(); + } + } +} + +export function modal(node: HTMLElement, options: ModalOptions) { + const returnFocus = + document.activeElement instanceof HTMLElement + ? document.activeElement + : null; + const surface = node.querySelector('[role="dialog"]'); + const hidden: HTMLElement[] = []; + let mounted = true; + if (!layers.length) { + originalOverflow = document.body.style.overflow; + originalRootOverflow = document.documentElement.style.overflow; + document.documentElement.style.overflow = "hidden"; + document.body.style.overflow = "hidden"; + } + layers.push(node); + let branch: HTMLElement = node; + while (branch.parentElement) { + for (const sibling of branch.parentElement.children) { + if ( + !(sibling instanceof HTMLElement) || + sibling === branch || + sibling.tagName === "SCRIPT" + ) + continue; + const entry = inertCounts.get(sibling) ?? { + count: 0, + original: sibling.inert, + }; + entry.count++; + inertCounts.set(sibling, entry); + sibling.inert = true; + hidden.push(sibling); + } + branch = branch.parentElement; + if (branch === document.body) break; + } + const viewport = window.visualViewport; + const updateViewport = () => { + node.style.setProperty( + "--dialog-viewport-height", + `${viewport?.height ?? innerHeight}px`, + ); + node.style.setProperty( + "--dialog-viewport-top", + `${viewport?.offsetTop ?? 0}px`, + ); + }; + viewport?.addEventListener("resize", updateViewport); + viewport?.addEventListener("scroll", updateViewport); + updateViewport(); + void tick().then(() => { + if (!mounted || layers.at(-1) !== node) return; + const initial = surface?.querySelector( + options.initialFocus ?? + "input:not(:disabled), textarea:not(:disabled), select:not(:disabled)", + ); + (initial ?? focusable(surface)[0] ?? surface)?.focus(); + }); + return { + update(next: ModalOptions) { + options = next; + }, + destroy() { + mounted = false; + viewport?.removeEventListener("resize", updateViewport); + viewport?.removeEventListener("scroll", updateViewport); + layers.splice(layers.indexOf(node), 1); + for (const element of hidden) { + const entry = inertCounts.get(element); + if (!entry || --entry.count) continue; + element.inert = entry.original; + inertCounts.delete(element); + } + if (!layers.length) { + document.body.style.overflow = originalOverflow; + document.documentElement.style.overflow = originalRootOverflow; + } + if (returnFocus?.isConnected && !returnFocus.closest("[inert]")) + returnFocus.focus(); + }, + }; +} diff --git a/src/lib/actions/navigation-indicator.ts b/src/lib/actions/navigation-indicator.ts new file mode 100644 index 0000000..6cac7f1 --- /dev/null +++ b/src/lib/actions/navigation-indicator.ts @@ -0,0 +1,42 @@ +export function navigationIndicator(node: HTMLElement) { + let frame = 0; + let ready = false; + const measure = () => { + cancelAnimationFrame(frame); + frame = requestAnimationFrame(() => { + const active = node.querySelector('[aria-current="page"]'); + if (!active) return; + const anchor = active.getBoundingClientRect(); + const container = node.getBoundingClientRect(); + node.style.setProperty( + "--nav-indicator-x", + `${anchor.left - container.left + node.scrollLeft}px`, + ); + node.style.setProperty("--nav-indicator-width", `${anchor.width}px`); + node.dataset.indicatorReady = "true"; + if (ready) node.dataset.indicatorAnimated = "true"; + ready = true; + }); + }; + const resize = new ResizeObserver(measure); + resize.observe(node); + for (const child of node.querySelectorAll("a")) resize.observe(child); + const changes = new MutationObserver(measure); + changes.observe(node, { + subtree: true, + attributes: true, + attributeFilter: ["aria-current"], + childList: true, + characterData: true, + }); + node.addEventListener("scroll", measure, { passive: true }); + measure(); + return { + destroy() { + cancelAnimationFrame(frame); + resize.disconnect(); + changes.disconnect(); + node.removeEventListener("scroll", measure); + }, + }; +} diff --git a/src/lib/components/ActionButton.svelte b/src/lib/components/ActionButton.svelte new file mode 100644 index 0000000..c9b1ab7 --- /dev/null +++ b/src/lib/components/ActionButton.svelte @@ -0,0 +1,94 @@ + + + diff --git a/src/lib/components/CopyButton.svelte b/src/lib/components/CopyButton.svelte new file mode 100644 index 0000000..8430701 --- /dev/null +++ b/src/lib/components/CopyButton.svelte @@ -0,0 +1,65 @@ + + + +{clipboardState === "copied" ? $t("Copied to clipboard") : ""} diff --git a/src/lib/components/Dialog.svelte b/src/lib/components/Dialog.svelte new file mode 100644 index 0000000..d6bd9fe --- /dev/null +++ b/src/lib/components/Dialog.svelte @@ -0,0 +1,33 @@ + + +
+ + +
diff --git a/src/lib/components/GitHubSelect.svelte b/src/lib/components/GitHubSelect.svelte index e92d223..82f20ae 100644 --- a/src/lib/components/GitHubSelect.svelte +++ b/src/lib/components/GitHubSelect.svelte @@ -1,5 +1,5 @@ @@ -150,7 +150,7 @@ function selectValue(nextValue: string) { role="menu" tabindex="-1" onkeydown={handleMenuKeydown} - transition:slide={{ duration: 150 }} + in:surfaceMotion={{ duration: 120, y: 4 }} out:surfaceMotion={{ duration: 140, y: 4 }} data-ui-motion >
{#each options as option} diff --git a/src/lib/components/OperationFeedback.svelte b/src/lib/components/OperationFeedback.svelte new file mode 100644 index 0000000..e83f64f --- /dev/null +++ b/src/lib/components/OperationFeedback.svelte @@ -0,0 +1,16 @@ + + +{#if feedback && feedback.feedbackState !== "success"} +

+ + {$t(feedback.messageKey, feedback.messageParams)} +

+{/if} diff --git a/src/lib/components/PageHeader.svelte b/src/lib/components/PageHeader.svelte new file mode 100644 index 0000000..c754a3f --- /dev/null +++ b/src/lib/components/PageHeader.svelte @@ -0,0 +1,17 @@ + + +
+
+

{title}

+ {#if description}

{description}

{/if} +
+ {#if children}
{@render children()}
{/if} +
diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index ada05de..a871441 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -7,6 +7,23 @@ const STORAGE_KEY = "subman:locale:v1"; const DEFAULT_LOCALE: Locale = "en"; const zhCN: Record = { + "Save a target, then publish the rule output to its file.": + "保存目标后,可将规则输出发布到对应文件。", + "Manage nodes and subscription sources.": "管理节点与订阅来源。", + "Combine sources, preview rules, and publish output.": + "组合来源、预览规则并发布输出。", + "Generate and publish client configurations.": "生成并发布客户端配置。", + "Files in your connected cloud Workspace.": "查看已连接云端工作区的文件。", + "Manage your GitHub connection and appearance.": + "管理 GitHub 连接与界面偏好。", + "Your resources and confirmed publications.": "查看资源与已确认的发布记录。", + "Waiting for cloud confirmation...": "等待云端确认…", + "Check synchronization status before retrying.": + "请先查看云端同步状态,再决定是否重试。", + Resource: "资源", + Enable: "启用", + "e.g. domestic, bypass": "例如 domestic, bypass", + Settings: "设置", Title: "名称", Actions: "操作", diff --git a/src/lib/stores/theme.ts b/src/lib/stores/theme.ts index f785497..e540d1e 100644 --- a/src/lib/stores/theme.ts +++ b/src/lib/stores/theme.ts @@ -51,12 +51,7 @@ function applyTheme(mode: ThemeMode, resolved: ResolvedTheme): void { root.style.colorScheme = resolved; root.dataset.themeMode = mode; - if (mode === "system") { - delete root.dataset.theme; - return; - } - - root.dataset.theme = mode; + root.dataset.theme = resolved; } export function startThemeSync(): () => void { diff --git a/src/lib/ui-motion.ts b/src/lib/ui-motion.ts new file mode 100644 index 0000000..64ce38e --- /dev/null +++ b/src/lib/ui-motion.ts @@ -0,0 +1,75 @@ +import { cubicOut } from "svelte/easing"; +import { prefersReducedMotion } from "svelte/motion"; +import { fade, slide, type TransitionConfig } from "svelte/transition"; + +export function motionDuration(duration = 180): number { + return prefersReducedMotion.current ? 0 : duration; +} + +export function surfaceMotion( + node: Element, + { duration = 180, y = 8, scale = 0.98 } = {}, +): TransitionConfig { + if (prefersReducedMotion.current) return { duration: 0 }; + const style = getComputedStyle(node); + const transform = style.transform === "none" ? "" : style.transform; + const opacity = Number(style.opacity); + return { + duration, + easing: cubicOut, + css: (t, u) => + "opacity:" + + t * opacity + + ";transform:" + + transform + + " translateY(" + + u * y + + "px) scale(" + + (1 - u * (1 - scale)) + + ")", + }; +} + +export function veilMotion(node: Element, { duration = 120 } = {}) { + return fade(node, { duration: motionDuration(duration) }); +} + +export function collapseMotion(node: Element, { duration = 180 } = {}) { + return slide(node, { duration: motionDuration(duration), easing: cubicOut }); +} + +export function animatePage(root: HTMLElement) { + const node = root.querySelector(".gh-page"); + if (!node) return; + for (const animation of node.getAnimations()) animation.cancel(); + if (prefersReducedMotion.current) return; + const animation = node.animate( + [ + { opacity: 0, transform: "translateY(4px)" }, + { opacity: 1, transform: "none" }, + ], + { duration: 160, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" }, + ); + animation.id = "subman-page"; +} + +export function watchMotionPreference() { + const query = matchMedia("(prefers-reduced-motion: reduce)"); + const finish = () => { + if (!query.matches) return; + for (const animation of document.getAnimations()) { + const target = (animation.effect as KeyframeEffect | null)?.target; + if (!(target instanceof Element) || !target.closest("[data-ui-motion]")) + continue; + if (animation.effect?.getComputedTiming().iterations === Infinity) + continue; + try { + animation.finish(); + } catch { + /* Already cancelled or unresolved. */ + } + } + }; + query.addEventListener("change", finish); + return () => query.removeEventListener("change", finish); +} diff --git a/src/lib/workspace-operation-presenter.test.ts b/src/lib/workspace-operation-presenter.test.ts index 30db5ab..e6ba2a7 100644 --- a/src/lib/workspace-operation-presenter.test.ts +++ b/src/lib/workspace-operation-presenter.test.ts @@ -22,6 +22,7 @@ describe("Workspace operation presenter", () => { ); expect(presentation).toEqual({ tone: "success", + feedbackState: "success", messageKey: "Published successfully", finalizeDraft: true, remoteCommitted: true, @@ -62,6 +63,7 @@ describe("Workspace operation presenter", () => { const presentation = presentWorkspaceOperation(operation); expect(presentation.messageKey).toBe(messageKey); expect(presentation.tone).toBe("info"); + expect(presentation.feedbackState).toBe("pending"); expect(presentation.finalizeDraft).toBe(false); expect(presentation.remoteCommitted).toBe(false); } @@ -80,6 +82,7 @@ describe("Workspace operation presenter", () => { "Cloud confirmation required; reload from Cloud", ); expect(manual.finalizeDraft).toBe(false); + expect(manual.feedbackState).toBe("pending"); const blocked = presentWorkspaceOperation( result({ @@ -93,6 +96,7 @@ describe("Workspace operation presenter", () => { ); expect(blocked.messageParams).toEqual({ error: "auth_required" }); expect(blocked.finalizeDraft).toBe(false); + expect(blocked.feedbackState).toBe("attention"); const rejected = presentWorkspaceOperation({ status: "rejected-before-durable-commit", @@ -102,6 +106,7 @@ describe("Workspace operation presenter", () => { message: "Quota exceeded", }); expect(rejected.tone).toBe("error"); + expect(rejected.feedbackState).toBe("error"); expect(rejected.finalizeDraft).toBe(false); const uncertain = presentWorkspaceOperation( @@ -114,5 +119,6 @@ describe("Workspace operation presenter", () => { ); expect(uncertain.tone).toBe("info"); expect(uncertain.finalizeDraft).toBe(false); + expect(uncertain.feedbackState).toBe("attention"); }); }); diff --git a/src/lib/workspace-operation-presenter.ts b/src/lib/workspace-operation-presenter.ts index 8199ce1..b5479c7 100644 --- a/src/lib/workspace-operation-presenter.ts +++ b/src/lib/workspace-operation-presenter.ts @@ -1,8 +1,15 @@ import type { ToastType } from "$lib/stores/toast"; import type { WorkspaceOperationResult } from "$lib/workspace-operation-result"; +export type WorkspaceFeedbackState = + | "pending" + | "success" + | "attention" + | "error"; + export type WorkspaceOperationPresentation = { tone: ToastType; + feedbackState: WorkspaceFeedbackState; messageKey: string; messageParams?: Record; finalizeDraft: boolean; @@ -23,6 +30,7 @@ export function presentWorkspaceOperation( case "remote-committed": return { tone: "success", + feedbackState: "success", messageKey: options.remoteCommittedMessageKey ?? "Saved to Workspace", messageParams: options.successMessageParams, finalizeDraft: true, @@ -31,6 +39,7 @@ export function presentWorkspaceOperation( case "local-durable": return { tone: "info", + feedbackState: "pending", messageKey: "Cloud confirmation required; reload from Cloud", finalizeDraft: false, remoteCommitted: false, @@ -38,6 +47,7 @@ export function presentWorkspaceOperation( case "local-durable-queued": return { tone: "info", + feedbackState: "pending", messageKey: "Cloud save pending", finalizeDraft: false, remoteCommitted: false, @@ -45,6 +55,7 @@ export function presentWorkspaceOperation( case "peer-owned": return { tone: "info", + feedbackState: "pending", messageKey: "Cloud save pending; another tab is synchronizing", finalizeDraft: false, remoteCommitted: false, @@ -52,6 +63,7 @@ export function presentWorkspaceOperation( case "retry-scheduled": return { tone: "info", + feedbackState: "pending", messageKey: "Cloud save pending; retrying", finalizeDraft: false, remoteCommitted: false, @@ -59,6 +71,7 @@ export function presentWorkspaceOperation( case "conflict-or-blocked": return { tone: "info", + feedbackState: "attention", messageKey: "Cloud synchronization needs repair: {error}", messageParams: { error: result.messageKey ?? result.code }, finalizeDraft: false, @@ -67,6 +80,7 @@ export function presentWorkspaceOperation( case "rejected-before-durable-commit": return { tone: "error", + feedbackState: "error", messageKey: options.rejectedMessageKey ?? "Workspace change was not saved: {error}", @@ -77,6 +91,7 @@ export function presentWorkspaceOperation( case "commit-acknowledgement-uncertain": return { tone: "info", + feedbackState: "attention", messageKey: "Workspace save acknowledgement is uncertain; reload before retrying", finalizeDraft: false, diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 7c32eea..bd377b5 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,10 +2,11 @@ import "../app.css"; import { onMount, tick } from "svelte"; import { get } from "svelte/store"; -import { fade, fly, slide } from "svelte/transition"; import { afterNavigate } from "$app/navigation"; import { page } from "$app/state"; +import { navigationIndicator } from "$lib/actions/navigation-indicator"; import { tooltip } from "$lib/actions/tooltip"; +import Dialog from "$lib/components/Dialog.svelte"; import Octicon from "$lib/components/Octicon.svelte"; import { t } from "$lib/i18n"; import { @@ -32,6 +33,12 @@ import { authState } from "$lib/stores/auth"; import { confirmDialog, resolveConfirm } from "$lib/stores/confirm"; import { startThemeSync, type ThemeMode, themeMode } from "$lib/stores/theme"; import { dismissToast, toastStore } from "$lib/stores/toast"; +import { + animatePage, + surfaceMotion, + veilMotion, + watchMotionPreference, +} from "$lib/ui-motion"; import { cn } from "$lib/utils/cn"; import { cancelCloudWorkspaceLoad, @@ -127,7 +134,21 @@ function updateNavigationOverflow() { navigationOverflows = navigation.scrollWidth > navigation.clientWidth + 1; navigationAtEnd = navigation.scrollLeft + navigation.clientWidth >= - navigation.scrollWidth - 2; + navigation.scrollWidth - 1; +} + +function scrollNavigation() { + const maximum = navigation.scrollWidth - navigation.clientWidth; + let target = + navigation.scrollLeft + + (navigationAtEnd ? -1 : 1) * navigation.clientWidth * 0.8; + if (!navigationAtEnd && maximum - target < 4) target = maximum; + navigation.scrollTo({ + left: Math.max(0, Math.min(maximum, target)), + behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches + ? "instant" + : "smooth", + }); } function revealActiveNavigation() { @@ -135,19 +156,21 @@ function revealActiveNavigation() { '[aria-current="page"]', ); if (active) { - const offset = - active.getBoundingClientRect().left - - navigation.getBoundingClientRect().left; - if (offset < 0) navigation.scrollLeft += offset; - else if (offset + active.offsetWidth > navigation.clientWidth) + const activeBounds = active.getBoundingClientRect(); + const offset = activeBounds.left - navigation.getBoundingClientRect().left; + if (offset < 0) navigation.scrollLeft += Math.floor(offset) - 1; + else if (offset + activeBounds.width > navigation.clientWidth) navigation.scrollLeft += - offset + active.offsetWidth - navigation.clientWidth; + Math.ceil(offset + activeBounds.width - navigation.clientWidth) + 1; } updateNavigationOverflow(); } -afterNavigate(() => { - void tick().then(revealActiveNavigation); +afterNavigate(({ from }) => { + void tick().then(() => { + revealActiveNavigation(); + if (from && content) animatePage(content); + }); }); async function toggleThemeMenu() { @@ -189,59 +212,23 @@ function handleThemeKeydown(event: KeyboardEvent) { items[next]?.focus(); } } -let confirmDialogElement: HTMLDivElement | null = null; -let confirmButton: HTMLButtonElement | null = null; -let confirmWasOpen = false; -let confirmReturnFocus: HTMLElement | null = null; - -$: if ($confirmDialog.open && !confirmWasOpen) { - confirmWasOpen = true; - confirmReturnFocus = - typeof document === "undefined" - ? null - : document.activeElement instanceof HTMLElement - ? document.activeElement - : null; - void tick().then(() => confirmButton?.focus()); -} else if (!$confirmDialog.open && confirmWasOpen) { - confirmWasOpen = false; - confirmReturnFocus?.focus(); - confirmReturnFocus = null; -} +let content: HTMLElement; function isActive(pathname: string, href: string) { return href === "/" ? pathname === "/" : pathname.startsWith(href); } +let themeAnimationTimer: ReturnType; function handleThemeChange(nextTheme: ThemeMode) { + clearTimeout(themeAnimationTimer); + document.documentElement.dataset.themeChanging = "true"; themeMode.set(nextTheme); + themeAnimationTimer = setTimeout(() => { + delete document.documentElement.dataset.themeChanging; + }, 180); closeThemeMenu(); } -function handleConfirmKeydown(event: KeyboardEvent) { - if (event.key === "Escape") { - event.preventDefault(); - resolveConfirm(false); - return; - } - if (event.key !== "Tab" || !confirmDialogElement) return; - const focusable = Array.from( - confirmDialogElement.querySelectorAll( - 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', - ), - ); - const first = focusable[0]; - const last = focusable.at(-1); - if (!first || !last) return; - if (event.shiftKey && document.activeElement === first) { - event.preventDefault(); - last.focus(); - } else if (!event.shiftKey && document.activeElement === last) { - event.preventDefault(); - first.focus(); - } -} - onMount(() => { shellMounted = true; const navigationObserver = new ResizeObserver(revealActiveNavigation); @@ -251,6 +238,7 @@ onMount(() => { let stopAuth = () => {}; let currentToken: string | null | undefined; const stopThemeSync = startThemeSync(); + const stopUiMotion = watchMotionPreference(); const stopWorkspaceEvents = subscribeWorkspaceEvents((event) => { if (event.type !== "workspace-v2-committed" || !currentToken) return; if (get(workspaceCloudStatus).phase === "error") { @@ -278,6 +266,9 @@ onMount(() => { return () => { navigationObserver.disconnect(); + stopUiMotion(); + clearTimeout(themeAnimationTimer); + delete document.documentElement.dataset.themeChanging; cancelled = true; stopAuth(); stopAutoSync(); @@ -331,7 +322,7 @@ onMount(() => { {#if themeMenuOpen} - -
+
{#if $workspaceCloudStatus.phase === "ready" && (workspaceNeedsAttention || workspacePending)}
{$t(syncStatusLabel)}{#if $workspaceSyncStatus.queueCount > 0} · {$t("{count} queued", { count: $workspaceSyncStatus.queueCount })}{/if} @@ -400,7 +392,8 @@ onMount(() => {

{$t("Cloud Workspace")}

{$workspaceCloudStatus.phase === "loading" ? $t("Loading cloud data...") : $workspaceCloudStatus.phase === "error" ? $t("Cloud data could not be loaded. Check your connection and retry.") : $t("Connect GitHub to load your cloud data.")}

{#if $workspaceCloudStatus.phase === "error"}

{$t($workspaceCloudStatus.message ?? "Cloud synchronization needs review")}

{/if} - {$t("Setup GitHub")} + {#if $workspaceCloudStatus.phase === "loading"}{/if} + {$t("Setup GitHub")}
{/if} @@ -409,8 +402,9 @@ onMount(() => {
{#each $toastStore as toast (toast.id)}
@@ -437,24 +431,8 @@ onMount(() => { {/each}
- {#if $confirmDialog.open} -
- - diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9b23e97..4f2328c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,5 +1,6 @@
-
-
-

{$t("Overview")}

-
- -
+
@@ -160,7 +156,7 @@ $: stats = [
{#if hasResources} -
+

{$t("Recently updated")}

{$t("Manage Sources")}
{#each recentResources as resource (`${resource.kind}:${resource.id}`)} diff --git a/src/routes/aggregate/+page.svelte b/src/routes/aggregate/+page.svelte index 5b4761b..c8303eb 100644 --- a/src/routes/aggregate/+page.svelte +++ b/src/routes/aggregate/+page.svelte @@ -1,7 +1,7 @@ @@ -770,21 +695,15 @@ async function copy(text: string) {
-
-
-

{$t("Nodes")}

-
-
- -
-
+ + + {#if isAddModalOpen} -
+
@@ -844,9 +763,10 @@ async function copy(text: string) {
{/if}
+
{/if} @@ -880,23 +800,12 @@ async function copy(text: string) {
-
-
- {activeTab === "nodes" ? $t("Nodes") : $t("Subscriptions")} -
- {#if activeTab === "nodes"} - {filteredNodes.length} {$t("results")} - {enabledNodeCount} {$t("enabled")} - {:else} - {filteredSubscriptions.length} {$t("results")} - {enabledSubscriptionCount} {$t("enabled")} - {/if} -
-
- +
+
+ {$t("Enable")}{$t("Resource")} + {activeTab === "nodes" ? filteredNodes.length : filteredSubscriptions.length} {$t("results")} · {activeTab === "nodes" ? enabledNodeCount : enabledSubscriptionCount} {$t("enabled")} + {$t("Actions")} +
{#if activeTab === "nodes"} {#if filteredNodes.length === 0} @@ -914,7 +823,7 @@ async function copy(text: string) {
{:else} {#each filteredNodes as node (node.id)} -
+
toggleEnabled(node.id, "node")} aria-label={$t(node.enabled ? "Disable node" : "Enable node")} - disabled={deletingResourceId === node.id || togglingResourceId === node.id} + disabled={deletingResourceId === node.id || togglingResourceId === node.id || $workspaceSyncStatus.queueCount > 0} />
@@ -936,7 +845,7 @@ async function copy(text: string) {
{$t("Updated {time}", { time: formatUpdatedAt(node.updatedAt) })} {$t("Source: {source}", { source: $t(node.source === "single" ? "Single URI" : "Subscription") })} - {$t("{count} tags", { count: node.tags.length })} + {#if node.tags.length}{$t("{count} tags", { count: node.tags.length })}{/if}
{#if node.tags.length > 0}
@@ -948,9 +857,9 @@ async function copy(text: string) {
-
+
- +
{:else} {#each filteredSubscriptions as sub (sub.id)} -
+
toggleEnabled(sub.id, "sub")} aria-label={$t(sub.enabled ? "Disable subscription" : "Enable subscription")} - disabled={deletingResourceId === sub.id || togglingResourceId === sub.id} + disabled={deletingResourceId === sub.id || togglingResourceId === sub.id || $workspaceSyncStatus.queueCount > 0} />
@@ -1000,7 +909,7 @@ async function copy(text: string) {
{$t("Updated {time}", { time: formatUpdatedAt(sub.updatedAt) })} - {$t("{count} tags", { count: sub.tags.length })} + {#if sub.tags.length}{$t("{count} tags", { count: sub.tags.length })}{/if}
@@ -1016,10 +925,10 @@ async function copy(text: string) {
-
+
- + - + {/if} {#if previewSubscriptionId} {@const sub = $appState.subscriptions.find(s => s.id === previewSubscriptionId)} {@const cache = subscriptionPreviewCache[previewSubscriptionId]} -
- - @@ -1183,6 +1072,5 @@ async function copy(text: string) { -
-
+ {/if} diff --git a/src/routes/nodes/page-source.test.ts b/src/routes/nodes/page-source.test.ts index e33539a..46afd43 100644 --- a/src/routes/nodes/page-source.test.ts +++ b/src/routes/nodes/page-source.test.ts @@ -18,7 +18,7 @@ test("nodes page uses a unified github-style filter bar", () => { expect(nodesPageSource).toContain('class="gh-filter-bar"'); expect(nodesPageSource).toContain('class="gh-filter-controls"'); expect(nodesPageSource).toContain('class="gh-counter"'); - expect(nodesPageSource).toContain("gh-btn-group"); + expect(nodesPageSource).toContain("gh-resource-list"); }); test("nodes filter bar separates search and status with creation in the page header", () => { @@ -89,7 +89,7 @@ test("resource editing opens a modal instead of expanding inline editors", () => expect(nodesPageSource).toContain("Edit Node"); expect(nodesPageSource).toContain("Edit Subscription"); expect(nodesPageSource).toContain("Close edit modal"); - expect(nodesPageSource).toContain("fixed inset-0 z-[150]"); + expect(nodesPageSource).toContain("