Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#246): Add onChange and initialSlideIndex props to CH.Slideshow #248

Merged
merged 6 commits into from
Jul 30, 2022

Conversation

brianespinosa
Copy link
Contributor

@brianespinosa brianespinosa commented Jul 29, 2022

Resolves #246

For the proposed use case, it is not enough to only initialize the Slideshow component with a starting slide. There also needed to be a way to expose the current slide so that someone could use that value to set in the current URL.

  • Adds an initialSlideIndex prop which allows initializing CH.Slideshow on a specific slide

    • Includes a new useInitialState hook which is used to make sure changing the initialSlideIndex after mount would not control the component
    • Includes a check to make sure the initial slide does not get set greater than the max slides in the MDX file
    • Includes MDX example of this prop in use
  • Adds an onChange function to the CH.Slideshow component which will get called every time the internal Slideshow state changes, and will return the internal state object

    • NOTE: If we wanted to only return the current slide and not the whole state object, I could make those changes to limit what we are exposing
    • NOTE: Since state changes do not happen from only one event, I did not think it made sense to also try to return different React synthetic events from the onChange in addition to the state data

Version

Published prerelease version: v0.7.3-next.2

Changelog

🐛 Bug Fix

⚠️ Pushed to next

  • Update bundle_analysis.yml (@pomber)

Authors: 2

@vercel
Copy link

vercel bot commented Jul 29, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
chtest ✅ Ready (Inspect) Visit Preview Jul 29, 2022 at 5:52PM (UTC)
playground ✅ Ready (Inspect) Visit Preview Jul 29, 2022 at 5:52PM (UTC)

@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 03:54 Inactive
@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 03:55 Inactive
@pomber
Copy link
Contributor

pomber commented Jul 29, 2022

Thanks a lot for the PRs @brianespinosa! I'll take a look later.

One small thing: can you disable the thing that reorders the props for future PRs? It makes the review harder.

@brianespinosa
Copy link
Contributor Author

One small thing: can you disable the thing that reorders the props for future PRs? It makes the review harder.

Sorry... that's actually me and my OCD sorting alphabetically by habit. I'll make sure not to do that on other PRs.

Is there a logical method you're using to sort these props and objects so I can follow that in the future?

@pomber
Copy link
Contributor

pomber commented Jul 29, 2022

Is there a logical method you're using to sort these props and objects so I can follow that in the future?

chaos

@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 16:30 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jul 29, 2022

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

This PR introduced no changes to the javascript bundle 🙌

@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 16:32 Inactive
@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 16:43 Inactive
@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 16:45 Inactive
@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 16:47 Inactive
@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 16:49 Inactive
…trolled-slide

# Conflicts:
#	packages/mdx/src/mdx-client/slideshow.tsx
@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 16:56 Inactive
Not needed in this scenario
@vercel vercel bot temporarily deployed to Preview – playground July 29, 2022 17:51 Inactive
@vercel vercel bot temporarily deployed to Preview – chtest July 29, 2022 17:53 Inactive
@brianespinosa brianespinosa requested a review from pomber July 29, 2022 18:03
@pomber pomber added patch release PR created automatically for new releases labels Jul 30, 2022
@pomber
Copy link
Contributor

pomber commented Jul 30, 2022

Looks good, thank you!

@pomber pomber merged commit a3a03dd into code-hike:next Jul 30, 2022
@brianespinosa brianespinosa deleted the controlled-slide branch July 30, 2022 20:41
This was referenced Aug 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2022

🚀 PR was released in v0.7.3 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release PR created automatically for new releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Allow CH.Slideshow to be initialized with a specific slide number
2 participants