aboutsummaryrefslogtreecommitdiff
path: root/src/components/SmartList
diff options
context:
space:
mode:
authorEugene <eug-vs@keemail.me>2020-01-11 14:21:42 +0000
committerGitHub <noreply@github.com>2020-01-11 14:21:42 +0000
commite78ecf560a0c6f4cf59a3c4341884996464c7923 (patch)
tree0929172f24748ec041c861035e9c48e60e38bade /src/components/SmartList
parent2a501e2877ee82a9d2cad4c714083b1d190d2aa2 (diff)
parentecc6b5e6a2974502ed94cc33a70f388575bfa9ec (diff)
downloadchrono-cube-ui-e78ecf560a0c6f4cf59a3c4341884996464c7923.tar.gz
Merge pull request #32 from Eug-VS/window
Create Window component and refactor existing pages to use it
Diffstat (limited to 'src/components/SmartList')
-rw-r--r--src/components/SmartList/SmartList.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/components/SmartList/SmartList.js b/src/components/SmartList/SmartList.js
index 6cd774b..975cbbd 100644
--- a/src/components/SmartList/SmartList.js
+++ b/src/components/SmartList/SmartList.js
@@ -1,8 +1,9 @@
import React from 'react';
-import { FixedSizeList } from "react-window";
+import { FixedSizeList } from 'react-window';
+import AutoSizer from 'react-virtualized-auto-sizer';
-import { makeStyles } from "@material-ui/core";
+import { makeStyles } from '@material-ui/core';
const useStyles = makeStyles(theme => ({
@@ -12,25 +13,25 @@ const useStyles = makeStyles(theme => ({
}));
-const SmartList = ({ height, width, cellHeight, itemCount, renderItem }) => {
+const SmartList = ({ itemSize, 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>
+ <div style={{ flex: '1 1 auto'}}>
+ <AutoSizer>
+ {({ width, height }) => (
+ <FixedSizeList
+ height={height}
+ width={width}
+ itemSize={itemSize}
+ itemCount={itemCount}
+ className={classes.root}
+ >
+ {renderItem}
+ </FixedSizeList>
+ )}
+ </AutoSizer>
+ </div>
);
};