[D]DLS-702-feature(ui-react-visualization): Add Scrubber component#680
[D]DLS-702-feature(ui-react-visualization): Add Scrubber component#680
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds an interactive “Scrubber” feature to ui-react-visualization charts, enabling hover/touch/keyboard-driven selection of an x-position and rendering corresponding chart overlays (line/label/beacons).
Changes:
- Introduce
Scrubbercomponent + provider/context for pointer/touch/keyboard interactions. - Wire scrubbing support through
CartesianChartandLineChartpublic APIs. - Add unit tests and Storybook stories for scrubber behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/ui-react-visualization/src/lib/utils/scales/scales.ts | Adds a helper to map a single x value to pixel space (incl. band centering). |
| libs/ui-react-visualization/src/lib/Components/Scrubber/utils.ts | Adds pixel→data-index resolution for different x-scale modes. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/utils.test.ts | Tests for pixel→index mapping across band/linear + axis-data cases. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/types.ts | Defines scrubber props/context/provider types. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/ScrubberProvider.tsx | Attaches SVG event listeners and manages scrubber position state. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/ScrubberProvider.test.tsx | Integration-style tests for provider interactions (mouse/keys/focus). |
| libs/ui-react-visualization/src/lib/Components/Scrubber/Scrubber.tsx | Renders scrubber visuals (line, overlay, label, beacons). |
| libs/ui-react-visualization/src/lib/Components/Scrubber/Scrubber.test.tsx | Tests scrubber rendering toggles and basic positioning. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/Scrubber.stories.tsx | Storybook coverage for scrubber usage scenarios. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/index.ts | Public exports for scrubber module. |
| libs/ui-react-visualization/src/lib/Components/Scrubber/context/* | Safe context + hook for scrubber state. |
| libs/ui-react-visualization/src/lib/Components/LineChart/types.ts | Adds enableScrubbing + onScrubberPositionChange to LineChart API. |
| libs/ui-react-visualization/src/lib/Components/LineChart/LineChart.tsx | Passes scrubbing props through to CartesianChart. |
| libs/ui-react-visualization/src/lib/Components/LineChart/LineChart.stories.tsx | Adds a “real-time” scrubbing demo story. |
| libs/ui-react-visualization/src/lib/Components/index.ts | Re-exports scrubber from components barrel. |
| libs/ui-react-visualization/src/lib/Components/CartesianChart/types.ts | Adds scrubbing props to CartesianChart API. |
| libs/ui-react-visualization/src/lib/Components/CartesianChart/CartesianChart.tsx | Mounts ScrubberProvider, makes SVG focusable when enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const maxIndex = dataLength - 1; | ||
| const current = scrubberPosition ?? maxIndex; | ||
| const step = event.shiftKey | ||
| ? Math.min(10, Math.max(1, Math.floor(maxIndex * 0.1))) | ||
| : 1; |
| const contextValue: ScrubberContextValue = useMemo( | ||
| () => ({ | ||
| enableScrubbing, | ||
| scrubberPosition, | ||
| onScrubberPositionChange: setScrubberPosition, | ||
| }), |
| style={{ | ||
| display: 'block', | ||
| overflow: 'visible', | ||
| outline: enableScrubbing ? 'none' : undefined, |
…ent opacity; refactor Scrubber stories and tests
ba93481 to
1564a21
Compare
|
| style={{ | ||
| stroke: cssVar('var(--border-muted-subtle)'), | ||
| opacity: 0.5, | ||
| }} |
There was a problem hiding this comment.
so we do not have a token for this one ? looks like border-muted-subtle on figma, why do we need the reduce opacity ?
There was a problem hiding this comment.
the exact token needed for this was border-muted-subtle-transparent, but when I tried to add it, the token wasn't recognized, so Laurine told me it was just border-muted-subtle with a 50% opacity




Overview
Introduce Scrubber component with keyboard controls, and plug it to CartesianChart.
