Menu.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. :mini-variant.sync="miniVariant"
  8. v-model="open"
  9. fixed
  10. clipped
  11. class="ot_dark_grey ot_menu_color--text"
  12. app
  13. >
  14. <template #prepend>
  15. <slot name="title"></slot>
  16. </template>
  17. <v-list class="left-menu">
  18. <div v-for="(item, i) in menu" :key="i">
  19. <v-list-item
  20. v-if="!item.children"
  21. :href="item.isExternalLink ? item.to : undefined"
  22. :to="!item.isExternalLink ? item.to : undefined"
  23. router
  24. exact
  25. >
  26. <v-list-item-action>
  27. <v-icon class="ot_menu_color--text" small>
  28. {{ item.icon.name }}
  29. </v-icon>
  30. </v-list-item-action>
  31. <v-list-item-content>
  32. <v-list-item-title class="ot_menu_color--text" v-text="$t(item.title)" />
  33. </v-list-item-content>
  34. </v-list-item>
  35. <v-list-group
  36. v-else
  37. v-model="item.active"
  38. no-action
  39. >
  40. <template #activator>
  41. <v-list-item-action>
  42. <v-icon class="ot_menu_color--text" small>
  43. {{ item.icon.name }}
  44. </v-icon>
  45. </v-list-item-action>
  46. <v-list-item-content>
  47. <v-list-item-title class="ot_menu_color--text" v-text="$t(item.title)" />
  48. </v-list-item-content>
  49. </template>
  50. <v-list-item
  51. v-for="child in item.children"
  52. :key="child.title"
  53. :href="child.isExternalLink ? child.to : undefined"
  54. :to="!child.isExternalLink ? child.to : undefined"
  55. router
  56. exact
  57. >
  58. <v-list-item-action>
  59. <v-icon class="ot_white--text" small>
  60. {{ child.icon.name }}
  61. </v-icon>
  62. </v-list-item-action>
  63. <v-list-item-content>
  64. <v-list-item-title class="ot_white--text" v-text="$t(child.title)" />
  65. </v-list-item-content>
  66. </v-list-item>
  67. <template #appendIcon>
  68. <v-icon class="ot_menu_color--text" small>mdi-chevron-down</v-icon>
  69. </template>
  70. </v-list-group>
  71. </div>
  72. </v-list>
  73. <template #append>
  74. <slot name="foot"></slot>
  75. </template>
  76. </v-navigation-drawer>
  77. </template>
  78. <script lang="ts">
  79. import {computed, defineComponent, onUnmounted, ref, toRefs, watch} from '@nuxtjs/composition-api'
  80. import { ItemsMenu } from '~/types/interfaces'
  81. import {WatchStopHandle} from "@vue/composition-api";
  82. export default defineComponent({
  83. props: {
  84. menu: {
  85. type: Array as () => ItemsMenu,
  86. required: true
  87. },
  88. miniVariant: {
  89. type: Boolean,
  90. required: true
  91. },
  92. openMenu: {
  93. type: Boolean,
  94. required: true
  95. }
  96. },
  97. setup(props){
  98. const {openMenu} = toRefs(props)
  99. const open = ref(true)
  100. //Par défaut si l'écran est trop petit au chargement de la page, le menu doit être fermé.
  101. if(process.client)
  102. open.value = window.innerWidth >= 1264
  103. const unwatch: WatchStopHandle = watch(openMenu, (newValue, oldValue) => {
  104. if(newValue !== oldValue)
  105. open.value = true
  106. })
  107. onUnmounted(() => {
  108. unwatch()
  109. })
  110. return {
  111. open
  112. }
  113. }
  114. })
  115. </script>
  116. <style scoped>
  117. .v-list-item__action, .v-list-group__header__prepend-icon {
  118. margin-right: 10px !important;
  119. }
  120. .v-application--is-ltr .v-list-group--no-action > .v-list-group__header{
  121. margin-left: 0px;
  122. padding-left: 0px;
  123. }
  124. .v-application--is-ltr .v-list-group--no-action > .v-list-group__items > .v-list-item {
  125. padding-left: 30px;
  126. }
  127. .v-list-item__title {
  128. font-size: 14px;
  129. }
  130. .v-list-item {
  131. min-height: 10px !important;
  132. }
  133. .v-list-item__action {
  134. margin: 10px 0;
  135. }
  136. .v-list-item__content {
  137. padding: 8px 0;
  138. }
  139. .home_menu {
  140. font-size: 23px;
  141. }
  142. </style>