Last active
February 8, 2020 23:58
-
-
Save DZuz14/b2245ca9ac44c7c2cfdc0932549c22a3 to your computer and use it in GitHub Desktop.
Slider with React Hooks 4
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, { useState } from 'react' | |
| import { css, jsx } from '@emotion/core' | |
| import SliderContent from './SliderContent' | |
| /** | |
| * @function Slider | |
| */ | |
| const Slider = () => { | |
| const getWidth = () => window.innerWidth | |
| const [state, setState] = useState({ | |
| translate: 0, | |
| transition: 0.45 | |
| }) | |
| const { translate, transition } = state | |
| return ( | |
| <div css={SliderCSS}> | |
| <SliderContent | |
| translate={translate} | |
| transition={transition} | |
| width={getWidth()} | |
| > | |
| {/* */} | |
| </SliderContent> | |
| </div> | |
| ) | |
| } | |
| const SliderCSS = css` | |
| position: relative; | |
| height: 100vh; | |
| width: 100vw; | |
| margin: 0 auto; | |
| overflow: hidden; | |
| ` | |
| export default Slider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment