Skip to content

Commit 12d030f

Browse files
authored
fix(ui-kit): respect prefers-reduced-motion on Skeleton's pulse animation (#7025)
Every other animated ui-kit primitive (Spinner, button, tabs) pairs its animation with motion-reduce:animate-none; Skeleton was the one loading-state component in that family that didn't, despite state-views.tsx's own doc comment claiming the whole family respects prefers-reduced-motion.
1 parent 57011a8 commit 12d030f

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { render } from "@testing-library/react";
2+
import { describe, expect, it } from "vitest";
3+
4+
import { Skeleton } from "@loopover/ui-kit/components/skeleton";
5+
6+
// #7016: every other animated ui-kit primitive (Spinner, button.tsx, tabs.tsx) disables/reduces its
7+
// animation under prefers-reduced-motion via motion-reduce:animate-none; Skeleton was the one loading-state
8+
// primitive that didn't, despite state-views.tsx's own doc comment claiming the whole family respects it.
9+
describe("Skeleton respects prefers-reduced-motion (#7016)", () => {
10+
it("pairs animate-pulse with motion-reduce:animate-none", () => {
11+
const { container } = render(<Skeleton data-testid="skeleton" />);
12+
const el = container.firstElementChild;
13+
expect(el?.className).toContain("animate-pulse");
14+
expect(el?.className).toContain("motion-reduce:animate-none");
15+
});
16+
17+
it("still merges a caller-supplied className", () => {
18+
const { container } = render(<Skeleton className="h-4 w-full" />);
19+
const el = container.firstElementChild;
20+
expect(el?.className).toContain("h-4");
21+
expect(el?.className).toContain("w-full");
22+
expect(el?.className).toContain("motion-reduce:animate-none");
23+
});
24+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cn } from "../utils";
22

33
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
4-
return <div className={cn("animate-pulse rounded-md bg-primary/10", className)} {...props} />;
4+
return <div className={cn("animate-pulse rounded-md bg-primary/10 motion-reduce:animate-none", className)} {...props} />;
55
}
66

77
export { Skeleton };

0 commit comments

Comments
 (0)