Download discord-react-clone/src/components/ScrollableArea.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/discord-react-clone/src/components/ScrollableArea.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/discord-react-clone/src/components/ScrollableArea.js
-
curl -L -o ScrollableArea.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/discord-react-clone/src/components/ScrollableArea.js
1.02 kB
| import React from 'react'; | |
| import styled from 'styled-components'; | |
| // The parent of ScrollableArea should have "position" set to "relative" | |
| // otherwise the scrollable area will overflow the content | |
| const StyledScrollableArea = styled.div` | |
| position: absolute; | |
| top: 0; | |
| bottom: 0; | |
| left: 0; | |
| right: 0; | |
| display: flex; | |
| flex-direction: column; | |
| .scroller { | |
| flex: 1 1 auto; | |
| overflow-y: auto; | |
| flex-grow: 1; | |
| /* Firefox fix */ | |
| min-height: 0; | |
| } | |
| .scroller.force-vertical { | |
| overflow-y: scroll; | |
| } | |
| `; | |
| const ScrollableArea = ({ children, forceVertical, tinyStyle, autoHide, invisible }) => ( | |
| <StyledScrollableArea> | |
| <div | |
| className={[ | |
| 'scroller', | |
| forceVertical && 'force-vertical', | |
| !tinyStyle && 'scrollbar-default', | |
| tinyStyle && 'scrollbar-tiny', | |
| autoHide && 'scrollbar-autoHide', | |
| invisible && 'scrollbar-invisible' | |
| ].join(' ')} | |
| > | |
| {children} | |
| </div> | |
| </StyledScrollableArea> | |
| ); | |
| export default ScrollableArea; | |