@kano/icons-rendering
A small set of functions to help organizing the rendering of SVG icons with HTML templates.
Last updated 3 months ago by onishiweb .
MIT · Original npm · Tarball · package.json
$ cnpm install @kano/icons-rendering 
SYNC missed versions from official npm registry.

Icons rendering

A small set of functions to help organizing the rendering of SVG icons with HTML templates.

Create the template

Keeping your SVG icons in memory as HTML template is efficient as the browser can copy the DOM tree really fast. You can create the template using the svg string litteral tag. This can be used to create a SVG icon sheet with a whole set of icons.

import { svg } from '@kano/icons-rendering/index.js';

const svgTemplate = svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"></svg>`;

Render the icon

Rendering an icon by embedding its svg is the most efficient way to do it, you can clone the template to append its contents for a quick icon injection:


const { content } = svgTemplate.cloneNode(true);

el.appendChild(content);

If you do not control where the icon will be rendered and a src is required, you can use the dataURI method:

import { svg, dataURI } from '@kano/icons-rendering/index.js';

const svgTemplate = svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"></svg>`;

const imageSrc = dataURI(svgTemplate);

Current Tags

  • 3.3.14                                ...           latest (3 months ago)

7 Versions

  • 3.3.14                                ...           3 months ago
  • 3.0.16                                ...           a year ago
  • 3.0.15                                ...           a year ago
  • 3.0.6                                ...           2 years ago
  • 0.0.1-alpha.1                                ...           2 years ago
  • 0.0.1-alpha.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 3
Dependencies (0)
None
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |