Skip to content

Commit

Permalink
[Table] Migrate TableCell to emotion (#24663)
Browse files Browse the repository at this point in the history
  • Loading branch information
natac13 authored Feb 12, 2021
1 parent 2703121 commit 8f6b38a
Show file tree
Hide file tree
Showing 26 changed files with 200 additions and 96 deletions.
4 changes: 3 additions & 1 deletion docs/pages/api-docs/table-cell.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"sortDirection": {
"type": { "name": "enum", "description": "'asc'<br>&#124;&nbsp;'desc'<br>&#124;&nbsp;false" }
},
"sx": { "type": { "name": "object" } },
"variant": {
"type": {
"name": "enum",
Expand All @@ -36,6 +37,7 @@
"body",
"footer",
"sizeSmall",
"sizeMedium",
"paddingCheckbox",
"paddingNone",
"alignLeft",
Expand All @@ -52,6 +54,6 @@
"filename": "/packages/material-ui/src/TableCell/TableCell.js",
"inheritance": null,
"demos": "<ul><li><a href=\"/components/tables/\">Tables</a></li></ul>",
"styledComponent": false,
"styledComponent": true,
"cssComponent": false
}
13 changes: 8 additions & 5 deletions docs/pages/performance/table-emotion.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
// import { experimentalStyled as styled } from '@material-ui/core/styles';
import NoSsr from '@material-ui/core/NoSsr';

const createComponent = (defaultComponent) => {
const Root = styled('div')`
background: pink;
`;

const MyComponent = React.forwardRef(function MyComponent(props, ref) {
const { component: Component = defaultComponent, ...other } = props;
const { component = defaultComponent, ...other } = props;

return <Component ref={ref} {...other} />;
return <Root as={component} ref={ref} {...other} />;
});

MyComponent.propTypes = {
component: PropTypes.elementType,
};

return styled(MyComponent)`
background: pink;
`;
return MyComponent;
};

const Table = createComponent('table');
Expand Down
6 changes: 6 additions & 0 deletions docs/translations/api-docs/table-cell/table-cell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scope": "Set scope attribute.",
"size": "Specify the size of the cell. The prop defaults to the value (<code>&#39;medium&#39;</code>) inherited from the parent Table component.",
"sortDirection": "Set aria-sort direction.",
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the <a href=\"/system/basics/#the-sx-prop\">`sx` page</a> for more details.",
"variant": "Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components."
},
"classDescriptions": {
Expand All @@ -33,6 +34,11 @@
"nodeName": "the root element",
"conditions": "<code>size=\"small\"</code>"
},
"sizeMedium": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>size=\"medium\"</code>"
},
"paddingCheckbox": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/CardMedia/CardMedia.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { Theme } from '..';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Checkbox/Checkbox.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { SwitchBaseProps } from '../internal/SwitchBase';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';

export interface CircularProgressProps
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ImageListItem/ImageListItem.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { Theme } from '..';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';

export interface ImageListItemBarProps
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ListItemText/ListItemText.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { TypographyProps } from '../Typography';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Step/Step.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';

export interface StepProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Tab/Tab.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { Theme } from '..';
import { ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase';
import { OverrideProps } from '../OverridableComponent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';

export interface TabScrollButtonProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Table/Table.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { Theme } from '..';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/TableBody/TableBody.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SxProps } from '@material-ui/system';
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { Theme } from '..';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';

Expand Down
9 changes: 8 additions & 1 deletion packages/material-ui/src/TableCell/TableCell.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { InternalStandardProps as StandardProps } from '..';
import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { Padding, Size } from '../Table';

export { Padding, Size };
Expand Down Expand Up @@ -39,6 +40,8 @@ export interface TableCellProps extends StandardProps<TableCellBaseProps, 'align
footer?: string;
/** Styles applied to the root element if `size="small"`. */
sizeSmall?: string;
/** Styles applied to the root element if `size="medium"`. */
sizeMedium?: string;
/** Styles applied to the root element if `padding="checkbox"`. */
paddingCheckbox?: string;
/** Styles applied to the root element if `padding="none"`. */
Expand Down Expand Up @@ -77,6 +80,10 @@ export interface TableCellProps extends StandardProps<TableCellBaseProps, 'align
* Set aria-sort direction.
*/
sortDirection?: SortDirection;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
/**
* Specify the cell type.
* The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components.
Expand Down
Loading

0 comments on commit 8f6b38a

Please sign in to comment.