0.7.3 • Published 7 years ago

svg-json-parser v0.7.3

Weekly downloads
4
License
ISC
Repository
-
Last release
7 years ago

svg-json-parser

this App Converts SVG Element to JSON.

npm install svg-json-parser;

var svgParser = require("svg-json-parser");

app.json.lib('lib.svg','Output file path Without .json');

{ node:"svg", id:"svglib", children:[ {"node":"g",id:apple,children:{node:"path",attr:{d:"M10..",fill="red"}},.....}, {"node":"path",id:orange,attr:{fill="#FF3456"}}, ..... ] }

<h6>lib method </h6>

returns SVG elements as the properties of the object, will be included only elements with ID attribute; only direct children need id Attributes. and can be passed only: SVG or SVG "defs" element.

```html
<svg>
  // it not, no id  <path  d="M0..." />
    <g id="work">
        <path d="M0..." />
        <path d="M0..." />
    </g>
    <path id="gmail" d="M0..." />
    .......
</svg>

var  svglib = svgParser.json.lib();
{
  work:{
    node:"g",
    id:"work",
    children:[
      {"node":"path",attr{"d":"M0..."}},
      {"node":"path",attr{"d":"M0..."}}
    ]
  },
  gmail:{
    node:"path",
    id:"gmail",
    attr{"d":"M0..."}}
  },.....
}
class Icon extends React.Component {
  render(){
    var s = svglib[this.props.id];
    if(s.node=="g"){return (<g >{sv.children.map((e,i)=><path  d={e.d} fill={e.fill} key={i} ></path>)}</g>);}
    else if(s.node=="path"){return (<path  d={s.d} fill={s.fill} ></path>);}
  }
}

<Icon id='work' />
0.7.3

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.8

8 years ago

0.6.7

8 years ago

0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago