vue-glide icon indicating copy to clipboard operation
vue-glide copied to clipboard

Control Slot Styling

Open mpukit opened this issue 5 years ago • 5 comments

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 avatar Jul 23 '19 15:07 mpukit

@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?

mpukit avatar Jul 24 '19 17:07 mpukit

you can use attribute selector in css

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

matejtaborsky avatar Dec 13 '19 14:12 matejtaborsky

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

tyler-morales avatar Sep 09 '20 04:09 tyler-morales

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>

blowski avatar Apr 02 '21 20:04 blowski

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

antonreshetov avatar Apr 03 '21 04:04 antonreshetov