mirror of
https://github.com/bitbaum/bip-kit.git
synced 2026-12-04 04:57:05 +01:00
#27 cleared the code out from under the copy button with a fixed padding-top on the <pre> (--bp-copy-clearance, 2.75rem), sized to the button's measured height of ~30px. That number was the bug waiting to happen: the button's height is decided by the consumer's stylesheet, not this one. fleetcrown has a global accessibility rule — `button, summary, select, textarea, [role="button"] { min-height: 2.75rem }` under `@media (pointer: coarse)`, the fleet's own 44px touch-target guideline — so its copy button is 44px tall. top 8px + 44px puts its bottom at 52px; the first code line starts at 46px. Measured live on fleetcrown at 390x844 with hasTouch: the button covers the tail of the opening line. kivvi and botsmann (30px buttons, no coarse-pointer rule) show 0 overlap, which is exactly what made it fragile: correctness depended on a consumer rule bip-kit cannot see. So the fix is to the class of bug, not the number. The button is now in normal flow: a toolbar row (.bp-codeblock-toolbar — flex, justify-end) above the <pre>, holding the optional filename label (now a span in that row rather than a figcaption above the body) and the copy button. Layout pays for the button's height whatever a consumer sizes it to, so code can never sit under it. --bp-copy-clearance and the padding-top it drove are deleted. Kept: desktop hover-reveal under (hover: hover) and (pointer: fine) — fading is opacity-only, so the toolbar keeps its height and nothing jumps on reveal; always-visible on touch; data-copied state; focus-visible; clipboard copy. Toolbar precedes the code in DOM order, so keyboard and screen-reader users reach "copy" before the thing it copies. Print zeroes the toolbar's top padding so an empty toolbar (button hidden, no filename) collapses to nothing. Consumer CSS: grepped all eight sites (orangecat, fleetcrown, evig, botsmann, datacat, aoz-housing, kivvi, petvity) for bp-copy, bp-codeblock-body, copy-clearance, bp-codeblock-filename — no overrides anywhere. Only theming vars and orangecat's shiki-span color scope touch bp-codeblock-*. Guards: test/styles.test.js asserts no rule mentioning .bp-copy positions it out of flow, that .bp-codeblock-toolbar is a flex row in flow, that --bp-copy-clearance is gone and the scroller reserves no padding-top, and that print collapses the toolbar. test/react-render.test.js asserts the toolbar (containing the one copy button) closes before the <pre> opens, for the plain and shiki paths, with and without a filename. Mutation-proved: restoring position:absolute on .bp-copy → red (1 test); reintroducing the clearance var + padding-top → red (1); moving CopyButton below the code → red (2); restored → 150/150 green. Rendered check with the built dist and fleetcrown's coarse-pointer rule injected: at 390x844 hasTouch the button is 44px tall, bottom at 53px, first code text at 64px, no intersection, scrollWidth == clientWidth; at 1440 the button rests at opacity 0, reveals to 1 on hover of that block, block height unchanged (jump 0). Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>