index.pug 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // app/shared/MultiLevelMenu/index.pug
  2. nav(class="relative")
  3. button(
  4. @click="toggleMenu"
  5. class="flex items-center space-x-1 text-gray-700 dark:text-gray-200 hover:text-primary-600 dark:hover:text-primary-400 transition-colors"
  6. )
  7. span Каталог
  8. svg(:class="{'transform rotate-180': isOpen}" class="w-4 h-4 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24")
  9. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7")
  10. transition(name="menu-slide")
  11. div(
  12. v-if="isOpen"
  13. class="absolute top-full left-0 mt-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl z-50 py-2"
  14. v-click-outside="closeMenu"
  15. )
  16. .px-4.py-2.border-b.border-gray-200.dark_border-gray-700
  17. h3(class="font-semibold text-gray-900 dark:text-white") Категории товаров
  18. ul(class="max-h-96 overflow-y-auto")
  19. li(v-for="category in categories" :key="category._id")
  20. .relative
  21. button(
  22. @click="toggleSubmenu(category._id)"
  23. class="w-full flex justify-between items-center px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
  24. )
  25. span {{ category.name }}
  26. svg(v-if="category.children && category.children.length" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24")
  27. path(stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7")
  28. transition(name="submenu-slide")
  29. div(
  30. v-if="openSubmenu === category._id"
  31. class="absolute left-full top-0 ml-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl z-50 py-2"
  32. )
  33. ul
  34. li(v-for="child in getChildCategories(category._id)" :key="child._id")
  35. a(
  36. :href="`/catalog?category=${child.slug}`"
  37. class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
  38. ) {{ child.name }}