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

Feature/carousel active slide #1214

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cristiantiradob
Copy link

Added 'activeSlide' prop with tests and docs. I considered the following facts:

  • Validate 'activeSlide' prop:
    If negative value, default slider item is set to '0'. If value is greater than carousel childs, default slider item is set to the last one. If no carousel childs, exit useEffect.

  • Default value:
    If no 'activeSlide' prop provided, default value is set to 0.

  • Update 'activeItem' State
    'activeItem' is set to 'activeSlide' when the component mounts.

Fixes #1094

…ider item

'activeSlide' prop is zero-based position. Default value is '0'. Negative values are converted to
'0'. If value is greater than number of items, default item will be the last one.

fix themesberg#1094
Covering negative value and value greater than slider items
Provided example with activeSlide prop
Copy link

vercel bot commented Jan 4, 2024

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2024 10:25pm

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7461173) 99.54% compared to head (70f7db3) 97.36%.
Report is 184 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1214      +/-   ##
==========================================
- Coverage   99.54%   97.36%   -2.18%     
==========================================
  Files         163      214      +51     
  Lines        6621     9085    +2464     
  Branches      401      532     +131     
==========================================
+ Hits         6591     8846    +2255     
- Misses         30      239     +209     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shippinglob
Copy link

Hi. I'm not one of the maintainer of this repository but thanks for implementing this very useful update. I went over the PR and It LGTM. Only a minor comment for :

navigateTo(validateActiveSlide)();

In the case of an invalid index, I prefer keeping the current active item as it makes debugging issues easier.

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.

Setting Active Image In the Slider
2 participants