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

Control Slot Styling #35

Open
mpukit opened this issue Jul 23, 2019 · 5 comments
Open

Control Slot Styling #35

mpukit opened this issue Jul 23, 2019 · 5 comments

Comments

@mpukit
Copy link

mpukit commented Jul 23, 2019

Is there a way to add a class to the controls slot (or even a div inside around the buttons) to help with styling and positioning the Slider Controls?

Default control slot:

<template slot="control">
   <button data-glide-dir="<">prev</button>
   <button data-glide-dir=">">next</button>
</template>

Rendered in the browser:

<div data-glide-el="controls">
   <button data-v-4483513f="" data-glide-dir="<">prev</button>
   <button data-v-4483513f="" data-glide-dir=">">next</button>
</div>

How can I do this?

<div class="slider__nav" data-glide-el="controls">
   <div class="slider__buttons">
      <button data-v-4483513f="" data-glide-dir="<">prev</button>
      <button data-v-4483513f="" data-glide-dir=">">next</button>
   </div>
</div>
@mpukit
Copy link
Author

mpukit commented Jul 24, 2019

@antonreshetov if I manually add the <div class="slider__buttons"> inside the slider control - the controls no longer work...

<div data-glide-el="controls">
   <div class="slider__buttons">
      <button data-v-4483513f="" data-glide-dir="<">prev</button>
      <button data-v-4483513f="" data-glide-dir=">">next</button>
   </div>
</div>

Is there a better way to add classes to help with customizing the slider controls?

@matejtaborsky
Copy link

matejtaborsky commented Dec 13, 2019

you can use attribute selector in css

div[data-glide-el="controls"] {
  ...
}

@tyler-morales
Copy link

tyler-morales commented Sep 9, 2020

I've tried the solution @matejtaborsky has suggested to no avail. Has @mpukit, @matejtaborsky or @antonreshetov been able to style the controls as a whole yet?

As you can see in the following screenshots, the styling is not rendered in the browser.

I write the styles:

div[data-glide-el='controls'] {
  border: 2px solid blue !important;
}

I see the correct data attribute in the dev tools
Screen Shot 2020-09-08 at 11 52 59 PM

But then there is no styling is applied to the button container
Screen Shot 2020-09-09 at 12 11 34 AM

@blowski
Copy link

blowski commented Apr 2, 2021

I ran into this, and realised that it's easier to ignore the controls slot entirely, and do it manually instead. e.g.

<vue-glide v-model="active">
  <vue-glide-slide></vue-glide-slide>
  ...
</vue-glide>
<div><!-- this will fail if you do it in the slot -->
  <h1>Control the slider</h1>
  <div class="container">
    <button @click="active--">Previous</button>
    <button @click="active++">Next</button>
  </div>
</div>

@antonreshetov
Copy link
Owner

Since VueGlide is only a wrapper, it respects the behavior of the library itself. Control via arrows should be consistent with the documentation https://glidejs.com/docs/data-attributes.

But I will think about how to simplify the styling through the slot

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

No branches or pull requests

5 participants