Skip to content

Commit 9a59daf

Browse files
small changes
1 parent 96ea97f commit 9a59daf

File tree

6 files changed

+49
-55
lines changed

6 files changed

+49
-55
lines changed

packages/material-ui/src/Table/Table.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ export const styles = theme => ({
1717

1818
function Table(props) {
1919
const { classes, className, component: Component, padding, ...other } = props;
20-
const childContext = { padding };
2120

2221
return (
23-
<TableContext.Provider value={childContext}>
22+
<TableContext.Provider value={{ padding }}>
2423
<Component className={classNames(classes.root, className)} {...other} />
2524
</TableContext.Provider>
2625
);

packages/material-ui/src/Table/Tablelvl2Context.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import React from 'react';
33
/**
44
* @ignore - internal component.
55
*/
6-
const TableContext = React.createContext();
6+
const Tablelvl2Context = React.createContext();
77

8-
export default TableContext;
8+
export default Tablelvl2Context;

packages/material-ui/src/TableBody/TableBody.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export const styles = {
1313

1414
function TableBody(props) {
1515
const { classes, className, component: Component, ...other } = props;
16-
const childContext = { variant: 'body' };
1716

1817
return (
19-
<Tablelvl2Context.Provider value={childContext}>
18+
<Tablelvl2Context.Provider value={{ variant: 'body' }}>
2019
<Component className={classNames(classes.root, className)} {...other} />
2120
</Tablelvl2Context.Provider>
2221
);

packages/material-ui/src/TableCell/TableCell.js

+43-45
Original file line numberDiff line numberDiff line change
@@ -85,55 +85,53 @@ function TableCell(props) {
8585

8686
return (
8787
<TableContext.Consumer>
88-
{table => {
89-
return (
90-
<Tablelvl2Context.Consumer>
91-
{tablelvl2 => {
92-
let Component;
93-
if (component) {
94-
Component = component;
95-
} else {
96-
Component = tablelvl2 && tablelvl2.variant === 'head' ? 'th' : 'td';
97-
}
88+
{table => (
89+
<Tablelvl2Context.Consumer>
90+
{tablelvl2 => {
91+
let Component;
92+
if (component) {
93+
Component = component;
94+
} else {
95+
Component = tablelvl2 && tablelvl2.variant === 'head' ? 'th' : 'td';
96+
}
9897

99-
let scope = scopeProp;
100-
if (!scope && tablelvl2 && tablelvl2.variant === 'head') {
101-
scope = 'col';
102-
}
103-
const padding = paddingProp || (table && table.padding ? table.padding : 'default');
98+
let scope = scopeProp;
99+
if (!scope && tablelvl2 && tablelvl2.variant === 'head') {
100+
scope = 'col';
101+
}
102+
const padding = paddingProp || (table && table.padding ? table.padding : 'default');
104103

105-
const className = classNames(
106-
classes.root,
107-
{
108-
[classes.head]: variant
109-
? variant === 'head'
110-
: tablelvl2 && tablelvl2.variant === 'head',
111-
[classes.body]: variant
112-
? variant === 'body'
113-
: tablelvl2 && tablelvl2.variant === 'body',
114-
[classes.footer]: variant
115-
? variant === 'footer'
116-
: tablelvl2 && tablelvl2.variant === 'footer',
117-
[classes.numeric]: numeric,
118-
[classes[`padding${capitalize(padding)}`]]: padding !== 'default',
119-
},
120-
classNameProp,
121-
);
104+
const className = classNames(
105+
classes.root,
106+
{
107+
[classes.head]: variant
108+
? variant === 'head'
109+
: tablelvl2 && tablelvl2.variant === 'head',
110+
[classes.body]: variant
111+
? variant === 'body'
112+
: tablelvl2 && tablelvl2.variant === 'body',
113+
[classes.footer]: variant
114+
? variant === 'footer'
115+
: tablelvl2 && tablelvl2.variant === 'footer',
116+
[classes.numeric]: numeric,
117+
[classes[`padding${capitalize(padding)}`]]: padding !== 'default',
118+
},
119+
classNameProp,
120+
);
122121

123-
let ariaSort = null;
124-
if (sortDirection) {
125-
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
126-
}
122+
let ariaSort = null;
123+
if (sortDirection) {
124+
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
125+
}
127126

128-
return (
129-
<Component className={className} aria-sort={ariaSort} scope={scope} {...other}>
130-
{children}
131-
</Component>
132-
);
133-
}}
134-
</Tablelvl2Context.Consumer>
135-
);
136-
}}
127+
return (
128+
<Component className={className} aria-sort={ariaSort} scope={scope} {...other}>
129+
{children}
130+
</Component>
131+
);
132+
}}
133+
</Tablelvl2Context.Consumer>
134+
)}
137135
</TableContext.Consumer>
138136
);
139137
}

packages/material-ui/src/TableFooter/TableFooter.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export const styles = {
1313

1414
function TableFooter(props) {
1515
const { classes, className, component: Component, ...other } = props;
16-
const childContext = { variant: 'footer' };
1716

1817
return (
19-
<Tablelvl2Context.Provider value={childContext}>
18+
<Tablelvl2Context.Provider value={{ variant: 'footer' }}>
2019
<Component className={classNames(classes.root, className)} {...other} />
2120
</Tablelvl2Context.Provider>
2221
);

packages/material-ui/src/TableHead/TableHead.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export const styles = {
1313

1414
function TableHead(props) {
1515
const { classes, className, component: Component, ...other } = props;
16-
const childContext = { variant: 'head' };
1716

1817
return (
19-
<Tablelvl2Context.Provider value={childContext}>
18+
<Tablelvl2Context.Provider value={{ variant: 'head' }}>
2019
<Component className={classNames(classes.root, className)} {...other} />
2120
</Tablelvl2Context.Provider>
2221
);

0 commit comments

Comments
 (0)