Skip to content

feat(donut-s2): Emphasize - #897

Open
madelineluke wants to merge 2 commits into
feat/donut-hover-segment-fade-label-color-switchfrom
feat/donut-emphasize-segment-color-swap
Open

feat(donut-s2): Emphasize#897
madelineluke wants to merge 2 commits into
feat/donut-hover-segment-fade-label-color-switchfrom
feat/donut-emphasize-segment-color-swap

Conversation

@madelineluke

Copy link
Copy Markdown
Collaborator

Description

Implements the donut-emphasize spec: a static, design-time per-segment highlight, distinct from the mouse-driven donut-hover feature (#895) this is stacked on.

  • Adds 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.
  • Adds 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 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 state, and hover re-fading an already-gray sibling (or fading anything at all) fights that. Reuses the existing generic excludeCondition param on addHoveredItemSignal rather than inventing a new mechanism.
  • Adds Donut/Features/Emphasize stories: 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 Emphasize variant, independent of mouse position, that's distinct from (and not yet built alongside) the mouse-hover fade donut-hover implements. 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?

  • Unit tests added in donutUtils.test.ts (fill encoding for single/multiple emphasized items, custom otherItemColor, opacity rules untouched), donutSpecBuilder.test.ts (hover fully suppressed when emphasizedItems is set), and segmentLabelUtils.test.tsx (labels byte-identical to an ordinary interactive donut).
  • Full vega-spec-builder-s2/react-spectrum-charts-s2 test suite passes (131 suites, 2127 tests).
  • yarn lint and yarn tsc --noEmit are clean (no new errors).
  • Verified live in Storybook via Playwright, using precise on-pixel hover simulation: hovering either the emphasized segment or a grayed-out segment produces zero opacity change while emphasizedItems is set; the Basic and Multi stories 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 Basic and Multi stories under React Spectrum Charts 2/Donut/Features/Emphasize in Storybook.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@madelineluke
madelineluke force-pushed the feat/donut-emphasize-segment-color-swap branch from e414b92 to e50e85f Compare August 27, 2026 20:23
@madelineluke
madelineluke force-pushed the feat/donut-emphasize-segment-color-swap branch from e50e85f to 805b5c9 Compare August 27, 2026 20:55
@madelineluke
madelineluke force-pushed the feat/donut-emphasize-segment-color-swap branch from 805b5c9 to 6aa7a0e Compare August 27, 2026 21:31
…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
madelineluke force-pushed the feat/donut-emphasize-segment-color-swap branch from 6aa7a0e to 75c460f Compare August 27, 2026 21:43
@madelineluke madelineluke changed the title feat(donut-s2): static per-segment emphasize with a solid gray color swap feat(donut-s2): Emphasize Aug 27, 2026
…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.
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant