Converts your SVG files into React Components wrapped with @s-ui/atom-icon.
Features:
- Building the components
- Showing up a demo locally
$ npm i -SE @s-ui/svg
Add bundling scripts to your package.json
{
"name": "my-awesome-package",
"version": "1.0.0",
"scripts": {
"prepare": "sui-svg build",
"start": "npm run prepare && sui-svg demo"
}
}
A src
folder with all the .svg
files to be converted inside.
A lib
folder with the generated components will be created/overridden.
index.js
will be generated inside the lib folder, each component should be imported independently for performance reasons.
import YourIcon from 'your-svg-repo/lib/YourIcon'
const YourAwesomeComponent = () =>
<div>
<YourIcon />
<p>Awesome text/<p>
</div>
Also, keep in mind, you need to import the needed styles for the icons at least once in your app:
@import "your-svg-repo/lib/index";
Every icon svg will be wrapped using an <AtomIcon>
that means you could use all the props accepted by the component.
The wrapped code is minimal, in order to avoid performance penalties. You could check it here.