Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 7, 2018
1 parent 96ea97f commit 9a59daf
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 55 deletions.
3 changes: 1 addition & 2 deletions packages/material-ui/src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export const styles = theme => ({

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

return (
<TableContext.Provider value={childContext}>
<TableContext.Provider value={{ padding }}>
<Component className={classNames(classes.root, className)} {...other} />
</TableContext.Provider>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Table/Tablelvl2Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import React from 'react';
/**
* @ignore - internal component.
*/
const TableContext = React.createContext();
const Tablelvl2Context = React.createContext();

export default TableContext;
export default Tablelvl2Context;
3 changes: 1 addition & 2 deletions packages/material-ui/src/TableBody/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export const styles = {

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

return (
<Tablelvl2Context.Provider value={childContext}>
<Tablelvl2Context.Provider value={{ variant: 'body' }}>
<Component className={classNames(classes.root, className)} {...other} />
</Tablelvl2Context.Provider>
);
Expand Down
88 changes: 43 additions & 45 deletions packages/material-ui/src/TableCell/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,55 +85,53 @@ function TableCell(props) {

return (
<TableContext.Consumer>
{table => {
return (
<Tablelvl2Context.Consumer>
{tablelvl2 => {
let Component;
if (component) {
Component = component;
} else {
Component = tablelvl2 && tablelvl2.variant === 'head' ? 'th' : 'td';
}
{table => (
<Tablelvl2Context.Consumer>
{tablelvl2 => {
let Component;
if (component) {
Component = component;
} else {
Component = tablelvl2 && tablelvl2.variant === 'head' ? 'th' : 'td';
}

let scope = scopeProp;
if (!scope && tablelvl2 && tablelvl2.variant === 'head') {
scope = 'col';
}
const padding = paddingProp || (table && table.padding ? table.padding : 'default');
let scope = scopeProp;
if (!scope && tablelvl2 && tablelvl2.variant === 'head') {
scope = 'col';
}
const padding = paddingProp || (table && table.padding ? table.padding : 'default');

const className = classNames(
classes.root,
{
[classes.head]: variant
? variant === 'head'
: tablelvl2 && tablelvl2.variant === 'head',
[classes.body]: variant
? variant === 'body'
: tablelvl2 && tablelvl2.variant === 'body',
[classes.footer]: variant
? variant === 'footer'
: tablelvl2 && tablelvl2.variant === 'footer',
[classes.numeric]: numeric,
[classes[`padding${capitalize(padding)}`]]: padding !== 'default',
},
classNameProp,
);
const className = classNames(
classes.root,
{
[classes.head]: variant
? variant === 'head'
: tablelvl2 && tablelvl2.variant === 'head',
[classes.body]: variant
? variant === 'body'
: tablelvl2 && tablelvl2.variant === 'body',
[classes.footer]: variant
? variant === 'footer'
: tablelvl2 && tablelvl2.variant === 'footer',
[classes.numeric]: numeric,
[classes[`padding${capitalize(padding)}`]]: padding !== 'default',
},
classNameProp,
);

let ariaSort = null;
if (sortDirection) {
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
}
let ariaSort = null;
if (sortDirection) {
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
}

return (
<Component className={className} aria-sort={ariaSort} scope={scope} {...other}>
{children}
</Component>
);
}}
</Tablelvl2Context.Consumer>
);
}}
return (
<Component className={className} aria-sort={ariaSort} scope={scope} {...other}>
{children}
</Component>
);
}}
</Tablelvl2Context.Consumer>
)}
</TableContext.Consumer>
);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/material-ui/src/TableFooter/TableFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export const styles = {

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

return (
<Tablelvl2Context.Provider value={childContext}>
<Tablelvl2Context.Provider value={{ variant: 'footer' }}>
<Component className={classNames(classes.root, className)} {...other} />
</Tablelvl2Context.Provider>
);
Expand Down
3 changes: 1 addition & 2 deletions packages/material-ui/src/TableHead/TableHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export const styles = {

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

return (
<Tablelvl2Context.Provider value={childContext}>
<Tablelvl2Context.Provider value={{ variant: 'head' }}>
<Component className={classNames(classes.root, className)} {...other} />
</Tablelvl2Context.Provider>
);
Expand Down

0 comments on commit 9a59daf

Please sign in to comment.