<template>
  <svg :class="svgClass" aria-hidden="true" :style="{ width: size, height: size }">
    <use :xlink:href="iconName" />
  </svg>
</template>

<script setup lang="ts">
interface IProp {
  name: string
  size?: string
  className?: string
}
const props = withDefaults(defineProps<IProp>(), {
  size: '1em',
  color: '',
  className: '',
})

const iconName = computed(() => {
  return `#icon-${props.name}`
})
const svgClass = computed(() => {
  if (props.className) {
    return `svg-icon ${props.className}`
  }
  return 'svg-icon'
})
</script>

<style lang="scss" scoped>
.svg-icon {
  vertical-align: -0.1em;
  fill: currentColor;
  overflow: hidden;
}
</style>
