icons-to-react-svg
v0.0.2
Published
Icons to React SVG / Font-family / Experimental pseudo-element
Downloads
4
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
icon
folderOptional: You can add icon number into
scripts/icons.json
file.{[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.json
file.Run
yarn build
It will produce icon components (
lib
folder) + experimental pseudo-elements with SVGs (lib/styles.css
) + font-family (dist
folder) + 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.css
into you repo - Icons are working with double dash as prefix ie:
.icon--add
- it is using:before
pseudo-element.icon--add-after
- it is using:after
pseudo-element
How yarn build
works:
- Remove files (files inside
src
and.icons
) - Copy
icon
folder into folder.icons
- Clean all
.icons
usingsvgo
(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
dist
folder - Copy files from
src
intolib
- 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