0.0.8 • Published 4 years ago

zkt-svg v0.0.8

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

zkt-svg

This is a simple react component that can easily use SVG files;Base on svg-sprite-loader module;

Usage

index.jsx
import React, { Component } from 'react';
import ZktSvg from 'zkt-svg'

export default class Index extends Component {
 render() {
  return (
   <div>
	<ZktSvg className='someClass' svgName='smile' />
	{/* 
	 The svgName value should be same as the svg file name 
	*/}
   </div>
 )}
}
webpack.config.js
module: {
 rules: [
  { 
    test: /\.jsx?$/,
     use: [
	 'babel-loader',
	 'zkt-svg/loader'
     ]
  }]
/* 
  The default directory of svg files is ./src/images; 
  Your project's folder tree should be like this:

 *-src
 * --images
 *  ---smile.svg
 *-webpack.config.js
  
*/
  
 Or customize the directory 
...
  { 
   test: /\.jsx?$/,
   use: [
	'babel-loader',
	{
	  loader:'zkt-svg/loader',
	  options: { directory: path.resolve(__dirname, 'folder1/folder2/svgs') }
	}
  ]}
... 
<!-- Output -->

<svg class="">
 <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#smile">
  #shadow-root (closed)
 </use>
</svg>
0.0.8

4 years ago

0.0.6

4 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago