Skip to content

Commit

Permalink
feat: simplified implementation custom Icon svg
Browse files Browse the repository at this point in the history
  • Loading branch information
chornos13 committed Mar 6, 2021
1 parent e380715 commit bcef150
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
15 changes: 0 additions & 15 deletions src/icons/IconArrowLeft.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/icons/IconClose.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/icons/IconClose/Close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/icons/IconClose/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import withCustomIcon from 'icons/withCustomIcon'
import Close from 'icons/IconClose/Close.svg'

const IconClose = withCustomIcon(Close)

export default IconClose
27 changes: 27 additions & 0 deletions src/icons/withCustomIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react'
import Icon, {
CustomIconComponentProps,
IconComponentProps,
} from '@ant-design/icons/lib/components/Icon'

type WithCustomIconProps = Omit<IconComponentProps, 'ref'>
type SvgIcon = React.ComponentType<
CustomIconComponentProps | React.SVGProps<SVGSVGElement>
>

function withCustomIcon(svgIcon: SvgIcon) {
return (props: WithCustomIconProps) => {
const { style, ...otherProps } = props
return (
<Icon
component={svgIcon}
style={{
...style,
}}
{...otherProps}
/>
)
}
}

export default withCustomIcon
3 changes: 0 additions & 3 deletions src/svgs/ArrowLeft.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/svgs/Close.svg

This file was deleted.

0 comments on commit bcef150

Please sign in to comment.