sky-swiper
A versatile slot-based Vue swiper component
Installation
npm install sky-swiper
or
yarn add sky-swiper
Usage
Begin by importing and installing the SkySwiper Vue plugin
;; // If you want to use the baseline scss add the following line; Vue;
The <SkySwiper />
component registers globally. It uses the items
prop in conjunction with slots to allow you to render any kind of data inside the swiper.
Basic markup
Just content:
<!-- Template for rendering an item here, ie: -->
Content and caption:
<!-- Template for rendering an item here, ie: --> <!-- Template for captions, ie: -->
Props
The component receives 4 props:
items
: An array (required). Functions as the data layer of the swiper. The array can contain whichever kind of items you need since the content-slot functions as a template for rendering the data as well.controls
: Configure UI-elements to show inside the swiper content<SkySwiper :controls="{// show/hide next button on top of swiper contentnext: true || false,// show/hide previous button on top of swiper contentprevious: true || false,// show/hide custom cursor control on top of swiper contentcursor: true || false,}">navigation
: Configure UI-elements to display outside the swiper content<SkySwiper :navigation="{// The navigation element can either appear above the figcaption ('before-caption') or below ('after-caption')location: 'before-caption' || 'after-caption',// 'none': show no indicators, 'pagination': show slide number (eg. "2/10"), 'bullets': show list of clickable bulletsindicator: 'none' || 'pagination' || 'bullets',// show/hide next button in navigationnext: true || false,// show/hide previous button in navigationprevious: true || false,}">
Slots
The component provides these basic slots:
"content"
- Required.. Uses data from the items prop. Scoped slot with these bindings:{ item, index }
"caption"
- Uses data from the items prop. Scoped slot with these bindings:{ item, index }
Apart fron these there are more advanced slots for customizing the look in detail (more documentation needed):
"cursor"
- Custom cursor icon. Scoped slot with these bindings:{ direction, active, pressed }
"controls-next"
- Custom next icon"controls-previous"
- Custom previous icon"navigation-next"
- Custom next icon (in the navigation)"navigation-previous"
- Custom previous icon (in the navigation)"bullets"
- Custom icon of the bullets in the navigation. Scoped slot with these bindings:{ active, index }
Example
This basic concept can be expanded upon by using all available slots and configuration props to completely customize the swiper.
Credits
This module is made by the front-end team at Skybrud.dk. Feel free to use it in any way you want. Feedback, questions and bug reports should be posted as issues. Pull-requests appreciated!