GitXplorerGitXplorer
M

react-from-svg

public
60 stars
4 forks
5 issues

Commits

List of commits on branch main.
Verified
34c9934f58954917cae45c654076a3d513abc934

6.0.0

MMoOx committed 2 years ago
Verified
d8b166b6297abb129bdf876acae2619251b21219

Add `--with-native-for-typescript` option for `react-native-svg` with TypeScript

MMoOx committed 2 years ago
Verified
bed9dbb40fab1ed64f1b507852e74ca2f51ddb32

Fix CI badge

MMoOx committed 2 years ago
Verified
4bc5e7a4a0acebd3c349935f1a41f1f114b45f89

5.1.3

MMoOx committed 2 years ago
Verified
b5977b50603aebb7d602024f8df4b7dc942fba20

Handle gradientTransform for ReScript

MMoOx committed 2 years ago
Verified
c2b82fd16df4eccf1b22c7c460d6158843d7066e

Handle float without leading 0 for ReScript

MMoOx committed 2 years ago

README

The README file for this repository.

React from SVG

Sponsoring button

GitHub package.json version npm downloads GitHub Workflow Status License
GitHub followers Twitter Follow Sponsor my work

Transform SVG files into React components, Native and/or Web, JavaScript and rescriptML. Without shitload of dependencies.

Install

npm install react-from-svg

# or

yarn add react-from-svg

Usage

react-from-svg --help

Usage
  $ react-from-svg <sourcePath> <outputPath> [--with-native|--with-web]

Options
  --with-native, -rn                    Output code for react-native-svg
  --with-native-for-typescript, -rnts   Output code for react-native-svg with TypeScript

  --with-web, -rnw                      Output code for DOM. If --with-native is also used, will be output as .web.js files
  --with-native-for-rescript, -rrn      Output code for @rescript-react-native/svg
  --with-web-for-rescript, -rrnw        Output code for @rescript/react
  --remove-fill, -rf                    Remove all 'fill' properties from SVGs, convenient for icons
  --remove-stroke, -rs                  Remove all 'stroke' properties from SVGs, convenient for icons
  --commonjs, -cjs                      Export as commonjs instead of es6 import/export

Example
  $ react-from-svg assets/svgs src/Svgs --with-native --remove-fill

Generated components will have the following props that you can inject to the SVG components:

  • width
  • height
  • fill (if you use --remove-fill)
  • stroke (if you use --remove-stroke)

⚠️ To see what you can expect from the transformations, check our snapshots 👀

Requirements

--with-web

Need you to have:

--with-web-for-rescript

Need you to have:

--with-native

Need you to have:

--with-native-for-rescript

In addition to --with-native requirements, you need to have:

Ensure as that this dependencies are in the bs-dependencies of your bsconfig.json.