Menu.vue 3.6 KB

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