aboutsummaryrefslogtreecommitdiff
path: root/src/components/SmartList/SmartList.js
diff options
context:
space:
mode:
authorEug-VS <eug-vs@keemail.me>2020-01-07 22:34:49 +0300
committerEug-VS <eug-vs@keemail.me>2020-01-07 22:34:49 +0300
commitd66419438a83e564583e1e8c28ed6c80d89f5648 (patch)
tree1b9c5a206f8b1e91f90600415fbe6bfffc62f05d /src/components/SmartList/SmartList.js
parent4931f205e1250c649b3a48b96a7823a9d52615ff (diff)
downloadchrono-cube-ui-d66419438a83e564583e1e8c28ed6c80d89f5648.tar.gz
Implement SmartList component, hide body overflow
Diffstat (limited to 'src/components/SmartList/SmartList.js')
-rw-r--r--src/components/SmartList/SmartList.js38
1 files changed, 38 insertions, 0 deletions
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 (
+ <FixedSizeList
+ height={height}
+ width={width}
+ itemSize={cellHeight}
+ itemCount={itemCount}
+ className={classes.root}
+ >
+ {renderItem}
+ </FixedSizeList>
+ );
+};
+
+
+export default SmartList;