diff --git a/README.md b/README.md
index ec302541..84f07895 100644
--- a/README.md
+++ b/README.md
@@ -5,11 +5,9 @@
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
-[![version][version-badge]][package]
-[![MIT License][license-badge]][LICENSE]
+[![version][version-badge]][package] [![MIT License][license-badge]][license]
-[![PRs Welcome][prs-badge]][prs]
-[![Chat][chat-badge]][chat]
+[![PRs Welcome][prs-badge]][prs] [![Chat][chat-badge]][chat]
[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
@@ -47,13 +45,15 @@ npm install svgr
```
**Run SVGR**
+
```sh
svgr --no-semi --icon --replace-attr-value "#063855=currentColor" icon.svg
```
**Output**
+
```js
-import React from "react"
+import React from 'react'
const SvgComponent = props => (
`
-svgr(svgCode, { prettier: false }).then(jsCode => {
- console.log(jsCode)
-})
+svgr(svgCode, { prettier: false, componentName: 'MyComponent' }).then(
+ jsCode => {
+ console.log(jsCode)
+ },
+)
```
## Webpack usage
@@ -198,10 +202,10 @@ module.exports = {
rules: [
{
test: /\.svg$/,
- use: ['babel-loader', 'svgr/lib/webpack']
- }
- ]
- }
+ use: ['babel-loader', 'svgr/lib/webpack'],
+ },
+ ],
+ },
}
```
@@ -218,134 +222,163 @@ module.exports = {
{
loader: 'svgr/lib/webpack',
options: {
- svgo: false
- }
+ svgo: false,
+ },
},
- ]
- }
- ]
- }
+ ],
+ },
+ ],
+ },
}
```
## Options
-SVGR ships with a handful of customizable options, usable in both the CLI and API.
+SVGR ships with a handful of customizable options, usable in both the CLI and
+API.
### SVGO
-Use [SVGO](https://github.com/svg/svgo/) to optimize SVG code before transforming
-it into a component.
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-svgo` | `svgo: `
+Use [SVGO](https://github.com/svg/svgo/) to optimize SVG code before
+transforming it into a component.
+
+| Default | CLI Override | API Override |
+| ------- | ------------ | -------------- |
+| `true` | `--no-svgo` | `svgo: ` |
### Prettier
-Use [Prettier](https://github.com/prettier/prettier) to format JavaScript code output.
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-prettier` | `prettier: `
+Use [Prettier](https://github.com/prettier/prettier) to format JavaScript code
+output.
+
+| Default | CLI Override | API Override |
+| ------- | --------------- | ------------------ |
+| `true` | `--no-prettier` | `prettier: ` |
### Template
-Specify a template file (CLI) or a template function (API) to use. For an example of template, see [the default one](src/transforms/wrapIntoComponent.js).
-Default | CLI Override | API Override
---------|--------------|-------------
-[`wrapIntoComponent`](src/transforms/wrapIntoComponent.js) | `--template` | `template: `
+Specify a template file (CLI) or a template function (API) to use. For an
+example of template, see [the default one](src/transforms/wrapIntoComponent.js).
+
+| Default | CLI Override | API Override |
+| ---------------------------------------------------------- | ------------ | ------------------ |
+| [`wrapIntoComponent`](src/transforms/wrapIntoComponent.js) | `--template` | `template: ` |
### Expand props
+
All properties given to component will be forwarded on SVG tag.
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-expand-props` | `expandProps: `
+| Default | CLI Override | API Override |
+| ------- | ------------------- | --------------------- |
+| `true` | `--no-expand-props` | `expandProps: ` |
### Icon
-Replace SVG "width" and "height" value by "1em" in order to make SVG size inherits from text size. Also remove title.
-Default | CLI Override | API Override
---------|--------------|-------------
-`false` | `--icon` | `icon: `
+Replace SVG "width" and "height" value by "1em" in order to make SVG size
+inherits from text size. Also remove title.
+
+| Default | CLI Override | API Override |
+| ------- | ------------ | -------------- |
+| `false` | `--icon` | `icon: ` |
### ViewBox
+
Setting this to `false` will remove the viewBox property.
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-view-box` | `viewBox: `
+| Default | CLI Override | API Override |
+| ------- | --------------- | ----------------- |
+| `true` | `--no-view-box` | `viewBox: ` |
### Replace attribute value
-Replace an attribute value by an other. The main usage of this option is to change
-an icon color to "currentColor" in order to inherit from text color.
-Default | CLI Override | API Override
---------|--------------|-------------
-`[]` | `--replace-attr-value ` | `replaceAttrValues: `
+Replace an attribute value by an other. The main usage of this option is to
+change an icon color to "currentColor" in order to inherit from text color.
+
+| Default | CLI Override | API Override |
+| ------- | -------------------------------- | ------------------------------- |
+| `[]` | `--replace-attr-value ` | `replaceAttrValues: ` |
### Precision
-Set number of digits in the fractional part. See [SVGO](https://github.com/svg/svgo).
-Default | CLI Override | API Override
---------|--------------|-------------
-`3` | `--precision ` | `precision: `
+Set number of digits in the fractional part. See
+[SVGO](https://github.com/svg/svgo).
+
+| Default | CLI Override | API Override |
+| ------- | ------------------- | ------------------ |
+| `3` | `--precision ` | `precision: ` |
### Title
-Remove the title from SVG. See [SVGO `removeTitle` plugin](https://github.com/svg/svgo).
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-title` | `title: `
+Remove the title from SVG. See
+[SVGO `removeTitle` plugin](https://github.com/svg/svgo).
+
+| Default | CLI Override | API Override |
+| ------- | ------------ | --------------- |
+| `true` | `--no-title` | `title: ` |
### Tab Width
-Specify the number of spaces per indentation-level. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#tab-width).
-Default | CLI Override | API Override
---------|--------------|-------------
- `2` | `--tab-width ` | `tabWidth: `
+Specify the number of spaces per indentation-level. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#tab-width).
+
+| Default | CLI Override | API Override |
+| ------- | ------------------- | ----------------- |
+| `2` | `--tab-width ` | `tabWidth: ` |
### Tabs
-Indent lines with tabs instead of spaces. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#tabs).
-Default | CLI Override | API Override
---------|--------------|-------------
-`false` | `--use-tabs` | `useTabs: `
+Indent lines with tabs instead of spaces. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#tabs).
+
+| Default | CLI Override | API Override |
+| ------- | ------------ | ----------------- |
+| `false` | `--use-tabs` | `useTabs: ` |
### Semicolons
-Print semicolons at the ends of statements. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#semicolons).
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-semi` | `semi: `
+Print semicolons at the ends of statements. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#semicolons).
+
+| Default | CLI Override | API Override |
+| ------- | ------------ | -------------- |
+| `true` | `--no-semi` | `semi: ` |
### Quotes
-Use single quotes instead of double quotes. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#quotes).
-Default | CLI Override | API Override
---------|--------------|-------------
-`false` | `--single-quote` | `singleQuote: `
+Use single quotes instead of double quotes. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#quotes).
+
+| Default | CLI Override | API Override |
+| ------- | ---------------- | --------------------- |
+| `false` | `--single-quote` | `singleQuote: ` |
### Trailing Commas
-Print trailing commas wherever possible when multi-line. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#trailing-commas).
-Default | CLI Override | API Override
---------|--------------|-------------
-`"none"` | --trailing-comma
| trailingComma: ""
+Print trailing commas wherever possible when multi-line. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#trailing-commas).
+
+| Default | CLI Override | API Override |
+| -------- | ------------------------------------------------------ | ------------------------------------------------------ |
+| `"none"` | --trailing-comma
| trailingComma: ""
|
### Bracket Spacing
-Print spaces between brackets in object literals. See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#bracket-spacing).
-Default | CLI Override | API Override
---------|--------------|-------------
-`true` | `--no-bracket-spacing` | `bracketSpacing: `
+Print spaces between brackets in object literals. See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#bracket-spacing).
+
+| Default | CLI Override | API Override |
+| ------- | ---------------------- | ------------------------ |
+| `true` | `--no-bracket-spacing` | `bracketSpacing: ` |
### JSX Brackets
+
Put the `>` of a multi-line JSX element at the end of the last line instead of
-being alone on the next line (does not apply to self closing elements). See [Prettier](https://github.com/prettier/prettier/blob/master/README.md#jsx-brackets).
+being alone on the next line (does not apply to self closing elements). See
+[Prettier](https://github.com/prettier/prettier/blob/master/README.md#jsx-brackets).
-Default | CLI Override | API Override
---------|--------------|-------------
-`false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: `
+| Default | CLI Override | API Override |
+| ------- | ------------------------- | ---------------------------- |
+| `false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: ` |
## Other projects
@@ -354,42 +387,42 @@ fulfills my use cases.
Using raw node:
-- [svg-to-react](https://github.com/publitas/svg-to-react)
-- [svg-2-react-isvg](https://github.com/quirinpa/svg-2-react-isvg)
-- [svg-to-component](https://github.com/egoist/svg-to-component)
-- [svg-react-transformer](https://github.com/mapbox/svg-react-transformer)
-- [svg-to-react-k](https://github.com/andgandolfi/svg-to-react-k)
+* [svg-to-react](https://github.com/publitas/svg-to-react)
+* [svg-2-react-isvg](https://github.com/quirinpa/svg-2-react-isvg)
+* [svg-to-component](https://github.com/egoist/svg-to-component)
+* [svg-react-transformer](https://github.com/mapbox/svg-react-transformer)
+* [svg-to-react-k](https://github.com/andgandolfi/svg-to-react-k)
Using command line:
-- [svg-to-react-cli](https://github.com/goopscoop/svg-to-react-cli)
-- [svg2react](https://github.com/meriadec/svg2react)
-- [svg-react-transformer-writer](https://github.com/mapbox/svg-react-transformer-writer)
-- [react-svg-converter](https://github.com/joshblack/react-svg-converter)
+* [svg-to-react-cli](https://github.com/goopscoop/svg-to-react-cli)
+* [svg2react](https://github.com/meriadec/svg2react)
+* [svg-react-transformer-writer](https://github.com/mapbox/svg-react-transformer-writer)
+* [react-svg-converter](https://github.com/joshblack/react-svg-converter)
Or using a Webpack loader:
-- [svg-react-loader](https://github.com/jhamlet/svg-react-loader)
-- [svg-react-transformer-loader](https://github.com/mapbox/svg-react-transformer-loader)
+* [svg-react-loader](https://github.com/jhamlet/svg-react-loader)
+* [svg-react-transformer-loader](https://github.com/mapbox/svg-react-transformer-loader)
Or using a browserify loader:
-- [svg-reactify](https://github.com/coma/svg-reactify)
+* [svg-reactify](https://github.com/coma/svg-reactify)
Or using gulp / grunt plugin:
-- [gulp-svg-to-react](https://github.com/marvin1023/gulp-svg-to-react)
+* [gulp-svg-to-react](https://github.com/marvin1023/gulp-svg-to-react)
Or at runtime:
-- [svg-react](https://github.com/tonis2/svg-react)
-- [react-isvg-loader](https://github.com/quirinpa/react-isvg-loader/)
-- [react-svg-inline](https://github.com/MoOx/react-svg-inline)
+* [svg-react](https://github.com/tonis2/svg-react)
+* [react-isvg-loader](https://github.com/quirinpa/react-isvg-loader/)
+* [react-svg-inline](https://github.com/MoOx/react-svg-inline)
Or using grunt:
-- [grunt-svg-react-component](https://github.com/okcoker/grunt-svg-react-component)
-- [svg-inline-react](https://github.com/sairion/svg-inline-react)
+* [grunt-svg-react-component](https://github.com/okcoker/grunt-svg-react-component)
+* [svg-inline-react](https://github.com/sairion/svg-inline-react)
# License
diff --git a/package.json b/package.json
index 7b1320a3..f1ae3630 100644
--- a/package.json
+++ b/package.json
@@ -24,18 +24,18 @@
"babel-preset-react": "^6.24.1",
"codecov": "^3.0.0",
"conventional-github-releaser": "^2.0.0",
- "eslint": "^4.11.0",
+ "eslint": "^4.12.0",
"eslint-config-airbnb-base": "^12.0.1",
- "eslint-config-prettier": "^2.8.0",
+ "eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"jest": "^21.2.1",
- "react": "^16.1.1",
+ "react": "^16.2.0",
"standard-version": "^4.2.0",
"webpack": "^3.6.0"
},
"dependencies": {
"chalk": "^2.1.0",
- "commander": "^2.12.1",
+ "commander": "^2.12.2",
"glob": "^7.1.2",
"h2x-core": "^0.1.6",
"h2x-plugin-jsx": "^0.1.6",
diff --git a/yarn.lock b/yarn.lock
index ec579485..169b32bc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1259,9 +1259,9 @@ commander@^2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"
-commander@^2.12.1:
- version "2.12.1"
- resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.1.tgz#468635c4168d06145b9323356d1da84d14ac4a7a"
+commander@^2.12.2:
+ version "2.12.2"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"
commondir@^1.0.1:
version "1.0.1"
@@ -1715,12 +1715,11 @@ doctrine@1.5.0:
esutils "^2.0.2"
isarray "^1.0.0"
-doctrine@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63"
+doctrine@^2.0.2:
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075"
dependencies:
esutils "^2.0.2"
- isarray "^1.0.0"
dom-serializer@0:
version "0.1.0"
@@ -1915,9 +1914,9 @@ eslint-config-airbnb-base@^12.0.1:
dependencies:
eslint-restricted-globals "^0.1.1"
-eslint-config-prettier@^2.8.0:
- version "2.8.0"
- resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.8.0.tgz#929861a11de0249677686eba908118175d1a26bc"
+eslint-config-prettier@^2.9.0:
+ version "2.9.0"
+ resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3"
dependencies:
get-stdin "^5.0.1"
@@ -1961,9 +1960,9 @@ eslint-scope@^3.7.1:
esrecurse "^4.1.0"
estraverse "^4.1.1"
-eslint@^4.11.0:
- version "4.11.0"
- resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.11.0.tgz#39a8c82bc0a3783adf5a39fa27fdd9d36fac9a34"
+eslint@^4.12.0:
+ version "4.12.0"
+ resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.12.0.tgz#a7ce78eba8cc8f2443acfbbc870cc31a65135884"
dependencies:
ajv "^5.3.0"
babel-code-frame "^6.22.0"
@@ -1971,7 +1970,7 @@ eslint@^4.11.0:
concat-stream "^1.6.0"
cross-spawn "^5.1.0"
debug "^3.0.1"
- doctrine "^2.0.0"
+ doctrine "^2.0.2"
eslint-scope "^3.7.1"
espree "^3.5.2"
esquery "^1.0.0"
@@ -1980,7 +1979,7 @@ eslint@^4.11.0:
file-entry-cache "^2.0.0"
functional-red-black-tree "^1.0.1"
glob "^7.1.2"
- globals "^9.17.0"
+ globals "^11.0.1"
ignore "^3.3.3"
imurmurhash "^0.1.4"
inquirer "^3.0.6"
@@ -2414,7 +2413,11 @@ globals@^10.0.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c"
-globals@^9.17.0, globals@^9.18.0:
+globals@^11.0.1:
+ version "11.0.1"
+ resolved "https://registry.yarnpkg.com/globals/-/globals-11.0.1.tgz#12a87bb010e5154396acc535e1e43fc753b0e5e8"
+
+globals@^9.18.0:
version "9.18.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
@@ -4128,9 +4131,9 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
-react@^16.1.1:
- version "16.1.1"
- resolved "https://registry.yarnpkg.com/react/-/react-16.1.1.tgz#d5c4ef795507e3012282dd51261ff9c0e824fe1f"
+react@^16.2.0:
+ version "16.2.0"
+ resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"