@iconify/react
Advanced tools
Comparing version 0.0.1 to 0.0.2
18
build.js
@@ -27,2 +27,5 @@ /** | ||
// Ignore errors | ||
let ignoreErrors = false; | ||
// Source directory | ||
@@ -302,3 +305,3 @@ let sourceDir = null; | ||
if (log) { | ||
console.log('[' + collection.prefix() + ']: Exported ' + icons + ' icons' + (aliases ? ', ' + aliases + ' aliases.' : '')); | ||
console.log('[' + collection.prefix() + '] Exported ' + icons + ' icons' + (aliases ? ', ' + aliases + ' aliases.' : '')); | ||
} | ||
@@ -442,2 +445,6 @@ return true; | ||
case '--ignore-errors': | ||
ignoreErrors = true; | ||
break; | ||
case '--silent': | ||
@@ -509,2 +516,5 @@ case '--no-log': | ||
if (!Object.keys(files).length) { | ||
if (ignoreErrors) { | ||
return; | ||
} | ||
throw new Error('No JSON files to parse.'); | ||
@@ -523,2 +533,5 @@ } | ||
if (!collection.loadFromFile(source)) { | ||
if (ignoreErrors) { | ||
return; | ||
} | ||
throw new Error('Error loading collection from ' + source); | ||
@@ -529,2 +542,5 @@ } | ||
if (validatePrefix) { | ||
if (ignoreErrors) { | ||
return; | ||
} | ||
throw new Error('Collection loaded from ' + source + ' has prefix "' + collection.prefix() + '", expected "' + prefix + '"'); | ||
@@ -531,0 +547,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"license": "MIT", | ||
@@ -18,9 +18,7 @@ "bugs": "https://github.com/iconify-design/iconify-react/issues", | ||
"main": "icon.js", | ||
"devDependencies": { | ||
"dependencies": { | ||
"@iconify/json-tools": "^1.0.3", | ||
"react": "^16.7.0" | ||
}, | ||
"optionalDependencies": { | ||
"react": "^16.7.0", | ||
"@iconify/json": "^1.0.48" | ||
} | ||
} |
@@ -40,3 +40,6 @@ # Iconify for React | ||
## Importing icons | ||
Import format for each icon is "@iconify/react/{prefix}/{icon}" where {prefix} is collection prefix, {icon} is icon name. | ||
Import imports JSON data for icon, to render it use Icon or InlineIcon component. | ||
@@ -46,2 +49,39 @@ | ||
You can use any name for imported icon. For example: | ||
``` | ||
import notCat from "@iconify/react/noto-v1/dog"; | ||
``` | ||
## Build script | ||
You can use build script with custom icon sets that have been converted to [Iconify JSON format](https://iconify.design/docs/json-icon-format/). | ||
Add your own JSON files to directory "json", run build script from command line: | ||
``` | ||
node node_modules/@iconify/react/build --source json --target icons | ||
``` | ||
where "json" is directory where JSON files are, "icons" is directory where components will be exported. | ||
There are more command line options: | ||
* --skip foo,bar: list of prefixes to ignore. | ||
* --filter foo,bar: list of prefixes to include. If set, all other prefixes will be ignored | ||
* --file json/custom.json: file to parse | ||
* --files json/custom.json,json/custom2.json: list of additional files to parse, separated by comma. | ||
* --package @iconify/json: parse JSON files in installed package. Use in combination with --dir if files are in sub-directory (see package.json for example). | ||
* --source json: directory where JSON files are located. | ||
* --dir json: sub-directory where JSON files are located, used in combination with --package (see package.json for example). | ||
* --target icons: directory where to save components. Build script will also create sub-directories with prefixes, so for example fa-home will be in icons/fa/home.js | ||
* --no-cleanup: prevent build script from deleting old files. By default everything in target directory is removed to clean up old build data, this will prevent clean up. | ||
* --silent: prevent build script from logging export process. | ||
* --ignore-prefix: do not validate prefixes. By default build script requires filenames to match prefixes, so for example "fa-solid" should be in "fa-solid.json", adding this to command line will prevent that check. | ||
* --ignore-errors: do not stop on error. This applies only to invalid json files. Script will throw errors even with --ignore-errors when there are bad command line parameters. | ||
Examples: | ||
```node node_modules/@iconify/react/build --source json --target icons | ||
node node_modules/@iconify/react/build --module @iconify/json --dir json --target iconify-icons --filter fa-brands,logos,brandico | ||
node node_modules/@iconify/react/build --module @iconify/json --dir json --target iconify-icons --skip fa-brands,logos,brandico --silent | ||
``` | ||
## License | ||
@@ -48,0 +88,0 @@ |
23849
0
532
92
3
+ Added@iconify/json@^1.0.48
+ Added@iconify/json-tools@^1.0.3
+ Addedreact@^16.7.0
+ Added@iconify/json-tools@1.0.10(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@16.14.0(transitive)
+ Addedreact-is@16.13.1(transitive)