Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Table] Add table-footer-group CSS #11264

Merged
merged 4 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/material-ui/src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Table extends React.Component {
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Table/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class TableBody extends React.Component {
}

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

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

Expand Down
5 changes: 4 additions & 1 deletion packages/material-ui/src/Table/TableFooter.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as React from 'react';
import { StandardProps } from '..';

export interface TableFooterProps extends TableFooterBaseProps {
export interface TableFooterProps extends StandardProps<TableFooterBaseProps, TableFooterClassKey> {
component?: React.ReactType<TableFooterBaseProps>;
}

export type TableFooterClassKey = 'root';

export type TableFooterBaseProps = React.HTMLAttributes<HTMLTableSectionElement>;

declare const TableFooter: React.ComponentType<TableFooterProps>;
Expand Down
22 changes: 19 additions & 3 deletions packages/material-ui/src/Table/TableFooter.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-footer-group',
},
};

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

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

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

Expand All @@ -23,6 +31,14 @@ TableFooter.propTypes = {
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node,
/**
* 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 @@ TableFooter.childContextTypes = {
table: PropTypes.object,
};

export default TableFooter;
export default withStyles(styles, { name: 'MuiTableFooter' })(TableFooter);
9 changes: 6 additions & 3 deletions packages/material-ui/src/Table/TableFooter.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
import { assert } from 'chai';
import { createShallow } from '../test-utils';
import { createShallow, getClasses } from '../test-utils';
import TableFooter from './TableFooter';

describe('<TableFooter />', () => {
let shallow;
let classes;

before(() => {
shallow = createShallow();
shallow = createShallow({ dive: true });
classes = getClasses(<TableFooter />);
});

it('should render a tfoot', () => {
Expand All @@ -20,9 +22,10 @@ describe('<TableFooter />', () => {
assert.strictEqual(wrapper.name(), 'div');
});

it('should render with the user class', () => {
it('should render with the user and root class', () => {
const wrapper = shallow(<TableFooter className="woofTableHead" />);
assert.strictEqual(wrapper.hasClass('woofTableHead'), true);
assert.strictEqual(wrapper.hasClass(classes.root), true);
});

it('should render children', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Table/TableHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class TableHead extends React.Component {
}

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

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

Expand Down
13 changes: 8 additions & 5 deletions packages/material-ui/src/styles/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { AppBarClassKey } from '../AppBar/AppBar';
import { AvatarClassKey } from '../Avatar/Avatar';
import { BackdropClassKey } from '../Modal/Backdrop';
import { BadgeClassKey } from '../Badge/Badge';
import { BottomNavigationClassKey } from '../BottomNavigation/BottomNavigation';
import { BottomNavigationActionClassKey } from '../BottomNavigation/BottomNavigationAction';
import { ButtonClassKey } from '../Button/Button';
import { BottomNavigationClassKey } from '../BottomNavigation/BottomNavigation';
import { ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
import { CardClassKey } from '../Card/Card';
import { ButtonClassKey } from '../Button/Button';
import { CardActionsClassKey } from '../Card/CardActions';
import { CardClassKey } from '../Card/Card';
import { CardContentClassKey } from '../Card/CardContent';
import { CardHeaderClassKey } from '../Card/CardHeader';
import { CardMediaClassKey } from '../Card/CardMedia';
Expand Down Expand Up @@ -62,8 +62,8 @@ import { SelectClassKey } from '../Select/Select';
import { SelectInputClassKey } from '../Select/SelectInput';
import { SnackbarClassKey } from '../Snackbar/Snackbar';
import { SnackbarContentClassKey } from '../Snackbar/SnackbarContent';
import { StepClasskey } from '../Stepper/Step';
import { StepButtonClasskey } from '../Stepper/StepButton';
import { StepClasskey } from '../Stepper/Step';
import { StepContentClasskey } from '../Stepper/StepContent';
import { StepIconClasskey } from '../Stepper/StepIcon';
import { StepLabelClasskey } from '../Stepper/StepLabel';
Expand All @@ -73,8 +73,11 @@ import { SvgIconClassKey } from '../SvgIcon/SvgIcon';
import { SwitchBaseClassKey } from '../internal/SwitchBase';
import { SwitchClassKey } from '../Switch/Switch';
import { TabClassKey } from '../Tabs/Tab';
import { TableClassKey } from '../Table/Table';
import { TableBodyClassKey } from '../Table/TableBody';
import { TableCellClassKey } from '../Table/TableCell';
import { TableClassKey } from '../Table/Table';
import { TableFooterClassKey } from '../Table/TableFooter';
import { TableHeadClassKey } from '../Table/TableHead';
import { TablePaginationClassKey } from '../Table/TablePagination';
import { TableRowClassKey } from '../Table/TableRow';
import { TableSortLabelClassKey } from '../Table/TableSortLabel';
Expand Down
1 change: 1 addition & 0 deletions pages/api/table-footer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ filename: /packages/material-ui/src/Table/TableFooter.js
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">children</span> | <span class="prop-type">node | | The content of the component, normally `TableRow`. |
| <span class="prop-name">classes</span> | <span class="prop-type">object | | Useful to extend the style applied to components. |
| <span class="prop-name">component</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;func<br> | <span class="prop-default">'tfoot'</span> | The component used for the root node. Either a string to use a DOM element or a component. |

Any other properties supplied will be [spread to the root element](/guides/api#spread).
Expand Down