index.pug 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. nav(class="relative")
  2. div(class="hidden md:flex space-x-2")
  3. div(
  4. v-for="item in menuItems"
  5. :key="item.id"
  6. class="menu-item relative"
  7. @mouseenter="openSubmenu = item.id"
  8. @mouseleave="openSubmenu = null"
  9. )
  10. button(
  11. class="flex items-center px-4 py-2 text-sm font-medium rounded-md transition-all duration-200"
  12. :class="getMenuItemClasses(item)"
  13. :aria-expanded="openSubmenu === item.id"
  14. )
  15. router-link(:to="item.path")
  16. span {{ item.title }}
  17. svg(
  18. v-if="item.children"
  19. class="w-4 h-4 ml-1 transition-transform duration-200"
  20. :class="{'transform rotate-180': openSubmenu === item.id}"
  21. fill="none"
  22. stroke="currentColor"
  23. viewBox="0 0 24 24"
  24. )
  25. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7")
  26. div(
  27. v-if="item.children && openSubmenu === item.id"
  28. class="absolute left-0 mt-2 w-56 rounded-lg shadow-xl bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 z-50"
  29. @mouseenter="openSubmenu = item.id"
  30. )
  31. div(class="py-2")
  32. div(
  33. v-for="child in item.children"
  34. :key="child.id"
  35. class="submenu-item relative"
  36. @mouseenter="openSubsubmenu = child.id"
  37. @mouseleave="openSubsubmenu = null"
  38. )
  39. div(
  40. class="flex items-center justify-between px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors duration-200"
  41. :class="{'rounded-lg': !child.children}"
  42. @click="handleMenuClick(child)"
  43. )
  44. router-link(:to="child.path")
  45. span {{ child.title }}
  46. svg(
  47. v-if="child.children"
  48. class="w-4 h-4 transition-transform duration-200"
  49. :class="{'transform rotate-90': openSubsubmenu === child.id}"
  50. fill="none"
  51. stroke="currentColor"
  52. viewBox="0 0 24 24"
  53. )
  54. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7")
  55. div(
  56. v-if="child.children && openSubsubmenu === child.id"
  57. class="absolute left-full top-0 ml-1 w-56 rounded-lg shadow-xl bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 z-50"
  58. )
  59. div(class="py-2")
  60. div(
  61. v-for="subchild in child.children"
  62. :key="subchild.id"
  63. class="px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors duration-200"
  64. @click="handleMenuClick(subchild)"
  65. )
  66. router-link(:to="subchild.path") {{ subchild.title }}
  67. button(
  68. class="md:hidden p-2 rounded-md text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
  69. @click="toggleMobileMenu"
  70. aria-label="Открыть меню"
  71. )
  72. svg(class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24")
  73. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16")
  74. div(
  75. v-if="isMobileMenuOpen"
  76. class="fixed inset-0 z-50 md:hidden min-h-max"
  77. )
  78. div(
  79. class="fixed inset-0 bg-black bg-opacity-50"
  80. @click="closeMobileMenu"
  81. )
  82. div(
  83. class="fixed inset-y-0 left-0 w-64 bg-white dark:bg-gray-800 shadow-xl transform transition-transform duration-300 ease-in-out" min-h-max
  84. :class="{'translate-x-0': isMobileMenuOpen, '-translate-x-full': !isMobileMenuOpen}"
  85. )
  86. div(class="flex flex-col h-full")
  87. div(class="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700")
  88. h2(class="text-lg font-semibold text-gray-800 dark:text-white") Меню
  89. button(
  90. @click="closeMobileMenu"
  91. class="p-2 rounded-md text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors"
  92. aria-label="Закрыть меню"
  93. )
  94. svg(class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24")
  95. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12")
  96. div(class="flex-1 overflow-y-auto min-h-max")
  97. div(class="py-2 min-h-max")
  98. div(
  99. v-for="item in menuItems"
  100. :key="item.id"
  101. class="mobile-menu-item"
  102. )
  103. div(
  104. class="flex items-center justify-between px-4 py-3 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors"
  105. @click="toggleMobileSubmenu(item)"
  106. )
  107. router-link(:to="item.path")
  108. span(class="font-medium") {{ item.title }}
  109. svg(
  110. v-if="item.children"
  111. class="w-4 h-4 transition-transform duration-200"
  112. :class="{'transform rotate-180': openMobileSubmenu === item.id}"
  113. fill="none"
  114. stroke="currentColor"
  115. viewBox="0 0 24 24"
  116. )
  117. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7")
  118. div(
  119. v-if="item.children && openMobileSubmenu === item.id"
  120. class="bg-gray-50 dark:bg-gray-900"
  121. )
  122. div(
  123. v-for="child in item.children"
  124. :key="child.id"
  125. class="mobile-submenu-item"
  126. )
  127. div(
  128. class="flex items-center justify-between px-6 py-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors"
  129. @click="toggleMobileSubsubmenu(child)"
  130. )
  131. router-link(:to="child.path")
  132. span {{ child.title }}
  133. svg(
  134. v-if="child.children"
  135. class="w-4 h-4 transition-transform duration-200"
  136. :class="{'transform rotate-90': openMobileSubsubmenu === child.id}"
  137. fill="none"
  138. stroke="currentColor"
  139. viewBox="0 0 24 24"
  140. )
  141. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7")
  142. div(
  143. v-if="child.children && openMobileSubsubmenu === child.id"
  144. class="bg-gray-100 dark:bg-gray-800"
  145. )
  146. div(
  147. v-for="subchild in child.children"
  148. :key="subchild.id"
  149. class="px-8 py-2 text-gray-500 dark:text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer transition-colors"
  150. @click="handleMobileMenuClick(subchild)"
  151. )
  152. router-link(:to="subchild.path") {{ subchild.title }}