ParametersMenu.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <v-navigation-drawer
  3. v-if="displayMenu"
  4. v-model="isOpened"
  5. mobile-breakpoint="sm"
  6. style="z-index: 1005"
  7. >
  8. <!--
  9. Le z-index est précisé pour éviter cette erreur : https://github.com/vuetifyjs/nuxt-module/issues/205
  10. Il pourra être retiré dès que le bug aura été corrigé
  11. -->
  12. <template #prepend>
  13. <div class="title">
  14. <h3>{{ $t('parameters') }}</h3>
  15. </div>
  16. </template>
  17. <v-list active-class="active">
  18. <v-list-item
  19. v-for="(item, i) in menu!!.children"
  20. :key="i"
  21. :title="$t(item.label)"
  22. :prepend-icon="item.icon ? item.icon.name : ''"
  23. :to="(item as MenuItem).to"
  24. >
  25. </v-list-item>
  26. </v-list>
  27. <template #append>
  28. <v-btn
  29. :href="homeUrl"
  30. prepend-icon="fa fa-right-from-bracket"
  31. :flat="true"
  32. color="on-neutral-very-soft"
  33. class="cancel-btn py-2"
  34. >
  35. {{ $t('exit') }}
  36. </v-btn>
  37. </template>
  38. </v-navigation-drawer>
  39. </template>
  40. <script setup lang="ts">
  41. import { useDisplay } from 'vuetify'
  42. import { computed } from 'vue'
  43. import { useMenu } from '~/composables/layout/useMenu'
  44. import { useHomeUrl } from '~/composables/utils/useHomeUrl'
  45. import type { MenuGroup, MenuItem } from '~/types/layout'
  46. const { mdAndUp } = useDisplay()
  47. const { getMenu, hasMenu, isMenuOpened, setMenuState } = useMenu()
  48. const menu: MenuGroup | null = getMenu('Parameters')
  49. const displayMenu = computed(() => {
  50. return menu !== null && hasMenu('Parameters')
  51. })
  52. const isOpened = computed(() => isMenuOpened('Parameters'))
  53. const unwatch = watch(mdAndUp, () => {
  54. // Par défaut si l'écran est trop petit au chargement de la page, le menu doit rester fermé.
  55. if (process.client && menu !== null) {
  56. setMenuState('Parameters', mdAndUp.value)
  57. }
  58. })
  59. const { homeUrl } = useHomeUrl()
  60. onUnmounted(() => {
  61. unwatch()
  62. })
  63. </script>
  64. <style scoped lang="scss">
  65. .title {
  66. display: flex;
  67. align-items: center;
  68. height: 48px;
  69. vertical-align: center;
  70. margin-top: 18px;
  71. padding: 4px 16px;
  72. font-size: 18px;
  73. color: rgb(var(--v-theme-on-neutral-very-soft));
  74. }
  75. .v-navigation-drawer {
  76. background-color: rgb(var(--v-theme-neutral-very-soft));
  77. border-right: solid 1px rgb(var(--v-theme-neutral-strong));
  78. }
  79. :deep(.v-list-item-title),
  80. :deep(.v-icon) {
  81. font-size: 14px;
  82. color: rgb(var(--v-theme-on-neutral-very-soft));
  83. }
  84. .v-list-item:hover,
  85. .v-list-item.active,
  86. :deep(.v-list-group__items .v-list-item) {
  87. background-color: rgb(var(--v-theme-neutral)) !important;
  88. color: rgb(var(--v-theme-on-secondary-alt)) !important;
  89. }
  90. :deep(.v-list-item.active .v-list-item-title) {
  91. font-weight: 800 !important;
  92. }
  93. :deep(.v-list-item-title),
  94. :deep(.v-icon) {
  95. font-size: 14px;
  96. color: rgb(var(--v-theme-on-neutral-very-soft));
  97. }
  98. :deep(.v-list-item__prepend) {
  99. margin: 10px 0;
  100. margin-right: 10px !important;
  101. }
  102. :deep(.v-list-item .v-icon) {
  103. max-width: 24px;
  104. margin-right: 10px;
  105. }
  106. .cancel-btn {
  107. height: 42px;
  108. color: rgb(var(--v-theme-on-neutral-very-soft));
  109. background-color: transparent;
  110. width: 100%;
  111. border-top: solid 1px rgb(var(--v-theme-on-neutral-very-soft));
  112. display: flex;
  113. flex-direction: row;
  114. justify-content: flex-start;
  115. }
  116. :deep(.cancel-btn .v-btn__prepend) {
  117. margin: 0 16px 4px 2px;
  118. }
  119. </style>