diff --git a/.svgrrc.js b/.svgrrc.js index b774134..7ba86b7 100644 --- a/.svgrrc.js +++ b/.svgrrc.js @@ -4,11 +4,10 @@ module.exports = { template: require('./templates/svg.js'), typescript: true, outDir: path.join('src', 'icons'), + expandProps: 'end', memo: true, icon: true, svgProps: { - className: '{className}', - fill: 'currentColor', - style: '{style}' + fill: 'currentColor' } }; diff --git a/README.md b/README.md index a9e6621..c187ece 100644 --- a/README.md +++ b/README.md @@ -33,22 +33,21 @@ function Component() { fontSize: '20px', color: 'red' }} - // If you need to add extra props use - svgProps={{}} // For icons that use strokeWidth you can change it like this strokeWidth={32} // to add a class name to the svg className="your class" + // All the props are forwarded to the SVG component /> ); } ``` -### Properties +### Props -| Name | Type | Default | -| ----------- | ------------- | -------- | -| svgProps | SVGProps | {} | -| style | CSSProperties | {} | -| strokeWidth | number | 32 or 16 | -| className | string | | +| Name | Type | Default | +| ----------- | ---------------- | -------- | +| style | CSSProperties | {} | +| strokeWidth | number \| string | 32 or 16 | +| className | string | | +| ... | Other SVG Props | | diff --git a/package.json b/package.json index 99e352c..8b26551 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@raresail/react-ionicons", - "version": "1.1.0", + "version": "1.1.1", "repository": "git@github.com:RaresAil/react-ionicons.git", "author": "RaresAil ", "license": "MIT", diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index dbbcdd3..0000000 --- a/src/types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { CSSProperties } from 'react'; - -export interface IonIconProps { - svgProps?: Omit, 'className' | 'style'>; - style?: CSSProperties; - strokeWidth?: number; - className?: string; -} diff --git a/templates/svg.js b/templates/svg.js index 1005731..5b9f0b8 100644 --- a/templates/svg.js +++ b/templates/svg.js @@ -2,11 +2,13 @@ const propTypesTemplate = ( { /* imports, */ interfaces, componentName, jsx, exports }, { tpl } ) => { - return tpl`import { memo } from 'react'; -import type { IonIconProps } from '../types'; + return tpl`import { SVGProps, memo } from 'react'; ${interfaces} -function ${componentName}({ className, strokeWidth, style, svgProps: props }: IonIconProps) { +function ${componentName}({ + strokeWidth, + ...props +}: Omit, 'fill' | 'stroke'>) { return ${jsx}; }