From 442e58780f5b2d704aa63f0887c0b177a39391be Mon Sep 17 00:00:00 2001 From: Brandon Oxendine Date: Tue, 27 Oct 2026 16:52:04 +0100 Subject: [PATCH] desktop: Respect reduced motion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rūdolfs Ošiņš --- desktop/AGENTS.md | 7 ++++ desktop/public/index.css | 13 ++++++++ desktop/src/components/AppSidebar.svelte | 22 ++++++++++--- desktop/src/components/ArtifactRow.svelte | 3 +- desktop/src/components/Comment.svelte | 3 +- desktop/src/components/CommitAuthors.svelte | 5 --- desktop/src/components/DraftReviewBar.svelte | 5 +-- desktop/src/components/FileBlock.svelte | 4 ++- .../components/FullscreenModalPortal.svelte | 3 +- desktop/src/components/Mention.svelte | 5 +-- .../src/components/PatchActivityItem.svelte | 3 +- desktop/src/components/PierreDiff.svelte | 3 +- desktop/src/components/Revision.svelte | 11 ++++--- desktop/src/components/SidebarRepoList.svelte | 32 +++++++++++-------- desktop/src/components/Thread.svelte | 3 +- desktop/src/lib/boardDrag.svelte.ts | 3 +- desktop/src/lib/flip.ts | 4 ++- desktop/src/lib/motion.ts | 9 ++++++ desktop/src/modals/BoardColumns.svelte | 3 +- desktop/src/modals/KeyboardShortcuts.svelte | 5 +-- desktop/src/views/repo/Board.svelte | 15 +++++---- desktop/src/views/repo/Identity.svelte | 5 ++- desktop/src/views/repo/Patch.svelte | 6 +++- 23 files changed, 119 insertions(+), 53 deletions(-) create mode 100644 desktop/src/lib/motion.ts diff --git a/desktop/AGENTS.md b/desktop/AGENTS.md index efcd8d3e0..4280222bf 100644 --- a/desktop/AGENTS.md +++ b/desktop/AGENTS.md @@ -155,6 +155,13 @@ Read `docs/adr/0005-boards.md` before working on boards. ### Svelte components - Props use `$props()`: `const { foo, bar = undefined }: Props = $props()` +- Respect reduced motion. CSS transitions and animations are handled globally in + `public/index.css`. Anything driven from JS is not: wrap every Svelte + `transition:`/`in:`/`out:`/`animate:` duration, `element.animate()` duration, + and `setTimeout` that waits on an animation in `motion(ms)`, and use + `scrollBehavior()` instead of `behavior: "smooth"` (both from + `@app/lib/motion`). Custom transition functions apply `motion()` to the + durations they return. ### TypeScript diff --git a/desktop/public/index.css b/desktop/public/index.css index c0222e1d5..dfae999c9 100644 --- a/desktop/public/index.css +++ b/desktop/public/index.css @@ -217,3 +217,16 @@ a { -webkit-user-select: text; user-select: text; } + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0s !important; + animation-delay: 0s !important; + animation-iteration-count: 1 !important; + transition-duration: 0s !important; + transition-delay: 0s !important; + scroll-behavior: auto !important; + } +} diff --git a/desktop/src/components/AppSidebar.svelte b/desktop/src/components/AppSidebar.svelte index a4937f77b..57d50d006 100644 --- a/desktop/src/components/AppSidebar.svelte +++ b/desktop/src/components/AppSidebar.svelte @@ -11,6 +11,7 @@ import { hints } from "@app/lib/hints"; import { dynamicInterval } from "@app/lib/interval"; import { modalStore, show } from "@app/lib/modal"; + import { motion } from "@app/lib/motion"; import { badgeCount, notificationCount, @@ -114,7 +115,10 @@ function snapWidth() { snapping = true; if (snapTimeout !== undefined) clearTimeout(snapTimeout); - snapTimeout = setTimeout(() => (snapping = false), SNAP_DURATION_MS); + snapTimeout = setTimeout( + () => (snapping = false), + motion(SNAP_DURATION_MS), + ); } // Held so unmounting mid-drag doesn't leave listeners and the body class @@ -565,8 +569,12 @@
+ in:swap={{ + duration: motion(COLLAPSE_MS), + rise: 8, + width: bodyTargetWidth, + }} + out:swap={{ duration: motion(COLLAPSE_MS) }}>
0} + in:scale={{ + duration: motion(200), + easing: backOut, + start: 0, + }} + out:fade={{ duration: motion(200) }}> {notificationCount.value} {/if} diff --git a/desktop/src/components/ArtifactRow.svelte b/desktop/src/components/ArtifactRow.svelte index 834c3090c..60e386ee0 100644 --- a/desktop/src/components/ArtifactRow.svelte +++ b/desktop/src/components/ArtifactRow.svelte @@ -8,6 +8,7 @@ import { artifactNodeRunning } from "@app/lib/events"; import { invoke, InvokeError } from "@app/lib/invoke"; import { show } from "@app/lib/modal"; + import { motion } from "@app/lib/motion"; import { attestedBy, canAttest, @@ -796,7 +797,7 @@
{#if open} -
+
Metadata diff --git a/desktop/src/components/Comment.svelte b/desktop/src/components/Comment.svelte index 950e3b3ac..6d3e5ae06 100644 --- a/desktop/src/components/Comment.svelte +++ b/desktop/src/components/Comment.svelte @@ -17,6 +17,7 @@ import type { CommentOrigin } from "@app/lib/codeComments"; import { writeToClipboard } from "@app/lib/invoke"; + import { scrollBehavior } from "@app/lib/motion"; import * as utils from "@app/lib/utils"; import DropdownList from "@app/components/DropdownList.svelte"; @@ -145,7 +146,7 @@ mode = "edit"; await tick(); utils.scrollIntoView(`edit-${id}`, { - behavior: "smooth", + behavior: scrollBehavior(), block: "center", }); } else if (mode === "edit") { diff --git a/desktop/src/components/CommitAuthors.svelte b/desktop/src/components/CommitAuthors.svelte index ce36ea404..7a5b915c7 100644 --- a/desktop/src/components/CommitAuthors.svelte +++ b/desktop/src/components/CommitAuthors.svelte @@ -94,11 +94,6 @@ .avatars .avatar + .more { margin-left: 0.25rem; } - @media (prefers-reduced-motion: reduce) { - .avatars .avatar + .avatar { - transition: none; - } - } .card { display: flex; flex-direction: column; diff --git a/desktop/src/components/DraftReviewBar.svelte b/desktop/src/components/DraftReviewBar.svelte index 6dd31e7d9..2ccdc4e02 100644 --- a/desktop/src/components/DraftReviewBar.svelte +++ b/desktop/src/components/DraftReviewBar.svelte @@ -8,6 +8,7 @@ import type { DraftReview } from "@app/lib/draftReviewStorage"; import { draftReviewStorage } from "@app/lib/draftReviewStorage"; + import { motion } from "@app/lib/motion"; import { formatAnchor } from "@app/lib/pierreComments"; import { isPublishableReview, verdictBadge } from "@app/lib/utils"; @@ -573,8 +574,8 @@
+ in:fly={{ y: 120, duration: motion(260), easing: backOut }} + out:fly={{ y: 120, duration: motion(180), easing: cubicIn }}>