Skip to content

Commit

Permalink
fix data props (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresAil authored Mar 27, 2024
1 parent ae66e73 commit e68c124
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
5 changes: 2 additions & 3 deletions .svgrrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
};
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@raresail/react-ionicons",
"version": "1.1.0",
"version": "1.1.1",
"repository": "[email protected]:RaresAil/react-ionicons.git",
"author": "RaresAil <[email protected]>",
"license": "MIT",
Expand Down
8 changes: 0 additions & 8 deletions src/types.ts

This file was deleted.

8 changes: 5 additions & 3 deletions templates/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<SVGProps<SVGSVGElement>, 'fill' | 'stroke'>) {
return ${jsx};
}
Expand Down

0 comments on commit e68c124

Please sign in to comment.