Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
10 changes: 9 additions & 1 deletion docs/src/modules/components/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import {
ThemeProvider as MuiThemeProvider,
createMuiTheme,
createMuiTheme as createLegacyModeTheme,
unstable_createMuiStrictModeTheme as createStrictModeTheme,
darken,
} from '@material-ui/core/styles';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -97,6 +98,13 @@ if (process.env.NODE_ENV !== 'production') {

const useEnhancedEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;

let createMuiTheme;
if (process.env.REACT_MODE === 'legacy') {
createMuiTheme = createLegacyModeTheme;
} else {
createMuiTheme = createStrictModeTheme;
}

export function ThemeProvider(props) {
const { children } = props;

Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
},
"dependencies": {
"@babel/runtime": "^7.4.4",
"@material-ui/react-transition-group": "^4.2.0",
"@material-ui/styles": "^4.9.10",
"@material-ui/system": "^4.9.10",
"@material-ui/types": "^5.0.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/material-ui/src/Backdrop/Backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const Backdrop = React.forwardRef(function Backdrop(props, ref) {
invisible = false,
open,
transitionDuration,
// eslint-disable-next-line react/prop-types
TransitionComponent = Fade,
...other
} = props;

return (
<Fade in={open} timeout={transitionDuration} {...other}>
<TransitionComponent in={open} timeout={transitionDuration} {...other}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I had forgotten about this one in #17047 (comment).

<div
data-mui-test="Backdrop"
className={clsx(
Expand All @@ -53,7 +55,7 @@ const Backdrop = React.forwardRef(function Backdrop(props, ref) {
>
{children}
</div>
</Fade>
</TransitionComponent>
);
});

Expand Down
6 changes: 4 additions & 2 deletions packages/material-ui/src/Collapse/Collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
onExiting,
style,
timeout = duration.standard,
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
...other
} = props;
const theme = useTheme();
Expand Down Expand Up @@ -153,7 +155,7 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
};

return (
<Transition
<TransitionComponent
in={inProp}
onEnter={handleEnter}
onEntered={handleEntered}
Expand Down Expand Up @@ -186,7 +188,7 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
</div>
</Component>
)}
</Transition>
</TransitionComponent>
);
});

Expand Down
23 changes: 23 additions & 0 deletions packages/material-ui/src/Collapse/StrictModeCollapse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { Transition } from '@material-ui/react-transition-group';
import { useForkRef } from '../utils';
import Collapse from './Collapse';

/**
* @ignore - internal component.
*/
const StrictModeCollapse = React.forwardRef(function StrictModeCollapse(props, forwardedRef) {
const domRef = React.useRef(null);
const ref = useForkRef(domRef, forwardedRef);

return (
<Collapse
{...props}
findDOMNode={() => domRef.current}
ref={ref}
TransitionComponent={Transition}
/>
);
});

