Repository navigation
feat(hooks): useContainerReveal — composable hover/focus reveal primitive - #4573
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
July 31, 2026 04:12
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsThumbnail (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. Thumbnail - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
marked this pull request as ready for review
July 31, 2026 05:12
The remove button uses a fixed translucent scrim + on-dark icon (not luminance-adapting), so axe color-contrast can't be guaranteed over arbitrary images. These stories were never gated before; touching Thumbnail.tsx pulls them into the per-component pr-a11y audit. The Media Mode story is untouched by this PR, confirming the violations are pre-existing.
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why a hook, not a prop
Thumbnail(showRemoveOn="hover", #4300) and the proposedTreeListendContentReveal(#4538) ship the same hover/focus reveal mechanic — each with its own*.markers.stylex.ts+ a duplicated opacity block. This extracts the mechanic into one headless, tested primitive so components compose it instead of re-implementing it. This PR proves it out by movingThumbnailonto the hook and deleting its bespoke marker + reveal styles — no public API change.For
TreeList, the recommendation is: don't add a prop — expose the composition via the hook, and add an example/story showing it.What
useContainerReveal()→{ getContainerProps(), getContentRevealProps(opts) }.get*Props), matching theuseLightbox.getTriggerPropsprecedent.getContentRevealProps({isRevealInverted, isLayoutPreserved})— one container hover can drive multiple children with opposite behavior.Accessibility (WCAG 2.2 by construction)
position: absolute+opacity: 0— stays in the a11y tree and tab order, neverdisplay:none.:focus-within.:focus-within(a keyboard user must never watch content vanish) and stays visible on touch.prefers-reduced-motion.The one non-obvious design decision: the marker pool
stylex.when.ancestor(':hover', marker)compiles to.marker:hover *— a descendant selector. A single shared marker therefore leaks across nested reveal containers (an outer row's hover would reveal a nested thumbnail's button). Because StyleX welds the marker into the compiled CSS at build time, the marker cannot be passed as a runtime argument, so the per-marker blocks are written out literally incontainerReveal.pool.stylex.ts(no codegen — it's static output).useContainerRevealhands each concurrently-mounted container a distinct marker from that pool via a module-level free-list (claimed in auseStateinitializer, released on unmount — StrictMode-safe). Nested containers get different markers, so they can't leak. Siblings sharing a marker is harmless (a sibling is never an ancestor). Pool exhaustion degrades gracefully with a dev warning.Risk
Thumbnailbehavior is unchanged — its remove button is absolutely positioned, so it maps to the opacity-only (isLayoutPreserved) variant, exactly matching the prior styles. Full Thumbnail suite passes.Testing
Thumbnailsuite (22 tests) green on the refactor.typecheck,eslint,check-sync,sync-exports --check,check-changesets— all green.Hooks/useContainerRevealwith Reveal, InvertedConceal, PreserveLayout, and a NestedIsolation story that visually proves no leak.color-contrastviolations on Thumbnail stories (the fixed-scrim remove button over arbitrary images) are added to.github/a11y-baseline.json. They were never gated before —pr-a11yonly audits components a PR touches, and one of the two (Media Mode) is untouched by this PR, confirming they predate it.Open questions
useContainerReveal+getContentRevealProps— settled?