Skip to content

Commit

Permalink
Bugfix/issue 1095 fix stacked view styles (gregnb#1096)
Browse files Browse the repository at this point in the history
* Fix issues caused by style changes for dense table views

We need something closer to the previous styles for default stacked views to prevent divergences in display with mui v4

* Fix deprecation warning in example
  • Loading branch information
gabrielliwerant authored and patorjk committed May 31, 2020
1 parent bc30519 commit 5600876
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
5 changes: 4 additions & 1 deletion examples/customize-styling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class Example extends React.Component {
filter: true,
filterType: 'dropdown',
responsive: this.state.stacked ? 'stacked' : 'scrollMaxHeight',
fixedHeader: true,
fixedHeaderOptions: {
xAxis: true,
yAxis: true
},
rowHover: false,
setRowProps: (row) => {
return {
Expand Down
36 changes: 21 additions & 15 deletions src/components/TableBodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ const defaultBodyCellStyles = theme => ({
cellHide: {
display: 'none',
},
cellStacked: {
stackedCommon: {
[theme.breakpoints.down('sm')]: {
display: 'inline-block',
fontSize: '16px',
width: '50%',
height: '24px',
whiteSpace: 'nowrap',
width: 'calc(50% - 80px)',
whiteSpace: 'nowrap',
boxSizing: 'border-box',
height: '32px',
'&:last-child': {
borderBottom: 'none',
},
'&:nth-last-child(2)': {
borderBottom: 'none',
},
},
},
responsiveStacked: {
cellStackedSmall: {
[theme.breakpoints.down('sm')]: {
width: '50%',
},
},
responsiveStackedSmall: {
[theme.breakpoints.down('sm')]: {
display: 'inline-block',
fontSize: '16px',
width: '50%',
whiteSpace: 'nowrap',
boxSizing: 'border-box',
height: '32px',
'&:last-child': {
borderBottom: 'none',
},
},
},
});
Expand Down Expand Up @@ -65,7 +65,10 @@ class TableBodyCell extends React.Component {
{
[classes.root]: true,
[classes.cellHide]: true,
[classes.cellStacked]: options.responsive === 'stacked',
[classes.stackedCommon]: options.responsive === 'stacked',
[classes.cellStackedSmall]:
options.responsive === 'stacked' &&
(options.setTableProps().padding === 'none' || options.setTableProps().size === 'small'),
'datatables-noprint': !print,
},
className,
Expand All @@ -78,7 +81,10 @@ class TableBodyCell extends React.Component {
className={classNames(
{
[classes.root]: true,
[classes.responsiveStacked]: options.responsive === 'stacked',
[classes.stackedCommon]: options.responsive === 'stacked',
[classes.responsiveStackedSmall]:
options.responsive === 'stacked' &&
(options.setTableProps().padding === 'none' || options.setTableProps().size === 'small'),
'datatables-noprint': !print,
},
className,
Expand Down

0 comments on commit 5600876

Please sign in to comment.