Skip to content

Instantly share code, notes, and snippets.

@ademilter
Last active February 13, 2020 11:47
Show Gist options
  • Save ademilter/0e9be28fde5cb451ed606437f2db062d to your computer and use it in GitHub Desktop.
Save ademilter/0e9be28fde5cb451ed606437f2db062d to your computer and use it in GitHub Desktop.
use flickity with gastby
{
"dependencies": {
"flickity": "^2.2.1"
"react-flickity-component": "^3.5.0"
}
}
import React from 'react'
import 'flickity/dist/flickity.css'
const Slider = ({ children, options, ...props }) => {
const Flickity =
typeof window !== 'undefined'
? require('react-flickity-component')
: () => null
return (
Flickity && (
<Flickity options={options} {...props}>
{children}
</Flickity>
)
)
}
Slider.defaultProps = {
options: {
pageDots: false,
prevNextButtons: false,
cellAlign: 'left',
contain: true,
selectedAttraction: 0.2,
friction: 0.8
}
}
export default Slider
@ademilter
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment