Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix data props #3

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "git@github.com:RaresAil/react-ionicons.git",
"author": "RaresAil <rares.ailincai@raresdesigns.com>",
"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