From d66419438a83e564583e1e8c28ed6c80d89f5648 Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Tue, 7 Jan 2020 22:34:49 +0300 Subject: Implement SmartList component, hide body overflow --- src/components/SmartList/SmartList.js | 38 +++++++++++++++++++++++++++++++++++ src/index.js | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/components/SmartList/SmartList.js (limited to 'src') diff --git a/src/components/SmartList/SmartList.js b/src/components/SmartList/SmartList.js new file mode 100644 index 0000000..6cd774b --- /dev/null +++ b/src/components/SmartList/SmartList.js @@ -0,0 +1,38 @@ +import React from 'react'; + +import { FixedSizeList } from "react-window"; + +import { makeStyles } from "@material-ui/core"; + + +const useStyles = makeStyles(theme => ({ + root: { + scrollbarColor: `${theme.palette.primary.dark} ${theme.palette.primary.light}`, + } +})); + + +const SmartList = ({ height, width, cellHeight, itemCount, renderItem }) => { + const classes = useStyles(); + + if (!height) { + const windowHeight = window.innerHeight; + const headerHeight = document.getElementsByClassName("MuiAppBar-root")[0].clientHeight; + height = windowHeight - headerHeight + } + + return ( + + {renderItem} + + ); +}; + + +export default SmartList; diff --git a/src/index.js b/src/index.js index 07c50bc..431e139 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,6 @@ import Scoreboard from "./components/Scoreboard/Scoreboard"; const useStyles = makeStyles(theme => ({ root: { - padding: theme.spacing(2), }, })); @@ -57,4 +56,5 @@ const App = () => { ); }; +document.body.style.overflow = "hidden"; ReactDOM.render(, document.getElementById('root')); -- cgit v1.2.3