Created
October 9, 2017 16:22
-
-
Save VinSpee/090fa35bf875804a9e932394ac6e0001 to your computer and use it in GitHub Desktop.
Flywheel: A react carousel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default MyCarousel = ({ myItems }) => ( | |
<Flywheel> | |
{ | |
({ | |
activeItemIndex, | |
getNextButtonProps, | |
getPrevButtonProps, | |
}) => ( | |
<div> | |
<button | |
{...getPrevButtonProps({ | |
onClick: () => console.log('prev clicked'), | |
})} | |
> | |
Prev | |
</button> | |
{myItems.map({ id, imageURL }, index) => ( | |
<FlywheelItem key={id}> | |
{ | |
({ | |
getItemProps, | |
}) => ( | |
<div | |
{...getItemProps({ | |
key: id, | |
style: { | |
borderTop: `1px solid ${index === activeItemIndex ? 'red' | |
: 'transparent'}, | |
}, | |
onClick: () => console.log(`${id} clicked`) | |
})} | |
> | |
<img src={imageURL} /> | |
</div> | |
) | |
} | |
</FlywheelItem> | |
)} | |
<button | |
{...getNextButtonProps({ | |
onClick: () => console.log('next clicked'), | |
})} | |
> | |
Next | |
</button> | |
</div> | |
) | |
} | |
</Flywheel> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment