Created
February 8, 2020 22:34
-
-
Save DZuz14/cafde5aabca4f60e92d2721b4cff4b59 to your computer and use it in GitHub Desktop.
Slider with React Hooks 9
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
/** @jsx jsx */ | |
import React from 'react' | |
import { css, jsx } from '@emotion/core' | |
const Dot = ({ active }) => ( | |
<span | |
css={css` | |
padding: 10px; | |
margin-right: 5px; | |
cursor: pointer; | |
border-radius: 50%; | |
background: ${active ? 'black' : 'white'}; | |
`} | |
/> | |
) | |
const Dots = ({ slides, activeIndex }) => ( | |
<div | |
css={css` | |
position: absolute; | |
bottom: 25px; | |
width: 100%; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
`} | |
> | |
{slides.map((slide, i) => ( | |
<Dot key={slide} active={activeIndex === i} /> | |
))} | |
</div> | |
) | |
export default Dots |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment