Skip to content

Commit

Permalink
Added table padding feature.
Browse files Browse the repository at this point in the history
Fixed omission of padding as a valid prop of Table.

Fixed read-only problems with padding.

Defined Padding.
  • Loading branch information
aseem191 committed Aug 6, 2018
1 parent 876cc40 commit c3d47a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/material-ui/src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Table extends React.Component {
// eslint-disable-line class-methods-use-this
return {
table: {},
padding: this.props.padding
};
}

Expand All @@ -43,6 +44,10 @@ Table.propTypes = {
* @ignore
*/
className: PropTypes.string,
/**
* Allows TableCells to inherit padding of the Table.
*/
padding: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
Expand All @@ -52,10 +57,12 @@ Table.propTypes = {

Table.defaultProps = {
component: 'table',
padding: 'default'
};

Table.childContextTypes = {
table: PropTypes.object,
padding: PropTypes.string
};

export default withStyles(styles, { name: 'MuiTable' })(Table);
6 changes: 5 additions & 1 deletion packages/material-ui/src/TableCell/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function TableCell(props, context) {
variant,
...other
} = props;

let Padding = padding === 'default' ? context.padding : padding;

const { table } = context;
let Component;
if (component) {
Expand All @@ -100,7 +103,7 @@ function TableCell(props, context) {
[classes.body]: variant ? variant === 'body' : table && table.body,
[classes.footer]: variant ? variant === 'footer' : table && table.footer,
[classes.numeric]: numeric,
[classes[`padding${capitalize(padding)}`]]: padding !== 'default',
[classes[`padding${capitalize(Padding)}`]]: Padding !== 'default',
},
classNameProp,
);
Expand Down Expand Up @@ -166,6 +169,7 @@ TableCell.defaultProps = {

TableCell.contextTypes = {
table: PropTypes.object.isRequired,
padding: PropTypes.string
};

export default withStyles(styles, { name: 'MuiTableCell' })(TableCell);

0 comments on commit c3d47a2

Please sign in to comment.