useRawHTMLIcon.ts 828 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { i18n } from '#shared/i18n.ts'
  3. import { usePrivateIcon } from './usePrivateIcon.ts'
  4. import type { Props } from './CommonIcon.vue'
  5. export const useRawHTMLIcon = (props: Props & { class?: string }) => {
  6. const { iconClass, finalSize } = usePrivateIcon({ size: 'medium', ...props })
  7. const html = String.raw
  8. return html`
  9. <svg
  10. xmlns="http://www.w3.org/2000/svg"
  11. class="icon ${iconClass.value} ${props.class || ''} fill-current"
  12. width="${finalSize.value.width}"
  13. height="${finalSize.value.height}"
  14. ${!props.decorative &&
  15. `aria-label=${i18n.t(props.label || props.name) || ''}`}
  16. ${(props.decorative && 'aria-hidden="true"') || ''}
  17. >
  18. <use href="#icon-${props.name}" />
  19. </svg>
  20. `
  21. }