v-remixicon
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -33,11 +33,16 @@ 'use strict'; | ||
}, | ||
setup(props) { | ||
const icons = vue.inject('remixicon-icons', {}); | ||
const icon = vue.computed(() => { | ||
if (props.path) return props.path; | ||
lib: {}, | ||
add(icons) { | ||
if (typeof icons === 'object' && icons !== null) { | ||
this.lib = icons; | ||
} | ||
}, | ||
computed: { | ||
icon() { | ||
if (this.path) return path; | ||
const icon = icons[props.name]; | ||
const icon = this.$options.lib[this.name]; | ||
if (typeof icon === 'undefined') { | ||
console.error(`[v-remixicon] ${props.name} name of the icon is incorrect`); | ||
console.error(`[v-remixicon] ${this.name} name of the icon is incorrect`); | ||
return; | ||
@@ -47,22 +52,23 @@ } | ||
return icon; | ||
}); | ||
return () => vue.h( | ||
}, | ||
}, | ||
render() { | ||
return vue.h( | ||
'svg', | ||
{ | ||
viewBox: props.viewBox, | ||
fill: props.fill, | ||
height: props.size, | ||
width: props.size, | ||
viewBox: this.viewBox, | ||
fill: this.fill, | ||
height: this.size, | ||
width: this.size, | ||
class: 'v-remixicon', | ||
xmlns: 'http://www.w3.org/2000/svg', | ||
style: { | ||
transform: props.rotate ? `rotate(${props.rotate}deg)` : null, | ||
transform: this.rotate ? `rotate(${this.rotate}deg)` : null, | ||
}, | ||
}, | ||
[ | ||
props.title ? vue.h('title', {}, props.title) : null, | ||
this.title ? vue.h('title', {}, this.title) : null, | ||
vue.h('g', {}, [ | ||
vue.h('path', { fill: 'none', d: 'M0 0h24v24H0z' }), | ||
vue.h('path', { 'fill-rule': 'nonzero', d: icon.value }), | ||
vue.h('path', { 'fill-rule': 'nonzero', d: this.icon }), | ||
]) | ||
@@ -77,7 +83,8 @@ ] | ||
var index = { | ||
install(app, icons){ | ||
app.provide('remixicon-icons', icons); | ||
install(app){ | ||
app.component(VRemix.name, VRemix); | ||
}, | ||
add(icons){ | ||
VRemix.add(icons); | ||
} | ||
}; | ||
@@ -84,0 +91,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { inject, computed, h } from 'vue'; | ||
import { h } from 'vue'; | ||
@@ -29,11 +29,16 @@ var VRemix = { | ||
}, | ||
setup(props) { | ||
const icons = inject('remixicon-icons', {}); | ||
const icon = computed(() => { | ||
if (props.path) return props.path; | ||
lib: {}, | ||
add(icons) { | ||
if (typeof icons === 'object' && icons !== null) { | ||
this.lib = icons; | ||
} | ||
}, | ||
computed: { | ||
icon() { | ||
if (this.path) return path; | ||
const icon = icons[props.name]; | ||
const icon = this.$options.lib[this.name]; | ||
if (typeof icon === 'undefined') { | ||
console.error(`[v-remixicon] ${props.name} name of the icon is incorrect`); | ||
console.error(`[v-remixicon] ${this.name} name of the icon is incorrect`); | ||
return; | ||
@@ -43,22 +48,23 @@ } | ||
return icon; | ||
}); | ||
return () => h( | ||
}, | ||
}, | ||
render() { | ||
return h( | ||
'svg', | ||
{ | ||
viewBox: props.viewBox, | ||
fill: props.fill, | ||
height: props.size, | ||
width: props.size, | ||
viewBox: this.viewBox, | ||
fill: this.fill, | ||
height: this.size, | ||
width: this.size, | ||
class: 'v-remixicon', | ||
xmlns: 'http://www.w3.org/2000/svg', | ||
style: { | ||
transform: props.rotate ? `rotate(${props.rotate}deg)` : null, | ||
transform: this.rotate ? `rotate(${this.rotate}deg)` : null, | ||
}, | ||
}, | ||
[ | ||
props.title ? h('title', {}, props.title) : null, | ||
this.title ? h('title', {}, this.title) : null, | ||
h('g', {}, [ | ||
h('path', { fill: 'none', d: 'M0 0h24v24H0z' }), | ||
h('path', { 'fill-rule': 'nonzero', d: icon.value }), | ||
h('path', { 'fill-rule': 'nonzero', d: this.icon }), | ||
]) | ||
@@ -73,9 +79,10 @@ ] | ||
var index = { | ||
install(app, icons){ | ||
app.provide('remixicon-icons', icons); | ||
install(app){ | ||
app.component(VRemix.name, VRemix); | ||
}, | ||
add(icons){ | ||
VRemix.add(icons); | ||
} | ||
}; | ||
export { VRemixIcon, index as default }; |
{ | ||
"name": "v-remixicon", | ||
"description": "Vue component wrapper for remixicon", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"scripts": { | ||
@@ -15,2 +15,3 @@ "build:icons": "node scripts/icons.build.js", | ||
"icons.js", | ||
"icons.mjs", | ||
"cjs", | ||
@@ -21,2 +22,12 @@ "icons.d.ts" | ||
"module": "dist/v-remixicon.esm.js", | ||
"exports": { | ||
"import": { | ||
"path": "./dist/v-remixicon.esm.js", | ||
"type": "module" | ||
}, | ||
"require": { | ||
"path": "./dist/v-remixicon.cjs.js", | ||
"type": "commonjs" | ||
} | ||
}, | ||
"devDependencies": { | ||
@@ -23,0 +34,0 @@ "@vue/compiler-sfc": "^3.2.4", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2017476
7
11949