Skip to content

Commit

Permalink
chore: create MTableScrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
oze4 committed Aug 8, 2021
1 parent 7ef4880 commit 07434b4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": ["standard", "eslint:recommended", "plugin:react/recommended"],
"rules": {
"multiline-ternary": "off",
"no-restricted-imports": [
"error",
{
Expand Down
36 changes: 36 additions & 0 deletions src/components/MTableScrollbar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { withStyles } from '@material-ui/core';
import DoubleScrollbar from 'react-double-scrollbar';

This comment has been minimized.

Copy link
@donavan-tangible

donavan-tangible Mar 9, 2023

This import cause error: DoubleScrollbar
Failed to parse source map from 'node_modules/react-double-scrollbar/dist/DoubleScrollbar.js.map' file: Error: ENOENT: no such file or directory, open 'node_modules/react-double-scrollbar/dist/DoubleScrollbar.js.map'


const style = () => ({
horizontalScrollContainer: {
'& ::-webkit-scrollbar': {
'-webkit-appearance': 'none'
},
'& ::-webkit-scrollbar:horizontal': {
height: 8
},
'& ::-webkit-scrollbar-thumb': {
borderRadius: 4,
border: '2px solid white',
backgroundColor: 'rgba(0, 0, 0, .3)'
}
}
});

const ScrollBar = withStyles(style)(({ double, children, classes }) => {
if (double) {
return <DoubleScrollbar>{children}</DoubleScrollbar>;
} else {
return (
<div
className={classes.horizontalScrollContainer}
style={{ overflowX: 'auto', position: 'relative' }}
>
{children}
</div>
);
}
});

export default ScrollBar;
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export { default as OverlayLoading } from './Overlay/OverlayLoading.js';
export { default as OverlayError } from './Overlay/OverlayError.js';
export { default as Container } from './Container';
export { default as MTableScrollbar } from './MTableScrollbar';

/** ---------------------------
* Class based components
Expand Down
62 changes: 16 additions & 46 deletions src/material-table.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/* eslint-disable no-unused-vars */
import Table from '@material-ui/core/Table';
import TableFooter from '@material-ui/core/TableFooter';
import TableRow from '@material-ui/core/TableRow';
import LinearProgress from '@material-ui/core/LinearProgress';
import DoubleScrollbar from 'react-double-scrollbar';
import * as React from 'react';
import { MTablePagination, MTableSteppedPagination } from './components';
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
import DataManager from './utils/data-manager';
import React from 'react';
import { debounce } from 'debounce';
import equal from 'fast-deep-equal/react';
import { withStyles } from '@material-ui/core';
import {
Table,
TableFooter,
TableRow,
LinearProgress
} from '@material-ui/core';
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
import DataManager from './utils/data-manager';
import * as CommonValues from './utils/common-values';

/* eslint-enable no-unused-vars */
import {
MTablePagination,
MTableSteppedPagination,
MTableScrollbar
} from './components';

export default class MaterialTable extends React.Component {
dataManager = new DataManager();
Expand Down Expand Up @@ -1083,7 +1084,7 @@ export default class MaterialTable extends React.Component {
onGroupRemoved={this.onGroupRemoved}
/>
)}
<ScrollBar double={props.options.doubleHorizontalScroll}>
<MTableScrollbar double={props.options.doubleHorizontalScroll}>
<Droppable droppableId="headers" direction="horizontal">
{(provided, snapshot) => {
const table = this.renderTable(props);
Expand Down Expand Up @@ -1169,7 +1170,7 @@ export default class MaterialTable extends React.Component {
);
}}
</Droppable>
</ScrollBar>
</MTableScrollbar>
{(this.state.isLoading || props.isLoading) &&
props.options.loadingType === 'linear' && (
<div style={{ position: 'relative', width: '100%' }}>
Expand Down Expand Up @@ -1232,37 +1233,6 @@ export default class MaterialTable extends React.Component {
}
}

const style = () => ({
horizontalScrollContainer: {
'& ::-webkit-scrollbar': {
'-webkit-appearance': 'none'
},
'& ::-webkit-scrollbar:horizontal': {
height: 8
},
'& ::-webkit-scrollbar-thumb': {
borderRadius: 4,
border: '2px solid white',
backgroundColor: 'rgba(0, 0, 0, .3)'
}
}
});

const ScrollBar = withStyles(style)(({ double, children, classes }) => {
if (double) {
return <DoubleScrollbar>{children}</DoubleScrollbar>;
} else {
return (
<div
className={classes.horizontalScrollContainer}
style={{ overflowX: 'auto', position: 'relative' }}
>
{children}
</div>
);
}
});

function functionlessColumns(columns) {
return columns.map((col) =>
Object.entries(col).reduce((obj, [key, val]) => {
Expand Down

0 comments on commit 07434b4

Please sign in to comment.