| <template> | |
| <svg | |
| class="app-svg-icon" | |
| :class="$attrs.class" | |
| @click="(...args) => $emit('click', ...args)" | |
| aria-hidden="true" | |
| > | |
| <use | |
| :xlink:href="symbolId" | |
| :color="color" | |
| /> | |
| </svg> | |
| </template> | |
| <style lang="scss" scoped> | |
| @import "@/assets/mixins"; | |
| @import "@/assets/variables"; | |
| .app-svg-icon { | |
| width: 20px; | |
| height: 20px; | |
| } | |
| </style> | |
| <script lang="ts"> | |
| import { defineComponent, computed } from 'vue'; | |
| export default defineComponent({ | |
| name: 'SvgIcon', | |
| inheritAttrs: false, | |
| emits: ['click'], | |
| props: { | |
| prefix: { | |
| type: String, | |
| default: 'icon', | |
| }, | |
| name: { | |
| type: String, | |
| required: true, | |
| }, | |
| color: { | |
| type: String, | |
| default: null, | |
| }, | |
| }, | |
| setup(props) { | |
| const symbolId = computed(() => `#${props.prefix}-${props.name}`); | |
| return { symbolId }; | |
| }, | |
| }); | |
| </script> | |