export default StrictModeCollapse;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Collapse/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Collapse';
export { default, default as unstable_StrictModeCollapse } from './Collapse';
export * from './Collapse';
2 changes: 2 additions & 0 deletions packages/material-ui/src/Collapse/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default } from './Collapse';
// eslint-disable-next-line camelcase
export { default as unstable_StrictModeCollapse } from './StrictModeCollapse';
6 changes: 4 additions & 2 deletions packages/material-ui/src/Drawer/Drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const Drawer = React.forwardRef(function Drawer(props, ref) {
open = false,
PaperProps = {},
SlideProps,
// eslint-disable-next-line react/prop-types
TransitionComponent = Slide,
transitionDuration = defaultTransitionDuration,
variant = 'temporary',
...other
Expand Down Expand Up @@ -157,15 +159,15 @@ const Drawer = React.forwardRef(function Drawer(props, ref) {
}

const slidingDrawer = (
<Slide
<TransitionComponent
in={open}
direction={oppositeDirection[anchor]}
timeout={transitionDuration}
appear={mounted.current}
{...SlideProps}
>
{drawer}
</Slide>
</TransitionComponent>
);

if (variant === 'persistent') {
Expand Down
6 changes: 4 additions & 2 deletions packages/material-ui/src/Fade/Fade.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const Fade = React.forwardRef(function Fade(props, ref) {
onEnter,
onExit,
style,
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
timeout = defaultTimeout,
...other
} = props;
Expand Down Expand Up @@ -72,7 +74,7 @@ const Fade = React.forwardRef(function Fade(props, ref) {
};

return (
<Transition
<TransitionComponent
appear
in={inProp}
onEnter={handleEnter}
Expand All @@ -93,7 +95,7 @@ const Fade = React.forwardRef(function Fade(props, ref) {
...childProps,
});
}}
</Transition>
</TransitionComponent>
);
});

Expand Down
23 changes: 23 additions & 0 deletions packages/material-ui/src/Fade/StrictModeFade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { Transition } from '@material-ui/react-transition-group';
import { useForkRef } from '../utils';
import Fade from './Fade';

/**
* @ignore - internal component.
*/
const StrictModeFade = React.forwardRef(function StrictModeFade(props, forwardedRef) {
const domRef = React.useRef(null);
const ref = useForkRef(domRef, forwardedRef);

return (
<Fade
{...props}
findDOMNode={() => domRef.current}
ref={ref}
TransitionComponent={Transition}
/>
);
});

export default StrictModeFade;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Fade/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Fade';
export { default, default as unstable_StrictModeFade } from './Fade';
export * from './Fade';
2 changes: 2 additions & 0 deletions packages/material-ui/src/Fade/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default } from './Fade';
// eslint-disable-next-line camelcase
export { default as unstable_StrictModeFade } from './StrictModeFade';
16 changes: 13 additions & 3 deletions packages/material-ui/src/Grow/Grow.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ const styles = {
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
*/
const Grow = React.forwardRef(function Grow(props, ref) {
const { children, in: inProp, onEnter, onExit, style, timeout = 'auto', ...other } = props;
const {
children,
in: inProp,
onEnter,
onExit,
style,
timeout = 'auto',
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
...other
} = props;
const timer = React.useRef();
const autoTimeout = React.useRef();
const handleRef = useForkRef(children.ref, ref);
Expand Down Expand Up @@ -114,7 +124,7 @@ const Grow = React.forwardRef(function Grow(props, ref) {
}, []);

return (
<Transition
<TransitionComponent
appear
in={inProp}
onEnter={handleEnter}
Expand All @@ -137,7 +147,7 @@ const Grow = React.forwardRef(function Grow(props, ref) {
...childProps,
});
}}
</Transition>
</TransitionComponent>
);
});

Expand Down
23 changes: 23 additions & 0 deletions packages/material-ui/src/Grow/StrictModeGrow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { Transition } from '@material-ui/react-transition-group';
import { useForkRef } from '../utils';
import Grow from './Grow';

/**
* @ignore - internal component.
*/
const StrictModeGrow = React.forwardRef(function StrictModeGrow(props, forwardedRef) {
const domRef = React.useRef(null);
const ref = useForkRef(domRef, forwardedRef);

return (
<Grow
{...props}
findDOMNode={() => domRef.current}
ref={ref}
TransitionComponent={Transition}
/>
);
});

export default StrictModeGrow;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Grow/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Grow';
export { default, default as unstable_StrictModeGrow } from './Grow';
export * from './Grow';
2 changes: 2 additions & 0 deletions packages/material-ui/src/Grow/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default } from './Grow';
// eslint-disable-next-line camelcase
export { default as unstable_StrictModeGrow } from './StrictModeGrow';
6 changes: 4 additions & 2 deletions packages/material-ui/src/Slide/Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const Slide = React.forwardRef(function Slide(props, ref) {
onExited,
style,
timeout = defaultTimeout,
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
...other
} = props;

Expand Down Expand Up @@ -202,7 +204,7 @@ const Slide = React.forwardRef(function Slide(props, ref) {
}, [inProp, updatePosition]);

return (
<Transition
<TransitionComponent
onEnter={handleEnter}
onEntering={handleEntering}
onExit={handleExit}
Expand All @@ -223,7 +225,7 @@ const Slide = React.forwardRef(function Slide(props, ref) {
...childProps,
});
}}
</Transition>
</TransitionComponent>
);
});

