vue-unicons
Version:
1000+ Pixel-perfect svg icons for your next project as Vue components
2 lines (1 loc) • 6.86 kB
JavaScript
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self)["vue-unicons"]={})}(this,(function(n){"use strict";function e(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){if(!(Symbol.iterator in Object(n))&&"[object Arguments]"!==Object.prototype.toString.call(n))return;var t=[],i=!0,o=!1,l=void 0;try{for(var r,s=n[Symbol.iterator]();!(i=(r=s.next()).done)&&(t.push(r.value),!e||t.length!==e);i=!0);}catch(n){o=!0,l=n}finally{try{i||null==s.return||s.return()}finally{if(o)throw l}}return t}(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var t={name:"Unicon",inheritAttrs:!1,props:{name:{type:String,default:""},iconStyle:{type:String,default:"line"},width:{type:[String,Number],default:24},height:{type:[String,Number],default:24},fill:{type:String,default:"inherit"},hoverFill:{type:String,default:null},viewBox:{type:String,default:"0 0 24 24"}},lib:[],add(n){Array.isArray(n)?this.lib=n:this.lib.push(n)},data(){return{localFill:this.fill}},computed:{icon(){const n=this.$options.lib.find((n=>n.name===this.name&&n.style===this.iconStyle));return n?n.path:void console.error(`Name '${this.name}' of the icon is not correct`)}},watch:{fill(n){this.localFill=n}},methods:{onHover(){this.hoverFill&&(this.localFill=this.hoverFill)},onLeave(){this.hoverFill&&(this.localFill=this.fill)}}};function i(n,e,t,i,o,l,r,s,a,c){"boolean"!=typeof r&&(a=s,s=r,r=!1);const u="function"==typeof t?t.options:t;let d;if(n&&n.render&&(u.render=n.render,u.staticRenderFns=n.staticRenderFns,u._compiled=!0,o&&(u.functional=!0)),i&&(u._scopeId=i),l?(d=function(n){(n=n||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(n=__VUE_SSR_CONTEXT__),e&&e.call(this,a(n)),n&&n._registeredComponents&&n._registeredComponents.add(l)},u._ssrRegister=d):e&&(d=r?function(n){e.call(this,c(n,this.$root.$options.shadowRoot))}:function(n){e.call(this,s(n))}),d)if(u.functional){const n=u.render;u.render=function(e,t){return d.call(t),n(e,t)}}else{const n=u.beforeCreate;u.beforeCreate=n?[].concat(n,d):[d]}return t}const o="undefined"!=typeof navigator&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());function l(n){return(n,e)=>function(n,e){const t=o?e.media||"default":n,i=s[t]||(s[t]={ids:new Set,styles:[]});if(!i.ids.has(n)){i.ids.add(n);let t=e.source;if(e.map&&(t+="\n/*# sourceURL="+e.map.sources[0]+" */",t+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e.map))))+" */"),i.element||(i.element=document.createElement("style"),i.element.type="text/css",e.media&&i.element.setAttribute("media",e.media),void 0===r&&(r=document.head||document.getElementsByTagName("head")[0]),r.appendChild(i.element)),"styleSheet"in i.element)i.styles.push(t),i.element.styleSheet.cssText=i.styles.filter(Boolean).join("\n");else{const n=i.ids.size-1,e=document.createTextNode(t),o=i.element.childNodes;o[n]&&i.element.removeChild(o[n]),o.length?i.element.insertBefore(e,o[n]):i.element.appendChild(e)}}}(n,e)}let r;const s={};const a=t;var c=function(){var n=this,e=n.$createElement,t=n._self._c||e;return t("div",{staticClass:"unicon"},[t("svg",n._b({attrs:{xmlns:"http://www.w3.org/2000/svg",width:n.width,height:n.height,viewBox:n.viewBox,fill:n.localFill},domProps:{innerHTML:n._s(n.icon)},on:{click:function(e){return n.$emit("click")},mouseover:n.onHover,mouseout:n.onLeave}},"svg",n.$attrs,!1))])};c._withStripped=!0;const u=i({render:c,staticRenderFns:[]},(function(n){n&&n("data-v-57a9d603_0",{source:"\n.unicon {\n display: inline-block;\n}\n.unicon svg {\n transition: 0.2s all;\n}\n.uim-primary {\n opacity: 1;\n}\n.uim-secondary {\n opacity: 0.7;\n}\n.uim-tertiary {\n opacity: 0.5;\n}\n.uim-quaternary {\n opacity: 0.25;\n}\n.uim-quinary {\n opacity: 0;\n}\n",map:{version:3,sources:["/Users/antonreshetov/www/github/vue-unicons/src/components/Unicon.vue"],names:[],mappings:";AA4GA;EACA,qBAAA;AACA;AACA;EACA,oBAAA;AACA;AACA;EACA,UAAA;AACA;AACA;EACA,YAAA;AACA;AACA;EACA,YAAA;AACA;AACA;EACA,aAAA;AACA;AACA;EACA,UAAA;AACA",file:"Unicon.vue",sourcesContent:['<template>\n \x3c!-- eslint-disable vue/no-v-html --\x3e\n <div class="unicon">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n :width="width"\n :height="height"\n :viewBox.camel="viewBox"\n :fill="localFill"\n v-bind="$attrs"\n @click="$emit(\'click\')"\n @mouseover="onHover"\n @mouseout="onLeave"\n v-html="icon"\n />\n </div>\n</template>\n\n<script>\nexport default {\n name: \'Unicon\',\n\n inheritAttrs: false,\n\n props: {\n name: {\n type: String,\n default: \'\'\n },\n iconStyle: {\n type: String,\n default: \'line\'\n },\n width: {\n type: [String, Number],\n default: 24\n },\n height: {\n type: [String, Number],\n default: 24\n },\n fill: {\n type: String,\n default: \'inherit\'\n },\n hoverFill: {\n type: String,\n default: null\n },\n viewBox: {\n type: String,\n default: \'0 0 24 24\'\n }\n },\n\n lib: [],\n\n add (icons) {\n if (Array.isArray(icons)) {\n this.lib = icons\n } else {\n this.lib.push(icons)\n }\n },\n\n data () {\n return {\n localFill: this.fill\n }\n },\n\n computed: {\n icon () {\n const icon = this.$options.lib.find(\n i => i.name === this.name && i.style === this.iconStyle\n )\n\n if (icon) {\n return icon.path\n } else {\n console.error(`Name \'${this.name}\' of the icon is not correct`)\n return undefined\n }\n }\n },\n\n watch: {\n fill (newColor) {\n this.localFill = newColor\n }\n },\n\n methods: {\n onHover () {\n if (this.hoverFill) {\n this.localFill = this.hoverFill\n }\n },\n onLeave () {\n if (this.hoverFill) {\n this.localFill = this.fill\n }\n }\n }\n}\n<\/script>\n\n<style>\n.unicon {\n display: inline-block;\n}\n.unicon svg {\n transition: 0.2s all;\n}\n.uim-primary {\n opacity: 1;\n}\n.uim-secondary {\n opacity: 0.7;\n}\n.uim-tertiary {\n opacity: 0.5;\n}\n.uim-quaternary {\n opacity: 0.25;\n}\n.uim-quinary {\n opacity: 0;\n}\n</style>\n']},media:void 0})}),a,undefined,false,undefined,!1,l,void 0,void 0);var d={install:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n.component(u.name,u);for(var i=0,o=Object.entries(t);i<o.length;i++){var l=e(o[i],2),r=l[0],s=l[1];u.props[r]&&(u.props[r].default=s)}},add:function(n){u.add(n)}};n.Unicon=u,n.default=d,Object.defineProperty(n,"__esModule",{value:!0})}));