CommonLabel.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import type { Sizes } from './types.ts'
  4. export interface Props {
  5. size?: Sizes
  6. iconColor?: string
  7. prefixIcon?: string
  8. suffixIcon?: string
  9. tag?: 'span' | 'p'
  10. }
  11. const props = withDefaults(defineProps<Props>(), {
  12. size: 'medium',
  13. tag: 'span',
  14. })
  15. const fontSizeClassMap = {
  16. small: 'text-xs leading-snug',
  17. medium: 'text-sm leading-snug',
  18. large: 'text-base leading-snug',
  19. xl: 'text-xl leading-snug',
  20. }
  21. const iconClassMap = {
  22. small: 'xs',
  23. medium: 'tiny',
  24. large: 'small',
  25. xl: 'base',
  26. } as const
  27. </script>
  28. <template>
  29. <component
  30. :is="tag"
  31. class="-:gap-1 -:text-gray-100 -:dark:text-neutral-400 -:inline-flex items-center justify-start"
  32. :class="fontSizeClassMap[props.size]"
  33. data-test-id="common-label"
  34. >
  35. <CommonIcon
  36. v-if="prefixIcon"
  37. class="shrink-0"
  38. :size="iconClassMap[props.size]"
  39. :name="prefixIcon"
  40. :class="iconColor"
  41. decorative
  42. />
  43. <slot />
  44. <CommonIcon
  45. v-if="suffixIcon"
  46. class="shrink-0"
  47. :size="iconClassMap[props.size]"
  48. :name="suffixIcon"
  49. :class="iconColor"
  50. decorative
  51. />
  52. </component>
  53. </template>