diff --git a/docs/src/pages/demos/tables/BasicTable.js b/docs/src/pages/demos/tables/BasicTable.js index e6c3fca5ff487b..0d398f229b6bd3 100644 --- a/docs/src/pages/demos/tables/BasicTable.js +++ b/docs/src/pages/demos/tables/BasicTable.js @@ -10,10 +10,6 @@ const styles = theme => ({ root: { width: '100%', marginTop: theme.spacing.unit * 3, - overflowX: 'auto', - }, - table: { - minWidth: 700, }, }); @@ -36,7 +32,7 @@ function BasicTable(props) { return ( - +
Dessert (100g serving) diff --git a/docs/src/pages/demos/tables/EnhancedTable.js b/docs/src/pages/demos/tables/EnhancedTable.js index e674d4417f6320..f0dd05615ef82e 100644 --- a/docs/src/pages/demos/tables/EnhancedTable.js +++ b/docs/src/pages/demos/tables/EnhancedTable.js @@ -167,12 +167,6 @@ const styles = theme => ({ width: '100%', marginTop: theme.spacing.unit * 3, }, - table: { - minWidth: 800, - }, - tableWrapper: { - overflowX: 'auto', - }, }); class EnhancedTable extends React.Component { @@ -272,60 +266,58 @@ class EnhancedTable extends React.Component { return ( -
-
- - - {data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(n => { - const isSelected = this.isSelected(n.id); - return ( - this.handleClick(event, n.id)} - onKeyDown={event => this.handleKeyDown(event, n.id)} - role="checkbox" - aria-checked={isSelected} - tabIndex={-1} - key={n.id} - selected={isSelected} - > - - - - {n.name} - {n.calories} - {n.fat} - {n.carbs} - {n.protein} - - ); - })} - {emptyRows > 0 && ( - - +
+ + + {data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(n => { + const isSelected = this.isSelected(n.id); + return ( + this.handleClick(event, n.id)} + onKeyDown={event => this.handleKeyDown(event, n.id)} + role="checkbox" + aria-checked={isSelected} + tabIndex={-1} + key={n.id} + selected={isSelected} + > + + + + {n.name} + {n.calories} + {n.fat} + {n.carbs} + {n.protein} - )} - - - - + ); + })} + {emptyRows > 0 && ( + + - -
- + )} + + + + + + +
); } diff --git a/pages/api/table.md b/pages/api/table.md index 7de25cacdda19c..43997342da4304 100644 --- a/pages/api/table.md +++ b/pages/api/table.md @@ -22,7 +22,8 @@ Any other properties supplied will be [spread to the root element](/guides/api#s You can override all the class names injected by Material-UI thanks to the `classes` property. This property accepts the following keys: -- `root` +- `table` +- `wrapper` Have a look at [overriding with classes](/customization/overrides#overriding-with-classes) section and the [implementation of the component](https://github.com/callemall/material-ui/tree/v1-beta/src/Table/Table.js) diff --git a/src/Table/Table.js b/src/Table/Table.js index 3fd83e37671dc8..4143208197ada9 100644 --- a/src/Table/Table.js +++ b/src/Table/Table.js @@ -7,12 +7,15 @@ import classNames from 'classnames'; import withStyles from '../styles/withStyles'; export const styles = (theme: Object) => ({ - root: { + table: { fontFamily: theme.typography.fontFamily, width: '100%', borderCollapse: 'collapse', borderSpacing: 0, - overflow: 'hidden', + }, + wrapper: { + width: '100%', + overflowX: 'auto', }, }); @@ -68,12 +71,12 @@ class Table extends React.Component { component: ComponentProp, ...other } = this.props; - const className = classNames(classes.root, classNameProp); + const divWrapper = classNames(classes.wrapper, classNameProp); return ( - - {children} - +
+ {children} +
); } } diff --git a/src/Table/Table.spec.js b/src/Table/Table.spec.js index d194a00a0d2ab3..d5e4b4deda708d 100644 --- a/src/Table/Table.spec.js +++ b/src/Table/Table.spec.js @@ -16,12 +16,12 @@ describe('', () => { it('should render a table', () => { const wrapper = shallow(
); - assert.strictEqual(wrapper.name(), 'table'); + assert.strictEqual(wrapper.childAt(0).name(), 'table'); }); it('should render a div', () => { const wrapper = shallow(
); - assert.strictEqual(wrapper.name(), 'div'); + assert.strictEqual(wrapper.childAt(0).name(), 'div'); }); it('should spread custom props on the root node', () => { @@ -36,13 +36,19 @@ describe('
', () => { it('should render with the user and root classes', () => { const wrapper = shallow(
); assert.strictEqual(wrapper.hasClass('woofTable'), true); - assert.strictEqual(wrapper.hasClass(classes.root), true); + assert.strictEqual(wrapper.hasClass(classes.wrapper), true); }); it('should render children', () => { const children = ; const wrapper = shallow(
{children}
); - assert.strictEqual(wrapper.childAt(0).equals(children), true); + assert.strictEqual( + wrapper + .childAt(0) + .childAt(0) + .equals(children), + true, + ); }); it('should define table in the child context', () => {