icons-to-react-svg
v0.0.2
Published
Icons to React SVG / Font-family / Experimental pseudo-element
Readme
Icons to React SVG / Font-family / Experimental pseudo-element
This package is for creating react component with svg icon, or font-family or icons based on :before pseudo-element using one click.
Important
1) Do not use unicode bigger than 1000 (it is not working)!
2) Use underscores in the icon file name!
Installation:
just install it, ie: yarn
Adding new icons:
Add icon into
iconfolderOptional: You can add icon number into
scripts/icons.jsonfile.{[icon_file_name], [unicode (it need to be uniq)].It will produce an icon with this unicode. If you will miss this step script will generate code for you. Everything you'll find in
scripts/icons.jsonfile.Run
yarn buildIt will produce icon components (
libfolder) + experimental pseudo-elements with SVGs (lib/styles.css) + font-family (distfolder) + cleared icons in.icons
PS. For a preview, you can check dist/icons.html in the browser.
Base usage:
1) SVG as component:
import { Add } from 'icons-to-react-svg';
return (
<Add
color={STRING}
size={NUMBER || STRING}
{other props}
/>
)2) Font-family:
- you need to set new icon in you icon file
- you're able to use this icon by unicode, ie:
@include icon(directions, '\e993');
this mixin will create an icon in css .icon-directions and scss placeholder %icon-directions
3) Experimental SVG icons insider :before / :after - for now, it is OFF:
- you need to import styles
lib/styles.cssinto you repo - Icons are working with double dash as prefix ie:
.icon--add- it is using:beforepseudo-element.icon--add-after- it is using:afterpseudo-element
How yarn build works:
- Remove files (files inside
srcand.icons) - Copy
iconfolder into folder.icons - Clean all
.iconsusingsvgo(it is removing useless SVG tags) - Generate react component with SVG in folder
src - Generate experimental styles for using SVG inside pseudo-elements (
src/styles.css) - Generate font-family inside
distfolder - Copy files from
srcintolib - Remove temporary files inside
src
Components
sort_ascending.svg
import { SortAscending } from 'icons-to-react-svg';- unicode:
e007 .icon--sort-ascending:before,.icon--sort-ascending-after:after
sort_descending.svg
import { SortDescending } from 'icons-to-react-svg';- unicode:
e006 .icon--sort-descending:before,.icon--sort-descending-after:after
