CommonIcon.vue 1019 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { usePrivateIcon } from './composable'
  4. import type { Animations, Sizes } from './types'
  5. export interface Props {
  6. size?: Sizes
  7. fixedSize?: { width: number; height: number }
  8. name: string
  9. label?: string
  10. decorative?: boolean
  11. animation?: Animations
  12. }
  13. const props = withDefaults(defineProps<Props>(), {
  14. size: 'medium',
  15. decorative: false,
  16. })
  17. const emit = defineEmits<{
  18. (e: 'click', event: MouseEvent): void
  19. }>()
  20. const onClick = (event: MouseEvent) => {
  21. emit('click', event)
  22. }
  23. const { iconClass, finalSize } = usePrivateIcon(props)
  24. </script>
  25. <template>
  26. <svg
  27. xmlns="http://www.w3.org/2000/svg"
  28. class="icon fill-current"
  29. :class="iconClass"
  30. :width="finalSize.width"
  31. :height="finalSize.height"
  32. :aria-label="decorative ? undefined : $t(label || name)"
  33. :aria-hidden="decorative"
  34. @click="onClick"
  35. >
  36. <use :href="`#icon-${name}`" />
  37. </svg>
  38. </template>