0.7.3 • Published 9 years ago

svg-json-parser v0.7.3

Weekly downloads
4
License
ISC
Repository
-
Last release
9 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

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.8

10 years ago

0.6.7

10 years ago

0.6.5

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago