huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://shadcn-svelte.com
MIT License
4.13k stars 259 forks source link

feat: expose `scrollSnaps` `selectedIndex` `scrollTo` #1052

Closed shyakadavis closed 1 month ago

shyakadavis commented 1 month ago

Had briefly touched on this is in the server, bringing it here for your consideration;

This P.R lays the groundwork necessary to create a dots-scroll-to feature like in the video. From now on, one need only reach into the context and grab these stores+function and style however they wish.

const { scrollTo, scrollSnaps, selectedIndex } = getEmblaContext('<Carousel.Dots/>');

It's pretty easy to set up yourself, but having it come with the carousel component saves some time. 🙂 (And I don't think this introduction violates/deviates from the original, wouldn't you agree? - at least components-wise)


https://github.com/huntabyte/shadcn-svelte/assets/87414827/bc054fdc-503d-4e57-9801-0628366cdbc0

Before submitting the PR, please make sure you do the following

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 6bb1da7ac42d7026780265863886b6ef31c6687c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

github-actions[bot] commented 1 month ago
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
shadcn-svelte ✅ Ready (View Log) Visit Preview 6bb1da7ac42d7026780265863886b6ef31c6687c