Repository navigation
feat!: shimmer marked bones by default (BON-16) #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hunterbecton
merged 2 commits into
main
from
hunter/bon-16-marked-bones-do-not-animate-by-default-unlike-auto-bones
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@camp.dev/bones": minor | ||
| --- | ||
|
|
||
| Marked bones (`data-bone`) now shimmer by default, matching auto bones and the measured overlay. Before this, `bones.css` only animated inside a `data-bone-animate` scope, so a page that mixed an `aria-busy` region with explicit `data-bone` markup showed shimmering auto bones beside frozen marked ones. Set `data-bone-animate="none"` on a bone, a wrapper, or `<body>` to keep skeletons still. `"pulse"` still switches the animation. Under `prefers-reduced-motion: reduce`, the default and the `shimmer` and `pulse` scopes all downgrade to a slow pulse, and `none` stays still. This replaces the old reduced-motion rule, which pulsed the whole `aria-busy` element on top of the bar's own animation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { describe, expect, test } from "vite-plus/test"; | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // bones.css reduced-motion contract | ||
| // | ||
| // Marked bones shimmer by default (BON-16), and the shimmer/pulse scopes can | ||
| // switch that. Under prefers-reduced-motion: reduce every animated path must | ||
| // downgrade to a slow pulse, and data-bone-animate="none" must stay still. | ||
| // The browser runner cannot emulate media features, so this reads the shipped | ||
| // file and pins where the override lives, the same way boundary.test.ts pins | ||
| // the overlay's shadow sheet. | ||
| // --------------------------------------------------------------------------- | ||
|
|
||
| const css = readFileSync(join(import.meta.dirname, "../src/css/bones.css"), "utf8").replace( | ||
| /\/\*[\s\S]*?\*\//g, | ||
| "", | ||
| ); | ||
|
|
||
| const REDUCED = "@media (prefers-reduced-motion: reduce)"; | ||
|
|
||
| /** The brace-balanced block that starts at the first `marker` in `source`. */ | ||
| function blockAt(source: string, marker: string): string { | ||
| const start = source.indexOf(marker); | ||
| if (start === -1) throw new Error(`${marker} not found`); | ||
| const open = source.indexOf("{", start); | ||
| let depth = 0; | ||
| for (let i = open; i < source.length; i++) { | ||
| if (source[i] === "{") depth++; | ||
| else if (source[i] === "}" && --depth === 0) { | ||
| return source | ||
| .slice(start, i + 1) | ||
| .replace(/\s+/g, " ") | ||
| .trim(); | ||
| } | ||
| } | ||
| throw new Error(`unbalanced braces after ${marker}`); | ||
| } | ||
|
|
||
| /** The `@scope` block for one data-bone-animate value. */ | ||
| function scopeFor(value: string): string { | ||
| return blockAt(css, `@scope ([data-bone-animate="${value}"])`); | ||
| } | ||
|
|
||
| describe("bones.css reduced-motion contract", () => { | ||
| test("the default shimmer downgrades to pulse for every bone kind", () => { | ||
| const outside = css.split("@scope")[0]; | ||
| const block = blockAt(outside, REDUCED); | ||
| for (const selector of [ | ||
| '[data-bone="text"]::after', | ||
| '[data-bone="block"]', | ||
| '[data-bone="container"]::before', | ||
| ]) { | ||
| expect(block).toContain(selector); | ||
| } | ||
| expect(block).toContain("animation: bone-pulse"); | ||
| }); | ||
|
|
||
| test("the shimmer and pulse scopes downgrade to pulse inside the scope", () => { | ||
| for (const value of ["shimmer", "pulse"]) { | ||
| const scope = scopeFor(value); | ||
| const block = blockAt(scope, REDUCED); | ||
| expect(block).toContain(":is(:scope, :scope *)"); | ||
| expect(block).toContain("animation: bone-pulse"); | ||
| } | ||
| }); | ||
|
|
||
| test("the none scope has no reduced-motion override: none still means none", () => { | ||
| expect(scopeFor("none")).not.toContain(REDUCED); | ||
| }); | ||
|
|
||
| test("nothing animates the aria-busy element itself", () => { | ||
| // The old reduced-motion override animated whatever carried aria-busy, | ||
| // which stacked an opacity pulse on top of the bar's own animation | ||
| // instead of replacing it. Bones target their bars, never the carrier. | ||
| expect(css).not.toContain('[aria-busy="true"]'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { afterEach, expect, test } from "vite-plus/test"; | ||
| import "../../src/css/bones.css"; | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // BON-16: marked bones shimmer by default, the same as auto bones and the | ||
| // measured overlay. Before this, bones.css only animated inside a | ||
| // data-bone-animate scope, so a page mixing an aria-busy region with explicit | ||
| // data-bone markup showed shimmering auto bones beside frozen marked ones. | ||
| // data-bone-animate="none" is the opt-out. | ||
| // --------------------------------------------------------------------------- | ||
|
|
||
| afterEach(() => { | ||
| document.body.innerHTML = ""; | ||
| }); | ||
|
|
||
| function mount(html: string): HTMLElement { | ||
| document.body.insertAdjacentHTML("beforeend", html); | ||
| return document.body.lastElementChild as HTMLElement; | ||
| } | ||
|
|
||
| test("a text bone shimmers with no data-bone-animate anywhere", () => { | ||
| const root = mount(`<div><span data-bone="text">hidden</span></div>`); | ||
| const bar = getComputedStyle(root.querySelector("span")!, "::after"); | ||
| expect(bar.animationName).toBe("bone-shimmer"); | ||
| }); | ||
|
|
||
| test("a block bone shimmers with no data-bone-animate anywhere", () => { | ||
| const root = mount(`<div><img data-bone="block" alt="avatar" width="48" height="48" /></div>`); | ||
| expect(getComputedStyle(root.querySelector("img")!).animationName).toBe("bone-shimmer"); | ||
| }); | ||
|
|
||
| test("a container bone's cover shimmers with no data-bone-animate anywhere", () => { | ||
| const root = mount(`<div><div data-bone="container"><p>hidden</p></div></div>`); | ||
| const cover = getComputedStyle(root.querySelector("[data-bone]")!, "::before"); | ||
| expect(cover.animationName).toBe("bone-shimmer"); | ||
| }); | ||
|
|
||
| test("data-bone-animate='none' on the bone itself opts out of the default", () => { | ||
| const root = mount(`<div><span data-bone="text" data-bone-animate="none">hidden</span></div>`); | ||
| const bar = getComputedStyle(root.querySelector("span")!, "::after"); | ||
| expect(bar.animationName).toBe("none"); | ||
| }); | ||
|
|
||
| test("data-bone-animate='none' on a wrapper opts its bones out of the default", () => { | ||
| const root = mount(`<div data-bone-animate="none"><span data-bone="text">hidden</span></div>`); | ||
| const bar = getComputedStyle(root.querySelector("span")!, "::after"); | ||
| expect(bar.animationName).toBe("none"); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.