Skip to content

Commit

Permalink
Started working on the fixed height/width and dynamic support for aut…
Browse files Browse the repository at this point in the history
…osizer
  • Loading branch information
underfisk committed Oct 15, 2020
1 parent 3f24f8d commit 881b49d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/gridContainer/GridContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import shallowDiffers from '../helpers/shallowDiffers'

const useStyles = makeStyles(() => ({
root: {
// height: '100%',
height: '100%',
width: '100%',
// overflowY: 'hidden',
// overflowX: 'hidden',
/** @todo Margin remove **/
Expand Down Expand Up @@ -140,6 +141,7 @@ export const GridContainer = React.memo(

function render(containerWidth: number, containerHeight = 400) {
const remainingWidth = buildColumnTotalWidth(containerWidth)
console.log({ containerWidth, containerHeight })
return (
<ColumnSizer
columnMinWidth={minColumnWidth}
Expand Down Expand Up @@ -190,9 +192,9 @@ export const GridContainer = React.memo(
}

return (
<div id="grid-container" className={classes.root} ref={gridContainerRef}>
<AutoSizer disableHeight>{({ width }) => render(width)}</AutoSizer>
</div>
<div id="grid-container" className={classes.root} ref={gridContainerRef}>
<AutoSizer disableHeight={true} defaultHeight={800}>{({ width, height }) => render(width, height)}</AutoSizer>
</div>
)
},
)
2 changes: 1 addition & 1 deletion src/gridWrapper/GridWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const GridWrapper = forwardRef((props: GridWrapperProps, componentRef: React.Ref
useEffect(() => {
cache.clearAll()
gridRef.current?.recomputeGridSize()
}, [props.data])
}, [props.data, props.width, props.height])

const onCellDoubleClick =
({ event, cell, columnIndex, rowIndex }: CellEventParams<React.MouseEvent<HTMLDivElement>>) => {
Expand Down
8 changes: 7 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const useStyles = makeStyles(() => ({
display: 'none',
},
},
apolloRoot: {
height: '100%',
width: '100%',
flex: 1,
display: 'flex'
},
bodyContainer: {
outline: 'none',
// 'scrollbar-width': 'none',
Expand Down Expand Up @@ -246,7 +252,7 @@ export const ApolloSpreadSheet = forwardRef(
// }, [props.outsideClickDeselects, focused])

return (
<div id="apollo-spreadhsheet" ref={rootRef} style={{ height: '100%', width: '100%'}}>
<div className={classes.apolloRoot} ref={rootRef}>
<GridContainer
headers={headers}
minColumnWidth={minColumnWidth}
Expand Down
6 changes: 3 additions & 3 deletions stories/Basic.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { storiesOf } from '@storybook/react'
import { ApolloSpreadSheet } from '../src'
import { Button, Checkbox, FormControl, InputLabel, MenuItem, Select } from '@material-ui/core'
import { Box, Button, Checkbox, FormControl, InputLabel, MenuItem, Select } from "@material-ui/core";
import { GridApi } from '../src/types/grid-api.type'
import { GridTheme } from '../src/types/grid-theme'
import { makeStyles } from '@material-ui/core/styles'
Expand Down Expand Up @@ -223,7 +223,7 @@ const MainTable = () => {
}

return (
<>
<Box height={"90vh"} width={"100%"} style={{ overflow: 'hidden'}}>
<Button variant="contained" color={'primary'} onClick={createRowOnBottom}>
Create row on bottom
</Button>
Expand Down Expand Up @@ -286,7 +286,7 @@ const MainTable = () => {
: undefined
}
/>
</>
</Box>
)
}
storiesOf('VirtualizedTable (DEMOS)', module)
Expand Down

0 comments on commit 881b49d

Please sign in to comment.