Need private packages and team management tools?Check out npm Teams »

coffeekraken-s-swiper-component

1.0.2 • Public • Published

Coffeekraken s-swiper-component

Webcomponent wrapper around the freaking cool [Swiper](http://idangero.us/swiper/) library

View demo

Table of content

  1. Demo
  2. Install
  3. Get Started
  4. Javascript API
  5. SASS API
  6. Sugar Web Components Documentation
  7. Browsers support
  8. Code linting
  9. Contribute
  10. Who are Coffeekraken?
  11. Licence

Install

npm install coffeekraken-s-swiper-component --save

Get Started

First, import the component into your javascript file like so:

import SSwiperComponent from "coffeekraken-s-swiper-component"

Then simply use it inside your html like so:

<s-swiper>
  <div s-swiper-swiper>
    <div s-swiper-slide>
      <img src="https://source.unsplash.com/random/1280x720?bust=1" />
    </div>
    <div s-swiper-slide>
      <img src="https://source.unsplash.com/random/1280x720?bust=2" />
    </div>
    <div s-swiper-slide>
      <img src="https://source.unsplash.com/random/1280x720?bust=3" />
    </div>
    <div s-swiper-slide>
      <img src="https://source.unsplash.com/random/1280x720?bust=4" />
    </div>
  </div>
  <ul s-swiper-pagination>
    <!-- filled by swiper -->
  </ul>
  <div s-swiper-next></div>
  <!-- skin this as you want... -->
  <div s-swiper-previous></div>
  <!-- skin this as you want... -->
</s-swiper>

Generate the styles for the pagination if wanted like so:

@import "node_modules/coffeekraken-s-swiper-component/index";
@include s-swiper-classes($colors: default primary secondary);

This will gives you access to classes:

  • s-swiper: default color
  • s-swiper[color="primary"]: primary color
  • s-swiper[color="secondary"]: secondary color

This use the sugar colors system

Properties (options)

This webcomponent support every options that Swiper has to offer. You can set them using the html attributes or by using the setDefaultProps like so:

Using attributes

<s-swiper autoplay="{delay:4000}" speed="500" space-between="50">
  <!-- your swiper here... -->
</s-swiper>

Using setDefaultProps

import SWebComponent from "coffeekraken-sugar/js/core/SWebComponent"
SWebComponent.setDefaultProps(
  {
    autoplay: {
      delay: 4000
    },
    speed: 500,
    spaceBetween: 50
  },
  "s-swiper"
)

Supported modules

To keep the package size as small as possible, the webcomponent does not load all the Swiper modules. Here's the ones that are loaded and we think this is more than enough:

  • Swiper
  • Navigation
  • Pagination
  • Keyboard
  • Mousewheel
  • A11y
  • Autoplay
  • History
  • HashNavigation

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
IE11+ last 2 versions last 2 versions last 2 versions

As browsers are automatically updated, we will keep as reference the last two versions of each but this component can work on older ones as well.

The webcomponent API (custom elements, shadowDOM, etc...) is not supported in some older browsers like IE10, etc... In order to make them work, you will need to integrate the corresponding polyfill.

Code linting

This package uses some code linting rules. Here's the list:

  1. ESLint with airbnb and prettier rules for javascript files
  2. Stylelint with stylelint-config-standard for scss files

Your commits will not been accepted if the code style is not respected!

Contribute

This is an open source project and will ever be! You are more that welcomed to contribute to his development and make it more awesome every day. To do so, you have several possibilities:

  1. Share the love ❤️
  2. Declare issues
  3. Fix issues
  4. Add features
  5. Build web component

Who are Coffeekraken

We try to be some cool guys that build some cool tools to make our (and yours hopefully) every day life better.

More on who we are

License

The code is available under the MIT license. This mean that you can use, modify, or do whatever you want with it. This mean also that it is shipped to you for free, so don't be a hater and if you find some issues, etc... feel free to contribute instead of sharing your frustrations on social networks like an asshole...

Install

npm i coffeekraken-s-swiper-component

DownloadsWeekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

1.39 MB

Total Files

32

Last publish

Collaborators

  • avatar