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

[Component] Carousel #4

Open
zetareticoli opened this issue Sep 1, 2021 · 7 comments
Open

[Component] Carousel #4

zetareticoli opened this issue Sep 1, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@zetareticoli
Copy link
Owner

Create the Carousel component using scroll-snap CSS feature.

@zetareticoli zetareticoli added the enhancement New feature or request label Sep 1, 2021
@zetareticoli zetareticoli self-assigned this Sep 1, 2021
@zetareticoli zetareticoli added this to the Public release milestone Sep 1, 2021
@zetareticoli zetareticoli modified the milestones: Public release, Next Sep 16, 2021
@zetareticoli
Copy link
Owner Author

Consider this example https://codepen.io/t_afif/pen/NWvQewg

@zetareticoli
Copy link
Owner Author

I worked on a basic component structure and style.

Here you can find a preview: https://codepen.io/zetareticoli/pen/oNGVyOz?editors=1100

@omaxel What do you think with the result?

@zetareticoli
Copy link
Owner Author

zetareticoli commented Feb 10, 2022

I've made some changes to the component:

  • Added PREV/NEXT arrows
  • Fixed padding bug

See the preview: https://codepen.io/zetareticoli/pen/oNGVyOz

I'll explore more the dots nav, making it with <input type="radio"> to simulate the checked state

@omaxel feedback welcome 🙏

@omaxel
Copy link
Collaborator

omaxel commented Feb 12, 2022

Great job @zetareticoli!

Here are my questions and comments on the implementation:

  1. Is there a particular reason for which you used :before and :after pseudo-selectors on [data-carousel] to display the previous and next button's icons? Couldn't we do the same styling the buttons using [data-slide-arrow]? A problem with the current approach is the clickable area: since :before and :after are rotated, the clickable area is different compared to the actual button. This makes it possible to implement the third point of this list too.
  2. I know you are exploring more on dots nav, but I noticed that when I'm on the third slide, the first and the third dots nav are white, while the second and the fourth are black.
  3. On Windows, the dots are displayed above the bottom horizontal scroll-bar. Also, I'm not sure it should have position: fixed, I would expect it to have position: absolute instead. This would allow the dots to be positioned relative to the carousel instead of the root document element.
  4. On the latest and first slides, I would enforce the feedback on the disabled arrow button. As of now, they are styled like a normal state button.
  5. [data-slides] elements have scroll-snap-padding applied. The correct property name should be scroll-padding. I tried fixing the property name and it breaks the carousel scroll.

I hope you find them useful. Thanks a lot!

@zetareticoli
Copy link
Owner Author

Great job @zetareticoli!

Here are my questions and comments on the implementation:

  1. Is there a particular reason for which you used :before and :after pseudo-selectors on [data-carousel] to display the previous and next button's icons? Couldn't we do the same styling the buttons using [data-slide-arrow]? A problem with the current approach is the clickable area: since :before and :after are rotated, the clickable area is different compared to the actual button. This makes it possible to implement the third point of this list too.

Yes, the reason is that using the pseudo-elements on [data-slide-arrow] they got repeated for each slide.
The downside is the effect you highlighted at point 4 (no visual feedback on first/last slide).

  1. I know you are exploring more on dots nav, but I noticed that when I'm on the third slide, the first and the third dots nav are white, while the second and the fourth are black.

At the moment, I added the active style using :target pseudo-class. Don't know how to deal it without (scrolling and first element active by default. Any suggestions?

  1. On Windows, the dots are displayed above the bottom horizontal scroll-bar. Also, I'm not sure it should have position: fixed, I would expect it to have position: absolute instead. This would allow the dots to be positioned relative to the carousel instead of the root document element.

This is just a workaround because using absolute generates a bug where the dots appear in the first slide only. Need to investigate more...

@argyleink
Copy link

here's some more inspo https://css-tricks.com/css-only-carousel/

@zetareticoli zetareticoli changed the title Add Carousel component [Component] Carousel Feb 16, 2022
@zetareticoli
Copy link
Owner Author

Worked on another demo: https://codepen.io/zetareticoli/pen/bGYKOQR?editors=1100

It's total different approach, using radio buttons to manage sliding effect and indicators. Thus, it isn't touch sensitive for mobile devices 🤔

@zetareticoli zetareticoli removed this from the Road to v1.0 milestone Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants