fix(registry): make the tabs active label follow the sliding indicator - #3437
Open
rajanpanth wants to merge 1 commit into
Open
fix(registry): make the tabs active label follow the sliding indicator#3437rajanpanth wants to merge 1 commit into
rajanpanth wants to merge 1 commit into
Conversation
The component pinned its active colour to the second button with button:nth-of-type(2), while the pill starts under the first. Before the slide, Plan sat gray on the dark pill and Debug sat white on the light track, and the two only agreed once the pill reached Debug. The pill now carries a clipped copy of the label row. Countering the pill's own translate keeps that copy aligned with the buttons underneath at every frame, so the white text is exactly the part of the row the pill covers and it crosses over as the pill moves, driven by the same --hf-tab-x the timeline already animates. The inactive gray also failed WCAG AA at 4.40:1 against the track. #6b6b73 measures 4.80:1. Fixes heygen-com#3266
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.
Fixes #3266
Problem
The component pinned its active colour to a fixed tab:
The pill starts under the first tab, so before the slide "Plan" was gray on the dark pill and "Debug" was white on the light track. The two only agreed once the pill arrived at "Debug".
The inactive gray
#71717aalso measured 4.40:1 against the#f4f4f5track, just under the 4.5:1 AA requirement.Fix
The pill now carries a clipped copy of the label row:
.indicatorgetsoverflow: hidden, and the copy counters the pill's own translate:That keeps the copy aligned with the buttons underneath at every frame, so the white text is exactly the part of the row the pill covers. It crosses over mid-slide instead of being pinned to one tab, and it is driven by the same
--hf-tab-xthe timeline already animates, so it stays deterministic under seek. The documented timeline recipe is unchanged.Inactive gray is now
#6b6b73, 4.80:1.One consequence worth flagging
.indicatorneededz-index: 2to sit above thez-index: 1buttons, because itstransformmakes it a stacking context and the label copy cannot otherwise paint above the row. The copy has to live inside.indicatorsince that is the element the timeline sets--hf-tab-xon, and inheritance only goes downward.So the pill's
box-shadownow paints over the track rather than behind the labels. I think this reads correctly, a raised pill casting onto what is below it, but it is a visual change beyond the reported bug and easy to revert if you would rather not have it. The alternative I considered was animatingleftinstead oftransform, which keeps the old layering exactly but trades a composited property for a layout one.Verification
Measured in the browser against the demo, at several points of the slide:
--hf-tab-x0px43px86pxelementFromPointat each label centre confirms the pill's subtree is topmost exactly where the pill sits and the gray row elsewhere.Contrast computed with the WCAG relative-luminance formula:
#71717a4.397:1,#6b6b734.805:1, white on the#18181bpill 17.72:1.The
labelsvariable rebuilds both rows, checked with four labels: 4 row buttons, 4 copies, 0.00px drift, copies attabIndex -1. The copy isaria-hiddenandpointer-events: noneso it adds nothing to the accessibility tree or the tab order.node scripts/lint-registry-items.mjspasses at 372 items, 0 errors. Bothdemo.htmland the installable snippet carry the same change, including the demo's duplicated head style block.