LayoutSidebarFooterMenu.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { computed } from 'vue'
  5. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  6. import { useSessionStore } from '#shared/stores/session.ts'
  7. import CommonPopover from '#desktop/components/CommonPopover/CommonPopover.vue'
  8. import CommonPopoverMenu from '#desktop/components/CommonPopover/CommonPopoverMenu.vue'
  9. import { usePopover } from '#desktop/components/CommonPopover/usePopover.ts'
  10. import { avatarMenuItems } from './AvatarMenu/plugins/index.ts'
  11. interface Props {
  12. collapsed?: boolean
  13. }
  14. const props = defineProps<Props>()
  15. const { user } = storeToRefs(useSessionStore())
  16. const avatarSize = computed(() => (props.collapsed ? 'small' : 'normal'))
  17. const { popover, popoverTarget, toggle, isOpen: popoverIsOpen } = usePopover()
  18. </script>
  19. <template>
  20. <section
  21. class="flex flex-row items-center justify-between"
  22. :class="{ 'mx-auto mb-0.5': collapsed }"
  23. >
  24. <CommonPopover
  25. id="user-menu-popover"
  26. ref="popover"
  27. :owner="popoverTarget"
  28. :hide-arrow="collapsed"
  29. orientation="autoVertical"
  30. placement="start"
  31. >
  32. <CommonPopoverMenu
  33. :popover="popover"
  34. :header-label="user?.fullname!"
  35. :items="avatarMenuItems"
  36. />
  37. </CommonPopover>
  38. <button
  39. id="user-menu"
  40. ref="popoverTarget"
  41. class="-:outline-transparent hover:-:outline-blue-900 rounded-full outline outline-2 focus:outline-blue-800 hover:focus:outline-blue-800"
  42. :class="{
  43. 'outline-blue-800 hover:outline-blue-800': popoverIsOpen,
  44. }"
  45. :aria-label="$t('User menu')"
  46. aria-controls="user-menu-popover"
  47. aria-expanded="false"
  48. @click="toggle(true)"
  49. >
  50. <CommonUserAvatar
  51. v-if="user"
  52. :entity="user"
  53. class="!flex border-gray-900"
  54. :size="avatarSize"
  55. personal
  56. />
  57. </button>
  58. <!-- <ul class="flex flex-row">
  59. <li>T1</li>
  60. <li>T2</li>
  61. </ul> -->
  62. </section>
  63. </template>