feat(donut-s2): Emphasize - #897
Open
madelineluke wants to merge 2 commits into
Open
Conversation
madelineluke
force-pushed
the
feat/donut-emphasize-segment-color-swap
branch
from
August 27, 2026 20:23
e414b92 to
e50e85f
Compare
madelineluke
force-pushed
the
feat/donut-emphasize-segment-color-swap
branch
from
August 27, 2026 20:55
e50e85f to
805b5c9
Compare
madelineluke
force-pushed
the
feat/donut-emphasize-segment-color-swap
branch
from
August 27, 2026 21:31
805b5c9 to
6aa7a0e
Compare
…swap - Add emphasizedItems/otherItemColor to DonutOptions, mirroring Line's primarySeries/otherSeriesColor but matched against the segment's own `color` facet value (not idKey), so users specify category names directly rather than internal row identifiers. - Add a new fill production rule in getArcMark that swaps non-emphasized segments to solid gray-400 at full opacity - a static color swap, kept fully independent from the opacity-based hover/legend-fade mechanism donut-hover already established. - Non-emphasized segments' labels are explicitly left untouched (verified by a regression test asserting identical label encodes to an ordinary interactive donut) - unlike Line's primarySeries, which suppresses non-primary direct labels entirely. - Mouse hover is fully suppressed while emphasize is active, for every segment (not just non-emphasized ones) - emphasize is a static, design-time state, and hover re-fading an already-gray sibling (or fading anything at all) fights that. Reuses the existing generic excludeCondition param on addHoveredItemSignal to keep HOVERED_ITEM null unconditionally rather than inventing a new mechanism. - Add Donut/Features/Emphasize stories: a single emphasized segment, and multiple emphasized segments. Verified live in Storybook via precise on-pixel hover simulation: hovering either the emphasized segment or a grayed-out segment produces zero opacity change while emphasizedItems is set. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
madelineluke
force-pushed
the
feat/donut-emphasize-segment-color-swap
branch
from
August 27, 2026 21:43
6aa7a0e to
75c460f
Compare
…decision Records the actual implementation choice (hover fully suppressed while any segment is emphasized) in the spec's edgeCases/openQuestions, flagged as a first-iteration simplification rather than a locked-in design, so a future iteration can revisit whether non-emphasized segments should stay independently hoverable.
|
|
🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-897 🎨 S2 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-897-s2 📚 Docs -> https://opensource.adobe.com/react-spectrum-charts/PR-897-docs/ |
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.



Description
Implements the
donut-emphasizespec: a static, design-time per-segment highlight, distinct from the mouse-drivendonut-hoverfeature (#895) this is stacked on.emphasizedItems/otherItemColortoDonutOptions, mirroring Line'sprimarySeries/otherSeriesColorbut matched against the segment's owncolorfacet value (notidKey), so users specify category names directly rather than internal row identifiers.fillproduction rule ingetArcMarkthat swaps non-emphasized segments to solid gray-400 at full opacity - a static color swap, kept fully independent from the opacity-based hover/legend-fade mechanismdonut-hoverestablished.primarySeries, which suppresses non-primary direct labels entirely.excludeConditionparam onaddHoveredItemSignalrather than inventing a new mechanism.Donut/Features/Emphasizestories: a single emphasized segment, and multiple emphasized segments.Related Issue
planning/specs/donut/donut-emphasize.json(approved)Motivation and Context
Figma's donut component has a static per-segment
Emphasizevariant, independent of mouse position, that's distinct from (and not yet built alongside) the mouse-hover fadedonut-hoverimplements. Building this on top of the hover branch let the interaction between the two be resolved with real behavior rather than guesswork - specifically, whether hovering a grayed-out or emphasized segment should still fade siblings (decided: no, hover is fully suppressed while emphasize is active, since it's meant to be a stable, non-interactive state).How Has This Been Tested?
donutUtils.test.ts(fill encoding for single/multiple emphasized items, customotherItemColor, opacity rules untouched),donutSpecBuilder.test.ts(hover fully suppressed whenemphasizedItemsis set), andsegmentLabelUtils.test.tsx(labels byte-identical to an ordinary interactive donut).vega-spec-builder-s2/react-spectrum-charts-s2test suite passes (131 suites, 2127 tests).yarn lintandyarn tsc --noEmitare clean (no new errors).emphasizedItemsis set; theBasicandMultistories render exactly matching the Figma reference (one or more segments in full color, the rest solid gray, all labels fully visible).Screenshots (if appropriate):
See the
BasicandMultistories underReact Spectrum Charts 2/Donut/Features/Emphasizein Storybook.Types of changes
Checklist: