mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
add BaseIcon component
This commit is contained in:
parent
9c0f8d92eb
commit
b52480b8d4
32
webapp/components/_new/generic/BaseIcon.vue
Normal file
32
webapp/components/_new/generic/BaseIcon.vue
Normal 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>
|
||||
Loading…
x
Reference in New Issue
Block a user