MainMenu.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!--
  2. Menu principal de l'application
  3. Prend en paramètre une liste de ItemMenu et les met en forme
  4. -->
  5. <template>
  6. <v-navigation-drawer
  7. v-model="displayMenu"
  8. :rail="!isOpened"
  9. :disable-resize-watcher="true"
  10. class="bg-ot-dark-grey text-ot-menu-color main-menu"
  11. >
  12. <template #prepend>
  13. <slot name="title"></slot>
  14. </template>
  15. <v-list
  16. open-strategy="single"
  17. active-class="active"
  18. class="left-menu"
  19. >
  20. <div v-for="(item, i) in menu.children" :key="i">
  21. <!-- Cas 1 : l'item n'a pas d'enfants, c'est un lien -->
  22. <v-list-item
  23. v-if="!item.children"
  24. :title="$t(item.label)"
  25. :prepend-icon="item.icon.name"
  26. :href="!isInternalLink(item) ? item.to : undefined"
  27. :to="isInternalLink(item) ? item.to : undefined"
  28. exact
  29. class="text-ot-menu-color"
  30. height="48px"
  31. ></v-list-item>
  32. <!-- Cas 2 : l'item a des enfants, c'est un groupe -->
  33. <v-list-group
  34. v-else
  35. expand-icon="fas fa-angle-right"
  36. collapse-icon="fas fa-angle-down"
  37. class="text-ot-menu-color"
  38. v-model="item.expanded"
  39. >
  40. <template #activator="{ props }">
  41. <v-list-item
  42. v-bind="props"
  43. :prepend-icon="item.icon.name"
  44. :title="$t(item.label)"
  45. class="text-ot-menu-color"
  46. height="48px"
  47. ></v-list-item>
  48. </template>
  49. <v-list-item
  50. v-for="child in item.children"
  51. :key="$t(child.label)"
  52. :title="$t(child.label)"
  53. :prepend-icon="child.icon.name"
  54. :href="!isInternalLink(child) ? child.to : undefined"
  55. :to="isInternalLink(child) ? child.to : undefined"
  56. exact
  57. height="48px"
  58. class="text-ot-white"
  59. ></v-list-item>
  60. </v-list-group>
  61. </div>
  62. </v-list>
  63. <template #append>
  64. <slot name="foot"></slot>
  65. </template>
  66. </v-navigation-drawer>
  67. </template>
  68. <script setup lang="ts">
  69. import {useMenu} from "~/composables/layout/useMenu";
  70. import {computed} from "@vue/reactivity";
  71. const { buildMenu, hasMenu, isInternalLink, openMenu, isMenuOpened } = useMenu()
  72. const menu = buildMenu('Main')
  73. const displayMenu = computed(() => hasMenu('Main'))
  74. const isOpened = computed(() => isMenuOpened('Main'))
  75. // Par défaut si l'écran est trop petit au chargement de la page, le menu doit rester fermé.
  76. if (process.client && window.innerWidth >= 1264) {
  77. openMenu('Main')
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .v-list-item {
  82. min-height: 10px !important;
  83. }
  84. :deep(.v-list-item-title),
  85. :deep(.v-icon),
  86. {
  87. font-size: 14px;
  88. color: rgb(var(--v-theme-ot-menu-color));
  89. }
  90. .v-list-item__prepend {
  91. margin: 10px 0;
  92. margin-right: 10px !important;
  93. }
  94. .v-application--is-ltr .v-list-group--no-action > .v-list-group__header {
  95. margin-left: 0;
  96. padding-left: 0;
  97. }
  98. .v-application--is-ltr .v-list-group--no-action > .v-list-group__items > .v-list-item {
  99. padding-left: 30px;
  100. }
  101. .v-list-item__content {
  102. padding: 8px 0;
  103. }
  104. .v-list-group__items .v-list-item {
  105. padding-inline-start: 30px !important;
  106. }
  107. .v-list-group--no-action > .v-list-group__header,
  108. .v-list-item
  109. {
  110. border-left:3px solid rgb(var(--v-theme-ot-dark-grey));
  111. height: 48px;
  112. }
  113. .v-list-item:hover,
  114. .v-list-item.active,
  115. :deep(.v-list-group__items .v-list-item)
  116. {
  117. border-left: 3px solid rgb(var(--v-theme-ot-green));
  118. background: rgb(var(--v-theme-ot-dark-grey-hover));
  119. }
  120. :deep(.v-list-group__items .v-list-item-title) {
  121. color: rgb(var(--v-theme-ot-white));
  122. }
  123. :deep(.v-list-item .v-icon) {
  124. margin-right: 10px;
  125. }
  126. </style>