Giter Site home page Giter Site logo

elrumordelaluz / svg-spreact Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 6.0 698 KB

Create svg sprites using svgson and react

Home Page: https://svgsprit.es

JavaScript 100.00%
svg svgo svg-sprites svg-icons svg-sprite svg-files react icons svgson svg-spreact

svg-spreact's Introduction

SVG Spreact

Create an SVG Sprites using svgson and react

Install

yarn add svg-spreact

Usage

const svgSpreact = require('svg-spreact')

const icons = [
  `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>Add</title>
    <path data-name="layer1"
    fill="none" stroke="#202020" stroke-miterlimit="10" stroke-width="2" d="M32 16v32m16-16H16"
    stroke-linejoin="round" stroke-linecap="round"></path>
  </svg>`,
  `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>Checkmark</title>
    <path data-name="layer1"
    fill="none" stroke="#202020" stroke-miterlimit="10" stroke-width="2" d="M16 33l11 11 21-22"
    stroke-linejoin="round" stroke-linecap="round"></path>
  </svg>`
]

svgSpreact(icons).then(({ defs, refs }) => {
  console.log(defs) // <symbol>
  console.log(refs) // <use>
})

API

svgSpreact(input, [options])

input

Type: Array

options

Type: Object

  • tidy output prettyfied (Boolean) default: true
  • optimize output optimizde with svgo (Boolean) default: true
  • svgoConfig SVGO plugins configuration (Object) default
  • processId function for customize Icons ids (Function) default: (n) => 'Icon_' + n
  • className classname/s to add on each <use> element (String) default: ''

Example

Take a look into this example reading a folder with Icons

Related

svg-spreact-cli CLI version

web-app

[POST] endpoint | docs

svg-spreact's People

Contributors

dependabot[bot] avatar elrumordelaluz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.