Skip to content

Commit

Permalink
[core] Standardize the component injection pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed May 1, 2018
1 parent 2ac22c9 commit 916f8a3
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class CustomPaginationActionsTable extends React.Component {
page={page}
onChangePage={this.handleChangePage}
onChangeRowsPerPage={this.handleChangeRowsPerPage}
Actions={TablePaginationActionsWrapped}
ActionsComponent={TablePaginationActionsWrapped}
/>
</TableRow>
</TableFooter>
Expand Down
15 changes: 10 additions & 5 deletions packages/material-ui-lab/src/SpeedDial/SpeedDial.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SpeedDial extends React.Component {
onKeyDown,
open,
openIcon,
transition: Transition,
TransitionComponent,
transitionDuration,
TransitionProps,
...other
Expand Down Expand Up @@ -137,7 +137,12 @@ class SpeedDial extends React.Component {

return (
<div className={classNames(classes.root, classNameProp)} {...other}>
<Transition in={!hidden} timeout={transitionDuration} unmountOnExit {...TransitionProps}>
<TransitionComponent
in={!hidden}
timeout={transitionDuration}
unmountOnExit
{...TransitionProps}
>
<Button
variant="fab"
color="primary"
Expand All @@ -155,7 +160,7 @@ class SpeedDial extends React.Component {
>
{icon()}
</Button>
</Transition>
</TransitionComponent>
<div
id={`${id}-actions`}
className={classNames(classes.actions, { [classes.actionsClosed]: !open })}
Expand Down Expand Up @@ -227,7 +232,7 @@ SpeedDial.propTypes = {
/**
* Transition component.
*/
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
TransitionComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
Expand All @@ -244,7 +249,7 @@ SpeedDial.propTypes = {

SpeedDial.defaultProps = {
hidden: false,
transition: Zoom,
TransitionComponent: Zoom,
transitionDuration: {
enter: duration.enteringScreen,
exit: duration.leavingScreen,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Dialog/Dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface DialogProps
fullWidth?: boolean;
maxWidth?: 'xs' | 'sm' | 'md' | false;
PaperProps?: Partial<PaperProps>;
transition?: React.ReactType;
TransitionComponent?: React.ReactType;
transitionDuration?: TransitionProps['timeout'];
}

Expand Down
10 changes: 5 additions & 5 deletions packages/material-ui/src/Dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function Dialog(props) {
onExiting,
open,
PaperProps,
transition: TransitionProp,
TransitionComponent,
transitionDuration,
TransitionProps,
...other
Expand All @@ -95,7 +95,7 @@ function Dialog(props) {
role="dialog"
{...other}
>
<TransitionProp
<TransitionComponent
appear
in={open}
timeout={transitionDuration}
Expand All @@ -119,7 +119,7 @@ function Dialog(props) {
>
{children}
</Paper>
</TransitionProp>
</TransitionComponent>
</Modal>
);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ Dialog.propTypes = {
/**
* Transition component.
*/
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
TransitionComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
Expand All @@ -235,7 +235,7 @@ Dialog.defaultProps = {
fullScreen: false,
fullWidth: false,
maxWidth: 'sm',
transition: Fade,
TransitionComponent: Fade,
transitionDuration: { enter: duration.enteringScreen, exit: duration.leavingScreen },
};

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Popover/Popover.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface PopoverProps
PaperProps?: Partial<PaperProps>;
role?: string;
transformOrigin?: PopoverOrigin;
transition?: React.ReactType;
TransitionComponent?: React.ReactType;
transitionDuration?: TransitionProps['timeout'] | 'auto';
}

Expand Down
10 changes: 5 additions & 5 deletions packages/material-ui/src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Popover extends React.Component {
PaperProps,
role,
transformOrigin,
transition: TransitionProp,
TransitionComponent,
transitionDuration,
TransitionProps,
...other
Expand All @@ -304,7 +304,7 @@ class Popover extends React.Component {

return (
<Modal container={container} open={open} BackdropProps={{ invisible: true }} {...other}>
<TransitionProp
<TransitionComponent
appear
in={open}
onEnter={this.handleEnter}
Expand All @@ -328,7 +328,7 @@ class Popover extends React.Component {
<EventListener target="window" onResize={this.handleResize} />
{children}
</Paper>
</TransitionProp>
</TransitionComponent>
</Modal>
);
}
Expand Down Expand Up @@ -472,7 +472,7 @@ Popover.propTypes = {
/**
* Transition component.
*/
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
TransitionComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* Set to 'auto' to automatically calculate transition time based on height.
*/
Expand All @@ -499,7 +499,7 @@ Popover.defaultProps = {
vertical: 'top',
horizontal: 'left',
},
transition: Grow,
TransitionComponent: Grow,
transitionDuration: 'auto',
};

Expand Down
10 changes: 5 additions & 5 deletions packages/material-ui/src/Snackbar/Snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Snackbar extends React.Component {
open,
resumeHideDuration,
SnackbarContentProps,
transition: TransitionProp,
TransitionComponent,
transitionDuration,
TransitionProps,
...other
Expand Down Expand Up @@ -236,7 +236,7 @@ class Snackbar extends React.Component {
onFocus={disableWindowBlurListener ? undefined : this.handleResume}
onBlur={disableWindowBlurListener ? undefined : this.handlePause}
/>
<TransitionProp
<TransitionComponent
appear
in={open}
onEnter={onEnter}
Expand All @@ -252,7 +252,7 @@ class Snackbar extends React.Component {
{children || (
<SnackbarContent message={message} action={action} {...SnackbarContentProps} />
)}
</TransitionProp>
</TransitionComponent>
</div>
</ClickAwayListener>
);
Expand Down Expand Up @@ -370,7 +370,7 @@ Snackbar.propTypes = {
/**
* Transition component.
*/
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
TransitionComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
Expand All @@ -391,7 +391,7 @@ Snackbar.defaultProps = {
horizontal: 'center',
},
disableWindowBlurListener: false,
transition: Slide,
TransitionComponent: Slide,
transitionDuration: {
enter: duration.enteringScreen,
exit: duration.leavingScreen,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Stepper/StepContent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface StepContentProps
last?: boolean;
optional?: boolean;
orientation?: Orientation;
transition?: React.ComponentType<TransitionProps>;
TransitionComponent?: React.ComponentType<TransitionProps>;
transitionDuration?: TransitionProps['timeout'] | 'auto';
}

Expand Down
10 changes: 5 additions & 5 deletions packages/material-ui/src/Stepper/StepContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function StepContent(props) {
last,
optional,
orientation,
transition: Transition,
TransitionComponent,
transitionDuration,
TransitionProps,
...other
Expand All @@ -45,15 +45,15 @@ function StepContent(props) {

return (
<div className={classNames(classes.root, { [classes.last]: last }, className)} {...other}>
<Transition
<TransitionComponent
in={active}
className={classes.transition}
timeout={transitionDuration}
unmountOnExit
{...TransitionProps}
>
{children}
</Transition>
</TransitionComponent>
</div>
);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ StepContent.propTypes = {
/**
* Collapse component.
*/
transition: PropTypes.func,
TransitionComponent: PropTypes.func,
/**
* Adjust the duration of the content expand transition.
* Passed as a property to the transition component.
Expand All @@ -120,7 +120,7 @@ StepContent.propTypes = {
};

StepContent.defaultProps = {
transition: Collapse,
TransitionComponent: Collapse,
transitionDuration: 'auto',
};

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Table/TablePagination.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface LabelDisplayedRowsArgs {

export interface TablePaginationProps
extends StandardProps<TablePaginationBaseProps, TablePaginationClassKey> {
Actions?: React.ReactType<TablePaginationBaseProps>;
ActionsComponent?: React.ReactType<TablePaginationBaseProps>;
backIconButtonProps?: Partial<IconButtonProps>;
component?: React.ReactType<TablePaginationBaseProps>;
count: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui/src/Table/TablePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TablePagination extends React.Component {

render() {
const {
Actions,
ActionsComponent,
backIconButtonProps,
classes,
colSpan: colSpanProp,
Expand Down Expand Up @@ -134,7 +134,7 @@ class TablePagination extends React.Component {
page,
})}
</Typography>
<Actions
<ActionsComponent
className={classes.actions}
backIconButtonProps={backIconButtonProps}
count={count}
Expand All @@ -154,7 +154,7 @@ TablePagination.propTypes = {
* The component used for displaying the actions.
* Either a string to use a DOM element or a component.
*/
Actions: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
ActionsComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* Properties applied to the back arrow `IconButton` component.
*/
Expand Down Expand Up @@ -222,7 +222,7 @@ TablePagination.propTypes = {
};

TablePagination.defaultProps = {
Actions: TablePaginationActions,
ActionsComponent: TablePaginationActions,
component: TableCell,
labelDisplayedRows: ({ from, to, count }) => `${from}-${to} of ${count}`,
labelRowsPerPage: 'Rows per page:',
Expand Down

0 comments on commit 916f8a3

Please sign in to comment.