Skip to content

Rwg add row column header #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"bundled": 5241,
"minified": 5198,
"gzipped": 2290
},
"dist\\react-window-grid.min.js": {
"bundled": 5330,
"minified": 5287,
"gzipped": 2304
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@andrglo/react-window-grid",
"version": "0.1.18",
"version": "0.1.19",
"description": "A react grid with synced column and row headers",
"repository": "https://github.com/andrglo/react-window-grid.git",
"main": "src",
Expand Down
17 changes: 16 additions & 1 deletion src/ReactWindowGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const ReactWindowGrid = props => {
columnHorizontalPadding,
columnVerticalPadding,
verticalPadding,
rowColumnHeader
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comma is missing here

...rest
} = props

Expand Down Expand Up @@ -281,6 +282,19 @@ const ReactWindowGrid = props => {
{...rest}
style={{...(style || {}), width, position: 'relative', height}}
>
{rowColumnHeader && (
<div
style={{
position: absolute,
top: 0,
left: 0,
height: columnHeaderHeight,
width: rowHeaderWidth,
}}
>
{rowColumnHeader}
</div>
)}
<div style={{position: absolute, top: 0, left: rowHeaderWidth}}>
<VariableSizeList
ref={headerRef}
Expand Down Expand Up @@ -382,7 +396,8 @@ ReactWindowGrid.propTypes = {
gridRef: PropTypes.object,
style: PropTypes.object,
className: PropTypes.string,
scrollToTopOnNewRecordset: PropTypes.bool
scrollToTopOnNewRecordset: PropTypes.bool,
rowColumnHeader: PropTypes.object
}

ReactWindowGrid.defaultProps = {
Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ exports[`Auto calculate height and width 1`] = `
id="test1"
style="width: 100px; position: relative; height: 50px;"
>
<div
style="position: absolute; top: 0px; left: 0px;"
/>
<div
style="position: absolute; top: 0px; left: 10px;"
>
Expand Down Expand Up @@ -107,6 +110,9 @@ exports[`Case when recordset is empty use label or id to calc width 1`] = `
id="test2"
style="width: 100px; position: relative; height: 50px;"
>
<div
style="position: absolute; top: 0px; left: 0px;"
/>
<div
style="position: absolute; top: 0px; left: 10px;"
>
Expand Down Expand Up @@ -161,6 +167,9 @@ exports[`Use customized render 1`] = `
id="test3"
style="width: 200px; position: relative; height: 500px;"
>
<div
style="position: absolute; top: 0px; left: 0px;"
/>
<div
style="position: absolute; top: 0px; left: 30px;"
>
Expand Down
20 changes: 19 additions & 1 deletion src/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ const useStyles = makeStyles(theme => {
borderRight: border,
display: 'flex'
},
rowColumnHeader: {
fontSize: '0.75rem',
fontFamily: 'Roboto',
fontWeight: 400,
lineHeight: 1.66,
letterSpacing: '0.03333em',
borderBottom: border,
padding: '1px 0 0 4px'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padding-top should be zero to keep the same height of the header row

},
rowHeader: {
boxSizing,
borderBottom: border,
Expand Down Expand Up @@ -361,7 +370,8 @@ const Demo = () => {
</Grid>
<Grid item xs={12} ref={panel}>
<Typography variant="caption" align="center">
Controled column width and row with column resizing
Controled column width and row with column resizing. Customized
column header for row header.
</Typography>
<ReactWindowGrid
className={classes.grid}
Expand Down Expand Up @@ -405,6 +415,14 @@ const Demo = () => {
</div>
)
}}
rowColumnHeader={
<div
style={{width: 50}}
className={`${classes.columnHeader} ${classes.rowColumnHeader}`}
>
Items
</div>
}
/>
</Grid>
<Grid item xs={12}>
Expand Down
Loading