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(component): new pauseOnHover prop to <Carousel>, provide quick information with chance to pause #918

Merged
merged 1 commit into from
Aug 22, 2023
Merged

Conversation

Pewaukee
Copy link
Contributor

Summarize the changes made and the motivation behind them.

A new property on the component, pauseOnHover, will improve accessibility, allow for a faster flow of information, and help users find desired information quicker. From the Web Accessibility Initiative in "What makes a carousel accessible?", they note: "Users must be able to pause carousel movement because it can be too fast or distracting, making text hard to read." (www.w3.org/WAI/tutorials/carousels/) Currently, there is no built in feature to accomplish this. Developers will either have to disable the slide property, or make the slideInterval property very long to allow users to read necessary information. With the pauseOnHover property, users will have a quick way, both on mobile and desktop, to pause on the desired slide. Furthermore, this allows developers to display more information at a faster pace to users because users have a choice at which slide to stop and read, but can still have a general understanding of information displayed on other slides.

For changes in code, added an additional parameter to <Carousel> and an additional state variable isHovering to check if the user is hovering on the root component. Also defined a few additional callback functions to use on the parent <div>. Works on desktop by hovering, works on mobile by touching and pressing.
2023-08-18 13-01-53

Reference related issues using # followed by the issue number.

#902

If there are breaking API changes - like adding or removing props, or changing the structure of the theme - describe them, and provide steps to update existing code.

@vercel
Copy link

vercel bot commented Aug 18, 2023

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 Aug 22, 2023 7:46am

@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Patch coverage: 99.85% and project coverage change: -0.01% ⚠️

Comparison is base (7461173) 99.54% compared to head (a4d8e41) 99.53%.
Report is 51 commits behind head on main.

❗ Current head a4d8e41 differs from pull request most recent head 0c927b4. Consider uploading reports for the commit 0c927b4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #918      +/-   ##
==========================================
- Coverage   99.54%   99.53%   -0.01%     
==========================================
  Files         163      167       +4     
  Lines        6621     6918     +297     
  Branches      401      417      +16     
==========================================
+ Hits         6591     6886     +295     
- Misses         30       32       +2     
Files Changed Coverage Δ
src/components/Toast/theme.ts 100.00% <ø> (ø)
src/components/Dropdown/Dropdown.tsx 99.24% <99.43%> (-0.76%) ⬇️
src/components/Badge/Badge.tsx 100.00% <100.00%> (ø)
src/components/Button/Button.tsx 100.00% <100.00%> (ø)
src/components/Button/ButtonBase.tsx 100.00% <100.00%> (ø)
src/components/Button/theme.ts 100.00% <100.00%> (ø)
src/components/Card/Card.tsx 100.00% <100.00%> (ø)
src/components/Carousel/Carousel.tsx 99.09% <100.00%> (+0.12%) ⬆️
src/components/DarkThemeToggle/DarkThemeToggle.tsx 100.00% <100.00%> (ø)
src/components/Dropdown/DropdownItem.tsx 100.00% <100.00%> (ø)
... and 18 more

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

@tulup-conner
Copy link
Collaborator

Hey, thank you for submitting this, I love the idea, as someone who is personally quite frustrated with carousels in general in component libraries, lol. I don't have time to get to this right now but I wanted to let you know we see your contribution! I'll ask @rluders if he has an opportunity but I know he is about to give me some feedback on his PR to add Datepicker.

…nformation with chance to pause

A new property on the <Carousel> component, `pauseOnHover`, will improve accessibility, allow for a
faster flow of information, and help users find desired information quicker. From the Web
Accessibility Initiative in "What makes a carousel accessible?", they note: "Users must be able to
pause carousel movement because it can be too fast or distracting, making text hard to read."
(www.w3.org/WAI/tutorials/carousels/) Currently, there is no built in feature to accomplish this.
Developers will either have to disable the `slide` property, or make the `slideInterval` property
very long to allow users to read necessary information. With the `pauseOnHover` property, users will
have a quick way, both on mobile and desktop, to pause on the desired slide. Furthermore, this
allows developers to display more information at a faster pace to users because users have a choice
at which slide to stop and read, but can still have a general understanding of information displayed
on other slides.
Copy link
Collaborator

@rluders rluders left a comment

Choose a reason for hiding this comment

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

Well, in fact, this is a very cool feature and it works as expected. It lacks unit tests, but TBH I have no idea how we could test it, and its implementation looks very simple, so I'll not consider this a blocker.

Thank you @Pewaukee for your contribution.

@rluders rluders merged commit f69e1a4 into themesberg:main Aug 22, 2023
@Pewaukee Pewaukee deleted the feat/carousel-hoverpause branch August 23, 2023 02:18
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.

3 participants