Menu.vue 3.6 KB

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