index.vue 697 B

12345678910111213141516171819202122232425262728293031323334
  1. <script setup lang="ts">
  2. import type { CSSProperties } from 'vue'
  3. const props = withDefaults(
  4. defineProps<{
  5. name: string
  6. prefix?: string
  7. color?: string
  8. size?: number
  9. }>(),
  10. {
  11. prefix: 'icon',
  12. size: 16
  13. }
  14. )
  15. const symbolId = computed(() => `#${props.prefix}-${props.name}`)
  16. const fill = computed(() => (props.color ? props.color : 'currentColor'))
  17. const getStyle = computed((): CSSProperties => {
  18. const s = `${`${props.size}`.replace('px', '')}px`
  19. return {
  20. width: s,
  21. height: s
  22. }
  23. })
  24. </script>
  25. <template>
  26. <svg :style="getStyle" aria-hidden="true">
  27. <use :xlink:href="symbolId" :fill="fill" />
  28. </svg>
  29. </template>
  30. <style scoped lang="less"></style>