CommonLabel.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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' | 'h2' | 'h3'
  10. }
  11. const props = withDefaults(defineProps<Props>(), {
  12. size: 'medium',
  13. tag: 'span',
  14. })
  15. const fontSizeClassMap = {
  16. xs: 'text-[10px] leading-[10px]',
  17. small: 'text-xs leading-snug',
  18. medium: 'text-sm leading-snug',
  19. large: 'text-base leading-snug',
  20. xl: 'text-xl leading-snug',
  21. }
  22. const iconClassMap = {
  23. xs: 'xs',
  24. small: 'xs',
  25. medium: 'tiny',
  26. large: 'small',
  27. xl: 'base',
  28. } as const
  29. </script>
  30. <template>
  31. <component
  32. :is="tag"
  33. class="-:gap-1 -:text-gray-100 -:dark:text-neutral-400 -:inline-flex items-center justify-start"
  34. :class="fontSizeClassMap[props.size]"
  35. data-test-id="common-label"
  36. >
  37. <CommonIcon
  38. v-if="prefixIcon"
  39. class="shrink-0"
  40. :size="iconClassMap[props.size]"
  41. :name="prefixIcon"
  42. :class="iconColor"
  43. decorative
  44. />
  45. <slot />
  46. <CommonIcon
  47. v-if="suffixIcon"
  48. class="shrink-0"
  49. :size="iconClassMap[props.size]"
  50. :name="suffixIcon"
  51. :class="iconColor"
  52. decorative
  53. />
  54. </component>
  55. </template>