Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Created February 8, 2020 22:34
Show Gist options
  • Save DZuz14/cafde5aabca4f60e92d2721b4cff4b59 to your computer and use it in GitHub Desktop.
Save DZuz14/cafde5aabca4f60e92d2721b4cff4b59 to your computer and use it in GitHub Desktop.
Slider with React Hooks 9
/** @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