index.pug 8.7 KB

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