Menu.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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="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="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="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 setup lang="ts">
  79. import { ItemsMenu } from '~/types/interfaces'
  80. const props = defineProps({
  81. menu: {
  82. type: Array as () => ItemsMenu,
  83. required: true
  84. },
  85. miniVariant: {
  86. type: Boolean,
  87. required: true
  88. },
  89. openMenu: {
  90. type: Boolean,
  91. required: true
  92. }
  93. })
  94. const {openMenu} = toRefs(props)
  95. const open = ref(true)
  96. //Par défaut si l'écran est trop petit au chargement de la page, le menu doit être fermé.
  97. if(process.client)
  98. open.value = window.innerWidth >= 1264
  99. const unwatch: WatchStopHandle = watch(openMenu, (newValue, oldValue) => {
  100. if(newValue !== oldValue)
  101. open.value = true
  102. })
  103. onUnmounted(() => {
  104. unwatch()
  105. })
  106. </script>
  107. <style scoped>
  108. .v-list-item__action, .v-list-group__header__prepend-icon {
  109. margin-right: 10px !important;
  110. }
  111. .v-application--is-ltr .v-list-group--no-action > .v-list-group__header{
  112. margin-left: 0px;
  113. padding-left: 0px;
  114. }
  115. .v-application--is-ltr .v-list-group--no-action > .v-list-group__items > .v-list-item {
  116. padding-left: 30px;
  117. }
  118. .v-list-item__title {
  119. font-size: 14px;
  120. }
  121. .v-list-item {
  122. min-height: 10px !important;
  123. }
  124. .v-list-item__action {
  125. margin: 10px 0;
  126. }
  127. .v-list-item__content {
  128. padding: 8px 0;
  129. }
  130. .home_menu {
  131. font-size: 23px;
  132. }
  133. </style>