add BaseIcon component

This commit is contained in:
Alina Beck 2019-11-14 13:04:49 +03:00
parent 9c0f8d92eb
commit b52480b8d4

View File

@ -0,0 +1,32 @@
<template>
<span v-if="svgIcon">
<component :is="svgIcon" />
</span>
</template>
<script>
import icons from '~/view/assets/icons'
export default {
props: {
name: {
type: String,
required: true,
},
},
computed: {
svgIcon() {
const icon = icons[this.name]
if (!icon) {
return false
}
/*
a Vue component needs a render function,
so we check if there is a render function directly on the icon
otherwise it is wrapped in icon.default
*/
return icon.render ? icon : icon.default
},
},
}
</script>