35 lines
823 B
Vue
35 lines
823 B
Vue
<template>
|
|
<span ref="refIcon" :style="{ color: color ?? undefined }" class="liman-icons flex" v-html="tempIcon"></span>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref } from 'vue'
|
|
import icons from './icons.json'
|
|
|
|
interface Props {
|
|
icon: string
|
|
color?: string | null
|
|
size?: string | number
|
|
}
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
color: null,
|
|
})
|
|
const tempIcon = ref<string>()
|
|
const refIcon = ref<HTMLSpanElement>()
|
|
tempIcon.value = (icons as Record<string, string>)[`${props.icon}`]
|
|
|
|
onMounted(() => {
|
|
if (props.size) {
|
|
const svg = refIcon.value?.children[0] as SVGElement
|
|
svg.setAttribute('width', props.size as string)
|
|
svg.setAttribute('height', props.size as string)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.liman-icons :deep(svg path) {
|
|
stroke: currentColor;
|
|
}
|
|
</style>
|