0.1.4-b3 • Published 3 years ago

react-scripts-svg v0.1.4-b3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-scripts-svg :rocket:

Transform a directory of SVG files into an easily usable React component.

Installation

npm install react-scripts-svg --save-dev
yarn add -D react-scripts-svg

Usage

react-scripts-svg -p src/assets/svg -o src/components -t -d vector

This will take SVG files from directory src/assets/svg and generate files containing the component and SVG data. From the working directory where the command is executed; the generated files will be:

  • src/components/vector/index.tsx - component
  • src/components/vector/types.ts - data, TypeScript types (if -t flag is provided)

Parameters

ParameterDescriptionTypeDefaultRequired
--path, -pPath to directory containing SVG filesstring
--out, -oOutput path (directory will be created)string
--typescript, -tOutput TypeScript filesbooleanfalse
--component, cGenerated React component namestringsvg
--directory, -dGenerated directory namestringSVG
--jsx, -jUse JSX file extensions (.jsx, .tsx)booleantrue
--propTypes, --ptGenerate PropTypes definition for componentbooleanfalse

Usage in package.json

The script below can be run using npm run svg

package.json
{
    "scripts": {
        "svg": "react-scripts-svg -p src/assets/svg -o src/components"
    }
}

Component Usage

This example assumes all default values are used.

src/components/settings-icon/index.ts
import React from "react"
import Icon from "../icon"

export const SettingsIcon = () => (
    <Icon name="settings" className="settings-icon" style={{fill: "red"}}/>
);

Component Props

PropTypeRequired
name*string
classNamestring
styleCSSProperties

* name prop must be one of the strings exported in types.js or types.ts - if using TypeScript this will be enforced.

Assumptions

  • SVG file names must contain only letters or hyphens, such as:
    • settings.svg -> settings
    • alarm-clock.svg -> alarmClock
0.1.4-b3

3 years ago

0.0.40

3 years ago

0.0.41

3 years ago

0.0.42

3 years ago

0.0.43

3 years ago

0.0.37

3 years ago

0.0.38

3 years ago

0.0.39

3 years ago

0.0.36

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.4-b1

3 years ago

0.1.4-b2

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago