Skip to content

Commit

Permalink
[Table] default display style for all table components
Browse files Browse the repository at this point in the history
  • Loading branch information
caub committed Feb 25, 2018
1 parent 9a60f98 commit faa80b6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import withStyles from '../styles/withStyles';

export const styles = theme => ({
root: {
display: 'table',
fontFamily: theme.typography.fontFamily,
width: '100%',
borderCollapse: 'collapse',
Expand Down
22 changes: 19 additions & 3 deletions src/Table/TableBody.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';

const styles = {
root: {
display: 'table-row-group',
},
};

class TableBody extends React.Component {
getChildContext() {
Expand All @@ -12,9 +20,9 @@ class TableBody extends React.Component {
}

render() {
const { component: Component, ...other } = this.props;
const { classes, className: classNameProp, component: Component, ...other } = this.props;

return <Component {...other} />;
return <Component className={classNames(classes.root, classNameProp)} {...other} />;
}
}

Expand All @@ -23,6 +31,14 @@ TableBody.propTypes = {
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
Expand All @@ -38,4 +54,4 @@ TableBody.childContextTypes = {
table: PropTypes.object,
};

export default TableBody;
export default withStyles(styles, { name: 'MuiTableBody' })(TableBody);
2 changes: 1 addition & 1 deletion src/Table/TableBody.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('<TableBody />', () => {
let shallow;

before(() => {
shallow = createShallow();
shallow = createShallow({ dive: true });
});

it('should render a tbody', () => {
Expand Down
1 change: 1 addition & 0 deletions src/Table/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { darken, fade, lighten } from '../styles/colorManipulator';

export const styles = theme => ({
root: {
display: 'table-cell',
// Workaround for a rendering bug with spanned columns in Chrome 62.0.
// Removes the alpha (sets it to 1), and lightens or darkens the theme color.
borderBottom: `1px solid
Expand Down
22 changes: 19 additions & 3 deletions src/Table/TableHead.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';

const styles = {
root: {
display: 'table-header-group',
},
};

class TableHead extends React.Component {
getChildContext() {
Expand All @@ -12,9 +20,9 @@ class TableHead extends React.Component {
}

render() {
const { component: Component, ...other } = this.props;
const { classes, className: classNameProp, component: Component, ...other } = this.props;

return <Component {...other} />;
return <Component className={classNames(classes.root, classNameProp)} {...other} />;
}
}

Expand All @@ -23,6 +31,14 @@ TableHead.propTypes = {
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
Expand All @@ -38,4 +54,4 @@ TableHead.childContextTypes = {
table: PropTypes.object,
};

export default TableHead;
export default withStyles(styles, { name: 'MuiTableHead' })(TableHead);
2 changes: 1 addition & 1 deletion src/Table/TableHead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('<TableHead />', () => {
let shallow;

before(() => {
shallow = createShallow();
shallow = createShallow({ dive: true });
});

it('should render a thead', () => {
Expand Down

0 comments on commit faa80b6

Please sign in to comment.