Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

feat(motion): honor reduced motion app-wide, add shared motion presets, pin a matched framer-motion (#1251)

Goldflagcc7880fccc32
diff --git a/client/package.json b/client/package.json
index 8fbfafa45..486d3a8c4 100644
--- a/client/package.json
+++ b/client/package.json
@@ -70,7 +70,7 @@
"d3-scale": "4.0.2",
"date-fns": "^4.4.0",
"embla-carousel-react": "^8.6.0",
- "framer-motion": "12.11.0",
+ "framer-motion": "12.40.0",
"geojson": "0.5.0",
"ip-address": "^10.0.1",
"jotai": "2.17.1",
diff --git a/client/src/app/(home)/SiteCard.tsx b/client/src/app/(home)/SiteCard.tsx
index f95e160ff..3dff8ce12 100644
--- a/client/src/app/(home)/SiteCard.tsx
+++ b/client/src/app/(home)/SiteCard.tsx
@@ -134,7 +134,7 @@ function SiteCardView({
<Link href={`/${siteId}`}>
<div
ref={cardRef}
- className="flex flex-col md:flex-row md:justify-between gap-3 rounded-lg bg-white dark:bg-neutral-900/70 px-3 py-2 border border-neutral-100 dark:border-neutral-850 transition-all duration-300 hover:translate-y-[-2px] w-full"
+ className="flex flex-col md:flex-row md:justify-between gap-3 rounded-lg bg-white dark:bg-neutral-900/70 px-3 py-2 border border-neutral-100 dark:border-neutral-850 transition-all duration-300 motion-safe:hover:translate-y-[-2px] w-full"
>
{showSkeleton ? (
<>
diff --git a/client/src/app/Providers.tsx b/client/src/app/Providers.tsx
index 3a735d3c0..e7d7ecb46 100644
--- a/client/src/app/Providers.tsx
+++ b/client/src/app/Providers.tsx
@@ -9,6 +9,7 @@ import { IS_CLOUD } from "@/lib/const";
import { getStoredDashboardDefaultTime } from "@/lib/defaultTimeRange";
import { getTimezone, useStore } from "@/lib/store";
import QueryProvider from "@/providers/QueryProvider";
+import { MotionConfig } from "framer-motion";
import { ThemeProvider } from "next-themes";
import Script from "next/script";
import { NuqsAdapter } from "nuqs/adapters/next/app";
@@ -58,25 +59,28 @@ export function Providers({ children }: { children: React.ReactNode }) {
return (
<NuqsAdapter>
- <ThemeProvider
- key={themeStorageKey}
- attribute="class"
- enableSystem={true}
- defaultTheme={embedTheme ?? "system"}
- storageKey={themeStorageKey}
- disableTransitionOnChange
- >
- <TooltipProvider>
- <QueryProvider>
- <DashboardTimeInitializer />
- <OrganizationInitializer />
- <AuthenticationGuard />
- {children}
- <VersionCheck />
- </QueryProvider>
- <Toaster />
- </TooltipProvider>
- </ThemeProvider>
+ {/* Honors the OS "reduce motion" setting for every framer animation in the app. */}
+ <MotionConfig reducedMotion="user">
+ <ThemeProvider
+ key={themeStorageKey}
+ attribute="class"
+ enableSystem={true}
+ defaultTheme={embedTheme ?? "system"}
+ storageKey={themeStorageKey}
+ disableTransitionOnChange
+ >
+ <TooltipProvider>
+ <QueryProvider>
+ <DashboardTimeInitializer />
+ <OrganizationInitializer />
+ <AuthenticationGuard />
+ {children}
+ <VersionCheck />
+ </QueryProvider>
+ <Toaster />
+ </TooltipProvider>
+ </ThemeProvider>
+ </MotionConfig>
{appEnv === "prod" && (
<Script src="https://demo.rybbit.com/api/script.js" data-site-id="21" strategy="afterInteractive" />
)}
diff --git a/client/src/app/[site]/bots/components/BotSection.tsx b/client/src/app/[site]/bots/components/BotSection.tsx
index 3be5e263b..931c9256f 100644
--- a/client/src/app/[site]/bots/components/BotSection.tsx
+++ b/client/src/app/[site]/bots/components/BotSection.tsx
@@ -91,7 +91,7 @@ function BotRow({
<div className="hidden group-hover:block text-neutral-600 dark:text-neutral-400">
{item.percentage.toFixed(1)}%
</div>
- <NumberFlow respectMotionPreference={false} value={item.count} format={{ notation: "compact" }} />
+ <NumberFlow value={item.count} format={{ notation: "compact" }} />
</div>
</div>
</div>
diff --git a/client/src/app/[site]/bots/components/BotsOverview.tsx b/client/src/app/[site]/bots/components/BotsOverview.tsx
index 4df01e1a3..21ba00bfd 100644
--- a/client/src/app/[site]/bots/components/BotsOverview.tsx
+++ b/client/src/app/[site]/bots/components/BotsOverview.tsx
@@ -103,7 +103,7 @@ function StatCard({
<Skeleton className="h-8 w-20 rounded-md" />
) : (
<>
- <NumberFlow respectMotionPreference={false} value={value} format={{ notation: "compact" }} />
+ <NumberFlow value={value} format={{ notation: "compact" }} />
{suffix}
</>
)}
diff --git a/client/src/app/[site]/bots/components/ai/AiOverview.tsx b/client/src/app/[site]/bots/components/ai/AiOverview.tsx
index 30ef856dd..b941841a0 100644
--- a/client/src/app/[site]/bots/components/ai/AiOverview.tsx
+++ b/client/src/app/[site]/bots/components/ai/AiOverview.tsx
@@ -44,7 +44,7 @@ function AiStat({
{isLoading ? (
<Skeleton className="h-8 w-20 rounded-md" />
) : (
- <NumberFlow respectMotionPreference={false} value={value} format={{ notation: "compact" }} />
+ <NumberFlow value={value} format={{ notation: "compact" }} />
)}
</div>
</div>
diff --git a/client/src/app/[site]/components/SubHeader/LiveUserCount.tsx b/client/src/app/[site]/components/SubHeader/LiveUserCount.tsx
index d72ad3fff..6db17eec5 100644
--- a/client/src/app/[site]/components/SubHeader/LiveUserCount.tsx
+++ b/client/src/app/[site]/components/SubHeader/LiveUserCount.tsx
@@ -64,7 +64,7 @@ export function LiveUserCount() {
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
<span className="text-sm text-neutral-700 dark:text-neutral-200 ml-1 font-medium">
- {<NumberFlow respectMotionPreference={false} value={data?.count ?? 0} />}
+ {<NumberFlow value={data?.count ?? 0} />}
</span>
</div>
</Button>
diff --git a/client/src/app/[site]/dashboards/components/charts/DashboardStat.tsx b/client/src/app/[site]/dashboards/components/charts/DashboardStat.tsx
index c69527c2a..ac5daccd0 100644
--- a/client/src/app/[site]/dashboards/components/charts/DashboardStat.tsx
+++ b/client/src/app/[site]/dashboards/components/charts/DashboardStat.tsx
@@ -48,11 +48,7 @@ export function DashboardStat({ rows, mapping }: DashboardStatProps) {
style={{ fontSize }}
aria-label={stat.label ? `${stat.label}: ${text}` : text}
>
- {format === "number" ? (
- <NumberFlow respectMotionPreference={false} value={stat.value} format={{ notation: "compact" }} />
- ) : (
- text
- )}
+ {format === "number" ? <NumberFlow value={stat.value} format={{ notation: "compact" }} /> : text}
</div>
{stat.label && (
<span className="max-w-full truncate text-xs text-neutral-500 dark:text-neutral-400">{stat.label}</span>
diff --git a/client/src/app/[site]/events/components/AutocaptureEventsList.tsx b/client/src/app/[site]/events/components/AutocaptureEventsList.tsx
index f068903bb..1f4aae163 100644
--- a/client/src/app/[site]/events/components/AutocaptureEventsList.tsx
+++ b/client/src/app/[site]/events/components/AutocaptureEventsList.tsx
@@ -118,7 +118,7 @@ export function AutocaptureEventsList({ events, isLoading, size = "small" }: Aut
<div className="hidden group-hover:block text-neutral-600 dark:text-neutral-400 text-xs">
{Math.round(percentage * 10) / 10}%
</div>
- <NumberFlow respectMotionPreference={false} value={event.count} format={{ notation: "compact" }} />
+ <NumberFlow value={event.count} format={{ notation: "compact" }} />
</div>
</div>
</div>
diff --git a/client/src/app/[site]/events/components/EventProperties.tsx b/client/src/app/[site]/events/components/EventProperties.tsx
index 2be78f18a..ff4b50a38 100644
--- a/client/src/app/[site]/events/components/EventProperties.tsx
+++ b/client/src/app/[site]/events/components/EventProperties.tsx
@@ -106,11 +106,7 @@ export function EventProperties({ properties, isLoading, selectedEvent, size = "
<div className="hidden group-hover:block text-neutral-500 dark:text-neutral-400">
{Math.round(percentage * 10) / 10}%
</div>
- <NumberFlow
- respectMotionPreference={false}
- value={property.count}
- format={{ notation: "compact" }}
- />
+ <NumberFlow value={property.count} format={{ notation: "compact" }} />
</div>
</div>
</div>
diff --git a/client/src/app/[site]/events/components/OutboundLinksList.tsx b/client/src/app/[site]/events/components/OutboundLinksList.tsx
index aedeb7908..fb04a260c 100644
--- a/client/src/app/[site]/events/components/OutboundLinksList.tsx
+++ b/client/src/app/[site]/events/components/OutboundLinksList.tsx
@@ -136,7 +136,7 @@ export function OutboundLinksList({ outboundLinks, isLoading, size = "small" }:
{/* <div className="hidden group-hover:block text-neutral-600 dark:text-neutral-400 text-xs">
{lastClicked.toRelative()}
</div> */}
- <NumberFlow respectMotionPreference={false} value={link.count} format={{ notation: "compact" }} />
+ <NumberFlow value={link.count} format={{ notation: "compact" }} />
</div>
</div>
</div>
diff --git a/client/src/app/[site]/main/components/MainSection/Overview.tsx b/client/src/app/[site]/main/components/MainSection/Overview.tsx
index c0ef8e4e2..e3fc9eeb0 100644
--- a/client/src/app/[site]/main/components/MainSection/Overview.tsx
+++ b/client/src/app/[site]/main/components/MainSection/Overview.tsx
@@ -128,14 +128,14 @@ const Stat = ({
<Tooltip>
<TooltipTrigger>
<NumberFlow
- respectMotionPreference={false}
+
value={decimals ? Number(value.toFixed(decimals)) : value}
format={{ notation: "compact" }}
/>
</TooltipTrigger>
<TooltipContent>
<NumberFlow
- respectMotionPreference={false}
+
value={decimals ? Number(value.toFixed(decimals)) : value}
format={{ notation: "standard" }}
/>
diff --git a/client/src/app/[site]/main/components/MainSection/OverviewLite.tsx b/client/src/app/[site]/main/components/MainSection/OverviewLite.tsx
index 02cf5831e..56d918a09 100644
--- a/client/src/app/[site]/main/components/MainSection/OverviewLite.tsx
+++ b/client/src/app/[site]/main/components/MainSection/OverviewLite.tsx
@@ -97,14 +97,12 @@ const Stat = ({
<Tooltip>
<TooltipTrigger>
<NumberFlow
- respectMotionPreference={false}
value={decimals ? Number(value.toFixed(decimals)) : value}
format={{ notation: "compact" }}
/>
</TooltipTrigger>
<TooltipContent>
<NumberFlow
- respectMotionPreference={false}
value={decimals ? Number(value.toFixed(decimals)) : value}
format={{ notation: "standard" }}
/>
diff --git a/client/src/app/[site]/performance/components/PerformanceOverview.tsx b/client/src/app/[site]/performance/components/PerformanceOverview.tsx
index 995e575a0..09f3e534d 100644
--- a/client/src/app/[site]/performance/components/PerformanceOverview.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceOverview.tsx
@@ -76,11 +76,7 @@ const Stat = ({
) : (
<>
<span className={getMetricColor(id, value)}>
- <NumberFlow
- respectMotionPreference={false}
- value={Number(formatMetricValue(id, value))}
- format={{ notation: "compact" }}
- />
+ <NumberFlow value={Number(formatMetricValue(id, value))} format={{ notation: "compact" }} />
<span className="text-sm ml-1">{getMetricUnit(id, value)}</span>
</span>
<ChangePercentage current={value} previous={previous} />
diff --git a/client/src/app/globals.css b/client/src/app/globals.css
index 67bd9d12d..cfd7d327c 100644
--- a/client/src/app/globals.css
+++ b/client/src/app/globals.css
@@ -685,3 +685,20 @@
--color-chart-ring-background: var(----chart-ring-background);
--color-chart-label: var(----chart-label);
}
+
+/*
+ ---break---
+*/
+/* PRODUCT.md: honor prefers-reduced-motion on every animation. Framer animations
+ are handled by <MotionConfig reducedMotion="user">; this covers CSS ones
+ (Tailwind animate-*, transitions, keyframes, ldrs). */
+@media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 0.01ms !important;
+ scroll-behavior: auto !important;
+ }
+}
diff --git a/client/src/app/rollup/components/MainSection/MainSection.tsx b/client/src/app/rollup/components/MainSection/MainSection.tsx
index eae6f0b06..6e507e09a 100644
--- a/client/src/app/rollup/components/MainSection/MainSection.tsx
+++ b/client/src/app/rollup/components/MainSection/MainSection.tsx
@@ -50,11 +50,7 @@ const Stat = ({
<span>{valueFormatter(value)}</span>
) : (
<span>
- <NumberFlow
- respectMotionPreference={false}
- value={decimals ? Number(value.toFixed(decimals)) : value}
- format={{ notation: "compact" }}
- />
+ <NumberFlow value={decimals ? Number(value.toFixed(decimals)) : value} format={{ notation: "compact" }} />
{postfix && <span>{postfix}</span>}
</span>
)}
diff --git a/client/src/app/rollup/components/sections/RollupSection.tsx b/client/src/app/rollup/components/sections/RollupSection.tsx
index 58715415f..a6b906ab3 100644
--- a/client/src/app/rollup/components/sections/RollupSection.tsx
+++ b/client/src/app/rollup/components/sections/RollupSection.tsx
@@ -119,11 +119,7 @@ export function RollupSection({
<div className="hidden group-hover:block text-neutral-600 dark:text-neutral-400">
{round(item.percentage, 1)}%
</div>
- <NumberFlow
- respectMotionPreference={false}
- value={item.count}
- format={{ notation: "compact" }}
- />
+ <NumberFlow value={item.count} format={{ notation: "compact" }} />
</div>
</div>
</div>
diff --git a/client/src/app/widget/[siteId]/route.ts b/client/src/app/widget/[siteId]/route.ts
index 99b5caaf8..4104a2945 100644
--- a/client/src/app/widget/[siteId]/route.ts
+++ b/client/src/app/widget/[siteId]/route.ts
@@ -191,6 +191,9 @@ function renderHTML(c: Config) {
0% { transform: scale(1); opacity: 0.5; }
100% { transform: scale(2.2); opacity: 0; }
}
+ @media (prefers-reduced-motion: reduce) {
+ .pulse::before { animation: none; }
+ }
</style>
</head>
<body>
diff --git a/client/src/components/SpinningGlobe.test.tsx b/client/src/components/SpinningGlobe.test.tsx
new file mode 100644
index 000000000..7ee48176a
--- /dev/null
+++ b/client/src/components/SpinningGlobe.test.tsx
@@ -0,0 +1,99 @@
+import React from "react";
+import { act, cleanup, render } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+type Handler = (event: unknown) => void;
+type FakeMapInstance = { fire: (event: string) => void; easeTo: ReturnType<typeof vi.fn> };
+
+const mocks = vi.hoisted(() => ({ reducedMotion: false, maps: [] as FakeMapInstance[] }));
+
+vi.mock("mapbox-gl", () => {
+ class FakeMap {
+ handlers = new Map<string, Handler[]>();
+ // Like Mapbox (respectPrefersReducedMotion defaults to true), reduced motion makes easeTo
+ // instant, and an instant ease fires "moveend" synchronously.
+ easeTo = vi.fn(() => {
+ if (mocks.reducedMotion) this.fire("moveend");
+ });
+ constructor() {
+ mocks.maps.push(this);
+ }
+ on(event: string, layerOrHandler: string | Handler, handler?: Handler) {
+ const fn = typeof layerOrHandler === "function" ? layerOrHandler : handler!;
+ this.handlers.set(event, [...(this.handlers.get(event) ?? []), fn]);
+ return this;
+ }
+ off() {
+ return this;
+ }
+ fire(event: string) {
+ (this.handlers.get(event) ?? []).forEach(fn => fn({}));
+ }
+ getZoom() {
+ return 1.5;
+ }
+ getCenter() {
+ return { lng: 0, lat: 20 };
+ }
+ getLayer() {
+ return undefined;
+ }
+ setPaintProperty() {}
+ setFog() {}
+ addSource() {}
+ addLayer() {}
+ remove() {}
+ }
+ return { default: { Map: FakeMap, Marker: class {}, accessToken: "" } };
+});
+vi.mock("../lib/configs", () => ({ useConfigs: () => ({ configs: { mapboxToken: "pk.test" }, isLoading: false }) }));
+
+import { SpinningGlobe } from "./SpinningGlobe";
+
+function renderGlobe() {
+ render(
+ <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
+ <SpinningGlobe />
+ </QueryClientProvider>
+ );
+ const map = mocks.maps.at(-1)!;
+ act(() => map.fire("style.load"));
+ return map;
+}
+
+beforeEach(() => {
+ mocks.maps = [];
+ vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue({} as RenderingContext);
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => ({ json: async () => ({ data: [] }) }))
+ );
+ Object.defineProperty(window, "matchMedia", {
+ configurable: true,
+ writable: true,
+ value: (query: string) => ({ matches: mocks.reducedMotion, media: query }),
+ });
+});
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ vi.unstubAllGlobals();
+});
+
+describe("SpinningGlobe", () => {
+ it("spins at one revolution per two minutes by default", () => {
+ mocks.reducedMotion = false;
+ const map = renderGlobe();
+ expect(map.easeTo).toHaveBeenCalledTimes(1);
+ expect(map.easeTo).toHaveBeenCalledWith(expect.objectContaining({ center: { lng: -3, lat: 20 }, duration: 1000 }));
+ });
+
+ it("stays still under reduced motion, including after the user lets go", () => {
+ mocks.reducedMotion = true;
+ const map = renderGlobe();
+ act(() => map.fire("mouseup"));
+ act(() => map.fire("dragend"));
+ expect(map.easeTo).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/components/SpinningGlobe.tsx b/client/src/components/SpinningGlobe.tsx
index 0158414df..03460bf48 100644
--- a/client/src/components/SpinningGlobe.tsx
+++ b/client/src/components/SpinningGlobe.tsx
@@ -164,9 +164,14 @@ export function SpinningGlobe() {
mapRef.current = map;
+ // The idle spin is decorative, so reduced-motion users get a still globe. The check must stay:
+ // Mapbox honors the setting by making easeTo instant, which fires "moveend" synchronously and
+ // would turn the moveend -> spinGlobe loop below into unbounded recursion.
+ const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
+
// Spin globe function using easeTo for smooth animation
const spinGlobe = () => {
- if (!mapRef.current) return;
+ if (!mapRef.current || reducedMotion.matches) return;
const zoom = mapRef.current.getZoom();
if (!isUserInteractingRef.current && zoom < MAX_SPIN_ZOOM) {
let distancePerSecond = 360 / SECONDS_PER_REVOLUTION;
diff --git a/client/src/components/interior/README.md b/client/src/components/interior/README.md
new file mode 100644
index 000000000..b88bb18d8
--- /dev/null
+++ b/client/src/components/interior/README.md
@@ -0,0 +1,10 @@
+# Ported micro-interactions
+
+Components and hooks adapted from interior.dev and Beautiful UI (both MIT, see `THIRD_PARTY_LICENSES.md`).
+
+- **Port the logic, not the markup.** Keep the hook, state machine, timings and a11y wiring. Render through Rybbit primitives (`Button`, Radix, `cn()`) and restyle to `DESIGN.md` tokens: neutral ramp, emerald only for action or success, radii ≤ 4.8px, no resting shadows.
+- **Motion:** import from `"framer-motion"`, never `"motion/react"`, and take springs, easings and fades from `@/lib/motion`. `<MotionConfig reducedMotion="user">` covers framer animations; never branch DOM structure on `useReducedMotion()`.
+- **Keep Radix for overlays** (dialogs, popovers, menus, tooltips). Borrow upstream spring values, not the components.
+- **Localize every string**, including aria-labels and sr-only announcements, with `useExtracted()`, and format numbers for the active locale.
+- **Header comment** on the first line of each ported file: `// Adapted from interior.dev "<Component>" (MIT). See ./THIRD_PARTY_LICENSES.md` (or `Beautiful UI "<Component>"`).
+- **Never install with the shadcn CLI.** Registry items declare the `motion` package, which would add a second copy of framer-motion.
diff --git a/client/src/components/interior/THIRD_PARTY_LICENSES.md b/client/src/components/interior/THIRD_PARTY_LICENSES.md
new file mode 100644
index 000000000..e2739a48d
--- /dev/null
+++ b/client/src/components/interior/THIRD_PARTY_LICENSES.md
@@ -0,0 +1,59 @@
+# Third-party licenses
+
+Components and hooks in this folder, the motion presets in `src/lib/motion.ts` and the loader keyframes in `src/app/globals.css` are adapted from the projects below. Each adapted file names its source in a header comment.
+
+## interior.dev
+
+Source: https://github.com/ddoemonn/interior
+
+```
+MIT License
+
+Copyright (c) 2026 ozzy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+```
+
+## Beautiful UI
+
+Source: https://www.beautifului.dev/license
+
+```
+MIT License
+
+Copyright (c) 2026 Shane Levine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+```
diff --git a/client/src/components/ui/card.tsx b/client/src/components/ui/card.tsx
index d9c552770..3ff28e742 100644
--- a/client/src/components/ui/card.tsx
+++ b/client/src/components/ui/card.tsx
@@ -3,7 +3,6 @@
import { cn } from "@/lib/utils";
import { Zoomies } from "ldrs/react";
import "ldrs/react/Zoomies.css";
-import { useTheme } from "next-themes";
import * as React from "react";
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
@@ -18,17 +17,22 @@ const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElemen
));
Card.displayName = "Card";
+// The color comes from CSS (currentColor + dark:), so it follows the resolved theme class. Reading
+// next-themes' `theme` returned "system" for most users and painted the light color in dark mode.
+// Under reduced motion the sweeping bar is swapped for a static one, in CSS so the markup never branches.
const CardLoader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
- ({ className, ...props }, ref) => {
- const { theme } = useTheme();
- const loaderColor = theme === "dark" ? "hsl(var(--neutral-400))" : "hsl(var(--neutral-200))";
-
- return (
- <div ref={ref} className={cn("mt-[-15px] absolute top-0 left-0 w-full", className)} {...props}>
- <Zoomies size={1400} stroke="3" bg-opacity="0.1" speed="1.4" color={loaderColor} />
- </div>
- );
- }
+ ({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("mt-[-15px] absolute top-0 left-0 w-full text-neutral-200 dark:text-neutral-400", className)}
+ {...props}
+ >
+ <span className="motion-reduce:hidden">
+ <Zoomies size={1400} stroke="3" bg-opacity="0.1" speed="1.4" color="currentColor" />
+ </span>
+ <span className="hidden motion-reduce:inline-block h-[3px] w-full bg-current opacity-50" />
+ </div>
+ )
);
CardLoader.displayName = "CardLoader";
diff --git a/client/src/lib/motion.ts b/client/src/lib/motion.ts
new file mode 100644
index 000000000..a864532d7
--- /dev/null
+++ b/client/src/lib/motion.ts
@@ -0,0 +1,31 @@
+import type { Transition } from "framer-motion";
+
+// Shared motion presets. The values follow interior.dev's conventions (MIT, see
+// components/interior/THIRD_PARTY_LICENSES.md) so every animated component in
+// the app moves the same way. Reduced motion is handled once, by the
+// <MotionConfig reducedMotion="user"> in Providers: framer animations become
+// instant, so components only branch *styles* on useReducedMotion(), never DOM
+// structure (it returns null during SSR).
+
+// Enters decelerate hard; exits accelerate and are shorter.
+export const EASE_OUT = [0.23, 1, 0.32, 1] as const;
+export const EASE_IN = [0.4, 0, 1, 1] as const;
+
+// Label and icon swaps.
+export const SPRING_CROSSFADE: Transition = { type: "spring", stiffness: 260, damping: 34, mass: 0.8 };
+// Thumbs, highlights, checks: anything that travels a short distance.
+export const SPRING_CELL: Transition = { type: "spring", stiffness: 520, damping: 34, mass: 0.45 };
+// Chevrons, carets, chips.
+export const SPRING_NUDGE: Transition = { type: "spring", stiffness: 700, damping: 46, mass: 0.5 };
+// Height disclosure (accordions, expanding rows).
+export const SPRING_DISCLOSE: Transition = { type: "spring", stiffness: 190, damping: 30, mass: 1 };
+// Progress and share-bar fills.
+export const SPRING_FILL: Transition = { type: "spring", stiffness: 210, damping: 34, mass: 0.9 };
+// The only underdamped preset: a small celebratory pop.
+export const SPRING_POP: Transition = { type: "spring", stiffness: 640, damping: 22, mass: 0.7 };
+// Floating panels (pills, palettes).
+export const SPRING_PANEL: Transition = { type: "spring", stiffness: 420, damping: 36, mass: 0.9 };
+
+export const FADE_IN: Transition = { duration: 0.18, ease: EASE_OUT };
+export const FADE_OUT: Transition = { duration: 0.14, ease: EASE_IN };
+export const INSTANT: Transition = { duration: 0 };
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 614ff1771..a60e3ca98 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7,6 +7,8 @@ settings:
overrides:
'@types/react': 19.2.7
kysely: 0.28.17
+ motion-dom: 12.40.0
+ motion-utils: 12.39.0
importers:
@@ -174,8 +176,8 @@ importers:
specifier: ^8.6.0
version: 8.6.0([email protected])
framer-motion:
- specifier: 12.11.0
+ specifier: 12.40.0
geojson:
specifier: 0.5.0
version: 0.5.0
@@ -5555,8 +5557,8 @@ packages:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
- resolution: {integrity: sha512-BaBPmkhaC2l0n619Kt1nQaxSdUdyyz5V1Z7EKJ1CcraOTZitgVx0RTbL8lmg2XesaFi6o8MPBIhkWDIvzDpGaQ==}
+ resolution: {integrity: sha512-uaBd3qC1v3KQqBEjwTUd183K6PbS+j0yR9w9VmEOLWA/tnUcSn8Xa3uck7t4dgpDoUss8xQTcj8W2L07lrnLFg==}
peerDependencies:
'@emotion/is-prop-valid': '*'
react: ^18.0.0 || ^19.0.0
@@ -6450,11 +6452,11 @@ packages:
resolution: {integrity: sha512-m2fmM2dDm7GZQsY7KK2cme8agi+AAljILjQnof7p1ZMDe6dQ4bdnSMx0cPppudoeNv5hEFQirN6u+O4fDE0IWA==}
- resolution: {integrity: sha512-n5yolOs0TQQBRUFImrRfs/+6X4p3Q4n1dUEqt/H58Vx7OW6RF+foWEgmTVDhIWJIMXOuNNL0apKH2S16en9eiA==}
+ resolution: {integrity: sha512-HxU3ZaBwNPVQUBQf1xxgq+7JrPNZvjLVxgbpEZL7RrWJnsxOf0/OM+yrHG9ogLQ31Do/r57Oz2gQWPK+6q62mg==}
- resolution: {integrity: sha512-eAWoPgr4eFEOFfg2WjIsMoqJTW6Z8MTUCgn/GZ3VRpClWBdnbjryiA3ZSNLyxCTmCQx4RmYX6jX1iWHbenUPNQ==}
+ resolution: {integrity: sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ==}
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
@@ -13490,10 +13492,10 @@ snapshots:
dependencies:
- motion-dom: 12.23.23
- motion-utils: 12.23.6
+ motion-dom: 12.40.0
+ motion-utils: 12.39.0
tslib: 2.8.1
optionalDependencies:
react: 19.2.4
@@ -14366,11 +14368,11 @@ snapshots:
dependencies:
- motion-utils: 12.23.6
+ motion-utils: 12.39.0
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 63697ef15..ba0df0eee 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -10,6 +10,12 @@ autoInstallPeers: false
overrides:
"@types/react": 19.2.7
kysely: 0.28.17
+ # framer-motion depends on motion-dom/motion-utils with caret ranges, so the
+ # lockfile can pair it with a newer motion-dom whose render loop it doesn't
+ # understand (12.11 + 12.23 animated values without repainting). Keep the trio
+ # matched, and bump all three together (docs/ uses the same versions).
+ motion-dom: 12.40.0
+ motion-utils: 12.39.0
# Native modules and build tools used by the apps.
allowBuilds: