Skip to content

✨(front) add SmartScroller component#263

Open
NathanVss wants to merge 3 commits into
mainfrom
feat/horiz-scroller
Open

✨(front) add SmartScroller component#263
NathanVss wants to merge 3 commits into
mainfrom
feat/horiz-scroller

Conversation

@NathanVss

@NathanVss NathanVss commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Adds SmartScroller: a horizontally scrollable container that overlays an arrow on each edge where content overflows. Clicking scrolls the viewport by scrollRatio of its visible width (default 50%), smoothly.

CleanShot 2026-06-24 at 16 02 25

From

https://www.figma.com/design/hPwxE24MEaX3mBQ0KXNTSY/UI-kit?node-id=14537-7383&m=dev

Add a horizontally scrollable container that overlays an arrow button
on each edge where content is hidden by overflow. Clicking an arrow
scrolls the viewport by a configurable fraction of its visible width
(default 50%), smoothly. Arrows show only on the side(s) with hidden
content and are recomputed on scroll and on container/content resize.

The native scrollbar is hidden so the arrows are the primary
affordance, and a gradient fade hints at the partially-cut content. The
arrows are a pointer-only affordance: they are aria-hidden and out of
the tab order, since assistive-tech and keyboard users reach the
content directly.
Document the component with a Docs page and Overflowing, NoOverflow and
Resizable stories so the overflow/resize behaviour can be explored
interactively. The argTypes drive the Props table shown in the docs.
Cover the core behaviour with Playwright component tests: arrow
visibility per overflow side, the ~50% (and full-width) scroll amount,
recomputation on container resize, and the a11y contract that the
arrows stay hidden from assistive technology and the tab order.
@NathanVss NathanVss requested a review from PanchoutNathan June 24, 2026 14:15
Comment on lines +71 to +74
viewport.scrollBy({
left: direction * viewport.clientWidth * scrollRatio,
behavior: "smooth",
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrollBy hardcodes behavior: "smooth", which overrides the CSS scroll-behavior property (the CSS value is only consulted when behavior is "auto"). As a result the SCSS prefers-reduced-motion media query is ignored on arrow clicks — contradicting the docs, which claim it is respected. Dropping the behavior option makes the programmatic scroll follow the CSS (smooth by default, auto under reduced-motion).

Suggested change
viewport.scrollBy({
left: direction * viewport.clientWidth * scrollRatio,
behavior: "smooth",
});
viewport.scrollBy({
left: direction * viewport.clientWidth * scrollRatio,
});

Comment on lines +85 to +87
// Pointer-only affordance: assistive-tech and keyboard users reach
// the content directly (focusing a child scrolls it into view), so
// the arrows are hidden from the a11y tree and the tab order.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not very sur about this

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.

2 participants