Expand Down
23 changes: 23 additions & 0 deletions packages/material-ui/src/Slide/StrictModeSlide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { Transition } from '@material-ui/react-transition-group';
import { useForkRef } from '../utils';
import Slide from './Slide';

/**
* @ignore - internal component.
*/
const StrictModeSlide = React.forwardRef(function StrictModeSlide(props, forwardedRef) {
const domRef = React.useRef(null);
const ref = useForkRef(domRef, forwardedRef);

return (
<Slide
{...props}
findDOMNode={() => domRef.current}
ref={ref}
TransitionComponent={Transition}
/>
);
});

export default StrictModeSlide;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Slide/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Slide';
export { default, default as unstable_StrictModeSlide } from './Slide';
export * from './Slide';
2 changes: 2 additions & 0 deletions packages/material-ui/src/Slide/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default } from './Slide';
// eslint-disable-next-line camelcase
export { default as unstable_StrictModeSlide } from './StrictModeSlide';
23 changes: 23 additions & 0 deletions packages/material-ui/src/Zoom/StrictModeZoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { Transition } from '@material-ui/react-transition-group';
import { useForkRef } from '../utils';
import Zoom from './Zoom';

/**
* @ignore - internal component.
*/
const StrictModeZoom = React.forwardRef(function StrictModeZoom(props, forwardedRef) {
const domRef = React.useRef(null);
const ref = useForkRef(domRef, forwardedRef);

return (
<Zoom
{...props}
findDOMNode={() => domRef.current}
ref={ref}
TransitionComponent={Transition}
/>
);
});

export default StrictModeZoom;
6 changes: 4 additions & 2 deletions packages/material-ui/src/Zoom/Zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const Zoom = React.forwardRef(function Zoom(props, ref) {
onExit,
style,
timeout = defaultTimeout,
// eslint-disable-next-line react/prop-types
TransitionComponent = Transition,
...other
} = props;

Expand Down Expand Up @@ -74,7 +76,7 @@ const Zoom = React.forwardRef(function Zoom(props, ref) {
};

return (
<Transition
<TransitionComponent
Copy link
Member

@oliviertassinari oliviertassinari Apr 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call the root component prop Component to match the other non transition component convention?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of the generic term if the component has a specific task.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder. It could feel surprising 🤔.

Copy link
Member Author

@eps1lon eps1lon Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That the component responsible for Transition is named TransitionComponent over Component? Is this seriously a concern?

Copy link
Member

@oliviertassinari oliviertassinari Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be like we change the convention for the style rule, naming the root class name .transition over .root?

Copy link
Member

@oliviertassinari oliviertassinari Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of the idea to introduce a Components?: { Root: React.ComponentType, … } prop for v5 and empowering deep component customizations with styled component?

Similarly to what we do for the class names:

  • className prop at the root
  • classes.root object at the root
  • classes.xxx object for the nested elements

we could have:

  • Component prop at the root
  • Components.Root object at the root
  • Components.xxx object for the nested components

appear
in={inProp}
onEnter={handleEnter}
Expand All @@ -95,7 +97,7 @@ const Zoom = React.forwardRef(function Zoom(props, ref) {
...childProps,
});
}}
</Transition>
</TransitionComponent>
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Zoom/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Zoom';
export { default, default as unstable_StrictModeZoom } from './Zoom';
export * from './Zoom';
2 changes: 2 additions & 0 deletions packages/material-ui/src/Zoom/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default } from './Zoom';
// eslint-disable-next-line camelcase
export { default as unstable_StrictModeZoom } from './StrictModeZoom';
Loading