-
-
Couldn't load subscription status.
- Fork 476
feat(carousel): automatic hiding of navigation buttons when the first… #1207
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
Open
cristiantiradob
wants to merge
4
commits into
themesberg:main
Choose a base branch
from
cristiantiradob:feature/carousel-control-hiding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+93
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0b23412
feat(carousel): automatic hiding of navigation buttons when the first…
cristiantiradob 6bef5df
fix(carousel): added hidden and block classes
cristiantiradob cac7084
docs(carousel): added autoHideControls to docs
cristiantiradob 5354f6b
style(carousel): ran prettier
cristiantiradob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { type CodeData } from '~/components/code-demo'; | ||
| import { Carousel } from '~/src'; | ||
|
|
||
| const code = ` | ||
| 'use client'; | ||
|
|
||
| import { Carousel } from 'flowbite-react'; | ||
|
|
||
| function Component() { | ||
| return ( | ||
| <div className="h-56 sm:h-64 xl:h-80 2xl:h-96"> | ||
| <Carousel autoHideControls slide={false}> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-1.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-2.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-3.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-4.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-5.svg" alt="..." /> | ||
| </Carousel> | ||
| </div> | ||
| ); | ||
| } | ||
| `; | ||
|
|
||
| const codeRSC = ` | ||
| import { Carousel } from 'flowbite-react'; | ||
|
|
||
| function Component() { | ||
| return ( | ||
| <div className="h-56 sm:h-64 xl:h-80 2xl:h-96"> | ||
| <Carousel autoHideControls slide={false}> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-1.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-2.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-3.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-4.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-5.svg" alt="..." /> | ||
| </Carousel> | ||
| </div> | ||
| ); | ||
| } | ||
| `; | ||
|
|
||
| function Component() { | ||
| return ( | ||
| <div className="h-56 sm:h-64 xl:h-80 2xl:h-96"> | ||
| <Carousel autoHideControls slide={false}> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-1.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-2.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-3.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-4.svg" alt="..." /> | ||
| <img src="https://flowbite.com/docs/images/carousel/carousel-5.svg" alt="..." /> | ||
| </Carousel> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export const autoHideControls: CodeData = { | ||
| type: 'single', | ||
| code: [ | ||
| { | ||
| fileName: 'client', | ||
| language: 'tsx', | ||
| code, | ||
| }, | ||
| { | ||
| fileName: 'server', | ||
| language: 'tsx', | ||
| code: codeRSC, | ||
| }, | ||
| ], | ||
| githubSlug: 'carousel/carousel.autoHideControls.tsx', | ||
| component: <Component />, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
Would opacity be the best approach in this case? W/opacity the controls will remain available to user interactions on the dom, while display:none would prevent interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, yes, that's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello. If with controls remaining available you mean that the user will go from last image to first image even with control hided, in my tests when control hides click has no effect. In this video you will see a circle in the pointer when I click:
Grabacion.de.pantalla.2024-01-01.a.la.s.1.30.21.p.m.mov
Please correct me if I misunderstood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still change this to
display:nonebecause this may come up as still clickable for users navigating with Tab.I can't confirm that since you didn't add an example to the docs, which, if you could, would be great.
With that said, I'm still not sure if we can merge this because this is a UX feature that isn't available in the vanilla library at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Thanks for your feedback I will implement this in my forked repo. Please let me know if you'd like this feature here so I can update the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that if the navigation button/icon disappears from the DOM, when the user spam clicks next (or prev) until he gets to the last, if in the future we'll implement click-to-fullscreen (or similar), then this behaviour would be very unpredictable.
So the case study is, the next/prev icons are wrapped in a
buttonelement in order to be focusable/accessible and the button becomesdisabled=truewhen is last or first page, according to the direction, this way tabbing is not possible (CC @tulup-conner ) and also clicking the disabled button should stop event propagation.#just_thoughts 🤔