24 lines
686 B
Vue
24 lines
686 B
Vue
<template>
|
|
<img class="icon-svg" :src="svg" :style="style" />
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed } from 'vue'
|
|
const props = defineProps<{type: string}>()
|
|
const requireAssets = require.context('../assets', false, /\.svg$/)
|
|
const SVGs = requireAssets.keys().reduce((svgs: {[propName:string]: string}, path: string) => {
|
|
const svgFile = requireAssets(path)
|
|
const fileNameMatch = path.match(/^.*\/(.+?)\.svg$/)
|
|
if (fileNameMatch) {
|
|
svgs[fileNameMatch[1]] = svgFile
|
|
}
|
|
return svgs
|
|
}, {})
|
|
|
|
const svg = computed(() => SVGs[props.type])
|
|
const style = computed(() => {
|
|
if (props.type === 'next') {
|
|
return { transform: 'rotate(180deg)' }
|
|
}
|
|
})
|
|
</script> |