Created
February 8, 2020 22:33
-
-
Save DZuz14/f94f591bd410163409f6e515267e6738 to your computer and use it in GitHub Desktop.
Slider with React Hooks 8
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' | |
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