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

refactor(cxl-tabs-slider): hide prev/next button on mobile #186

Open
paulkirspuu opened this issue Jan 14, 2022 · 4 comments
Open

refactor(cxl-tabs-slider): hide prev/next button on mobile #186

paulkirspuu opened this issue Jan 14, 2022 · 4 comments
Labels
enhancement New feature or request has-pr Has pull request

Comments

@paulkirspuu
Copy link

There should be a way to hide prev/next button on mobile.

image

@lkraav
Copy link

lkraav commented Jan 14, 2022

I would say "no", but there may be some opportunity to improve styling or something here.

It's clear from screenshot

  • non-centered content visual seems... weird
  • maybe the buttons don't need to be visible constantly, but only when.. um, tapping the testimonial, or.. not even sure what the best option for mobile would be - any popular sliders demos we could compare against and take notes?

cc @anoblet

@anoblet
Copy link
Collaborator

anoblet commented Jan 14, 2022

Hiding the arrows until the element is focused is easy, centering the content is going to be harder. Since this is a modified version of vaadin-tabs it's meant to accommodate items of various widths. I'm not sure modifying it further would be the best strategy, I would look into making something from scratch as they are relatively simple to create. Here's the code needed to hide the arrow:

ready() {
  super.ready();

  document.addEventListener('click', (event) => {
    let themes = this.getAttribute('theme').split(' ');

    if (this.contains(event.target)) {
      themes = themes.filter((item) => item !== 'hide-scroll-buttons');
    } else {
      if (!themes.includes('hide-scroll-buttons')) {
        themes.push('hide-scroll-buttons');
      }
    }

    this.setAttribute('theme', themes.join(' '));
  });
}

@anoblet
Copy link
Collaborator

anoblet commented Jan 14, 2022

Looking at this again, I don't believe it's a matter of centering, but rather the content is wider than the viewport.

We can snap/center content using scroll-snap-type: x mandatory on the tabs part, and use scroll-self-align: center on each vaadin-tab.

@anoblet
Copy link
Collaborator

anoblet commented Jan 14, 2022

Draft PR: #187
Demo: https://deploy-preview-187--conversionxl-aybolit.netlify.app/?path=/story/cxl-ui-cxl-tabs-slider--cxl-tabs-slider

Let me know if it's an improvement.

You will need to use dev tools and emulate mobile as it only responds to the touchstart event.

@lkraav lkraav added enhancement New feature or request has-pr Has pull request labels Mar 28, 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 has-pr Has pull request
Projects
None yet
Development

No branches or pull requests

3 participants