Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Last active February 8, 2020 23:58
Show Gist options
  • Select an option

  • Save DZuz14/b2245ca9ac44c7c2cfdc0932549c22a3 to your computer and use it in GitHub Desktop.

Select an option

Save DZuz14/b2245ca9ac44c7c2cfdc0932549c22a3 to your computer and use it in GitHub Desktop.
Slider with React Hooks 4
/** @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