coffeekraken-s-swiper-component v1.0.2
Coffeekraken s-swiper-component
Table of content
- Demo
- Install
- Get Started
- Javascript API
- SASS API
- Sugar Web Components Documentation
- Browsers support
- Code linting
- Contribute
- Who are Coffeekraken?
- 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 colors-swiper[color="primary"]
: primary colors-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 | Firefox | Chrome | 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:
- ESLint with airbnb and prettier rules for javascript files
- 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:
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...