Skip to content

Commit

Permalink
[core] Remove createSvgIcon duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Mar 27, 2020
1 parent 51f16ae commit dce63d8
Show file tree
Hide file tree
Showing 34 changed files with 43 additions and 74 deletions.
7 changes: 2 additions & 5 deletions packages/material-ui-icons/src/utils/createSvgIcon.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
import SvgIcon from '@material-ui/core/SvgIcon';

declare function createSvgIcon(path: React.ReactNode, displayName: string): typeof SvgIcon;

export default createSvgIcon;
export { default } from '@material-ui/core/createSvgIcon';
export * from '@material-ui/core/createSvgIcon';
21 changes: 1 addition & 20 deletions packages/material-ui-icons/src/utils/createSvgIcon.js
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
import React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';

export default function createSvgIcon(path, displayName) {
const Component = React.memo(
React.forwardRef((props, ref) => (
<SvgIcon data-mui-test={`${displayName}Icon`} ref={ref} {...props}>
{path}
</SvgIcon>
)),
);

if (process.env.NODE_ENV !== 'production') {
Component.displayName = `${displayName}Icon`;
}

Component.muiName = SvgIcon.muiName;

return Component;
}
export { default } from '@material-ui/core/createSvgIcon';
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Star.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
5 changes: 5 additions & 0 deletions packages/material-ui/src/createSvgIcon/createSvgIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import SvgIcon from '@material-ui/core/SvgIcon';

declare function createSvgIcon(path: React.ReactNode, displayName: string): typeof SvgIcon;

export default createSvgIcon;
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';
import React from 'react';
import SvgIcon from '../SvgIcon';

/**
* Private module reserved for @material-ui/x packages.
*/
export default function createSvgIcon(path, displayName) {
const Component = React.memo(
React.forwardRef((props, ref) => (
Expand Down
2 changes: 2 additions & 0 deletions packages/material-ui/src/createSvgIcon/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './createSvgIcon';
export * from './createSvgIcon';
1 change: 1 addition & 0 deletions packages/material-ui/src/createSvgIcon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './createSvgIcon';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Cancel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/CheckBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/CheckCircle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/MoreHoriz.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Person.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Warning.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../createSvgIcon';

/**
* @ignore - internal component.
Expand Down
20 changes: 0 additions & 20 deletions packages/material-ui/src/internal/svg-icons/createSvgIcon.js

This file was deleted.

0 comments on commit dce63d8

Please sign in to comment.