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 c2aa160
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 66 deletions.
12 changes: 5 additions & 7 deletions packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,11 @@ class SwipeableDrawer extends React.Component {
anchor={anchor}
{...other}
/>
{!disableDiscovery &&
!disableSwipeToOpen &&
variant === 'temporary' && (
<NoSsr>
<SwipeArea anchor={anchor} width={swipeAreaWidth} />
</NoSsr>
)}
{!disableDiscovery && !disableSwipeToOpen && variant === 'temporary' && (
<NoSsr>
<SwipeArea anchor={anchor} width={swipeAreaWidth} />
</NoSsr>
)}
</React.Fragment>
);
}
Expand Down
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
4 changes: 3 additions & 1 deletion packages/material-ui/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export { StyledComponentProps };

export type PropsOf<C> = C extends new (props: infer P) => React.Component
? P
: C extends (props: infer P) => React.ReactElement<any> | null ? P : never;
: C extends (props: infer P) => React.ReactElement<any> | null
? P
: never;

/**
* All standard components exposed by `material-ui` are `StyledComponents` with
Expand Down
6 changes: 5 additions & 1 deletion packages/material-ui/src/styles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export type WithStyles<
classes: ClassNameMap<
T extends string
? T
: T extends StyleRulesCallback<infer K> ? K : T extends StyleRules<infer K> ? K : never
: T extends StyleRulesCallback<infer K>
? K
: T extends StyleRules<infer K>
? K
: never
>;
innerRef?: React.Ref<any> | React.RefObject<any>;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/utils/ponyfillGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
export default (typeof window != 'undefined' && window.Math == Math
? window
: typeof self != 'undefined' && self.Math == Math
? self
: Function('return this')());
? self
: Function('return this')());

0 comments on commit c2aa160

Please sign in to comment.