Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { render } from "@testing-library/react";
import { describe, expect, it } from "vitest";

import { Skeleton } from "@loopover/ui-kit/components/skeleton";

// #7016: every other animated ui-kit primitive (Spinner, button.tsx, tabs.tsx) disables/reduces its
// animation under prefers-reduced-motion via motion-reduce:animate-none; Skeleton was the one loading-state
// primitive that didn't, despite state-views.tsx's own doc comment claiming the whole family respects it.
describe("Skeleton respects prefers-reduced-motion (#7016)", () => {
it("pairs animate-pulse with motion-reduce:animate-none", () => {
const { container } = render(<Skeleton data-testid="skeleton" />);
const el = container.firstElementChild;
expect(el?.className).toContain("animate-pulse");
expect(el?.className).toContain("motion-reduce:animate-none");
});

it("still merges a caller-supplied className", () => {
const { container } = render(<Skeleton className="h-4 w-full" />);
const el = container.firstElementChild;
expect(el?.className).toContain("h-4");
expect(el?.className).toContain("w-full");
expect(el?.className).toContain("motion-reduce:animate-none");
});
});
2 changes: 1 addition & 1 deletion packages/loopover-ui-kit/src/components/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cn } from "../utils";

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

export { Skeleton };
Loading