Skip to content

Instantly share code, notes, and snippets.

@searleb
Created September 4, 2017 00:52
Show Gist options
  • Save searleb/fa8175ccd370689b97b789a24dedaaaf to your computer and use it in GitHub Desktop.
Save searleb/fa8175ccd370689b97b789a24dedaaaf to your computer and use it in GitHub Desktop.
React ScrollPane
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
const Scroll = styled.div`
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
height: ${props => props.reduceHeight ? `calc(100% - ${props.reduceHeight})` : '100%'};
width: 100%;
&::-webkit-scrollbar {
display: none;
}
`
const ScrollPane = ({ children, reduceHeight }) => (
<Scroll reduceHeight={reduceHeight}>
{children}
</Scroll>
)
ScrollPane.propTypes = {
children: PropTypes.node.isRequired,
reduceHeight: PropTypes.string.isRequired,
}
export default ScrollPane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment