materialuiupgraded
Version:
Material-UI's workspace package
69 lines (60 loc) • 1.75 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
/* Styles applied to the root element. */
root: {
display: 'table',
fontFamily: theme.typography.fontFamily,
width: '100%',
borderCollapse: 'collapse',
borderSpacing: 0,
},
});
class Table extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
table: {
padding: this.props.padding,
},
};
}
render() {
const { classes, className, component: Component, padding, ...other } = this.props;
return <Component className={classNames(classes.root, className)} {...other} />;
}
}
Table.propTypes = {
/**
* The content of the table, normally `TableHeader` and `TableBody`.
*/
children: PropTypes.node.isRequired,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css-api) below for more details.
*/
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.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
/**
* Allows TableCells to inherit padding of the Table.
*/
padding: PropTypes.oneOf(['default', 'checkbox', 'dense', 'none']),
};
Table.defaultProps = {
component: 'table',
padding: 'default',
};
Table.childContextTypes = {
table: PropTypes.object,
};
export default withStyles(styles, { name: 'MuiTable' })(Table);