fix(Carousel): auto-mirror viewport padding to scroll-padding#201
Conversation
|
commit: |
|
Hey @J-Sek — thanks for digging into #200. After some back-and-forth on the approach, I'd like to pivot this PR to an auto-mirror pattern instead of a new prop. Reasoning + the new code below. Why drop the
|
Replace the previously-proposed `padding` prop on Carousel.Root with an
internal auto-mirror in CarouselViewport: on resize, read the viewport's
computed padding-{inline,block}-{start,end} via getComputedStyle and
apply matching scroll-padding on the viewport's inline style so CSS
scroll-snap targets align with the visible offset.
Consumers write padding any way they want (UnoCSS class, inline style,
stylesheet, CSS vars) and snap math stays correct without a dedicated
prop. This preserves v0's headless contract — PHILOSOPHY §2.1 — by not
adding a visual-styling prop to a Root component.
Closes #200.
I am OK with mirror. Not something that I am used to, but feels like just fine for v0. |
useResizeObserver already gates on SUPPORTS_OBSERVER and isHydrated, and the sync callback bails on a null element, so the outer IN_BROWSER block was never load-bearing.
padding prop and pass it to scroll-padding|
Verified 👍🏼 I cannot approve, because GitHub thinks I am an author. Feel free to merge |
fixes #200
Note: lmk if we should add
convertToUnitat this pointPlayground