Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Created February 8, 2020 22:33
Show Gist options
  • Save DZuz14/f94f591bd410163409f6e515267e6738 to your computer and use it in GitHub Desktop.
Save DZuz14/f94f591bd410163409f6e515267e6738 to your computer and use it in GitHub Desktop.
Slider with React Hooks 8
/** @jsx jsx */
import React from 'react'
import { css, jsx } from '@emotion/core'
import leftArrow from '../img/left-arrow.svg'
import rightArrow from '../img/right-arrow.svg'
const Arrow = ({ direction, handleClick }) => (
<div
onClick={handleClick}
css={css`
display: flex;
position: absolute;
top: 50%;
${direction === 'right' ? `right: 25px` : `left: 25px`};
height: 50px;
width: 50px;
justify-content: center;
background: white;
border-radius: 50%;
cursor: pointer;
align-items: center;
transition: transform ease-in 0.1s;
&:hover {
transform: scale(1.1);
}
img {
transform: translateX(${direction === 'left' ? '-2' : '2'}px);
&:focus {
outline: 0;
}
}
`}
>
{direction === 'right' ? <img src={rightArrow} /> : <img src={leftArrow} />}
</div>
)
export default Arrow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment