37 lines
913 B
JavaScript
37 lines
913 B
JavaScript
// @ts-check
|
|
|
|
const iconoir = require("@iconify-json/iconoir")
|
|
const utils = require("@iconify/utils")
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @param {number} [height]
|
|
*/
|
|
function get(name, height = 20) {
|
|
const {body, attributes} = utils.iconToSVG(iconoir.icons.icons[name], {height})
|
|
attributes.viewBox = "0 0 24 24"
|
|
return utils.iconToHTML(body, attributes)
|
|
}
|
|
|
|
/**
|
|
* @param {string} name
|
|
*/
|
|
function useTemplate(name) {
|
|
if (Array.isArray(name)) {
|
|
return name.map(useTemplate).join("")
|
|
}
|
|
const {body} = utils.iconToSVG(iconoir.icons.icons[name])
|
|
return `<svg hidden><symbol id="n-${name}">${body}</symbol></svg>`
|
|
}
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @param {number} [height]
|
|
*/
|
|
function use(name, height = 20) {
|
|
return `<svg width=${height} height=${height} viewBox="0 0 24 24"><use xlink:href=#n-${name} /></svg>`
|
|
}
|
|
|
|
module.exports.get = get
|
|
module.exports.useTemplate = useTemplate
|
|
module.exports.use = use
|