|
3 | 3 | <% current_menu.items(self).each do |item| %>
|
4 | 4 | <% children = item.items(self).presence %>
|
5 | 5 | <li <%= current_menu_item?(item) && "data-open" %> class="group" data-item-id="<%= item.id %>">
|
6 |
| - <% if children %> |
7 |
| - <button data-menu-button class="text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center w-full rounded-md p-2 gap-x-2 text-sm"> |
| 6 | + <% label = capture do %> |
| 7 | + <% if (url = item.url(self)).present? %> |
| 8 | + <%= link_to item.label(self), url, item.html_options.merge(class: "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center w-full rounded-md p-2 gap-x-2 text-sm no-underline #{(current_menu_item?(item, children: false) ? "bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white selected" : "")}") %> |
| 9 | + <% else %> |
8 | 10 | <%= item.label(self) %>
|
9 |
| - <svg class="group-data-[open]:rotate-90 group-data-[open]:rtl:-rotate-90 ms-auto h-5 w-5 shrink-0 rtl:-scale-x-100" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> |
10 |
| - <path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" /> |
11 |
| - </svg> |
12 |
| - </button> |
| 11 | + <% end %> |
| 12 | + <% end %> |
| 13 | + |
| 14 | + <% if children %> |
| 15 | + <div class="flex gap-2"> |
| 16 | + <div class="flex-auto"><%= label %></div> |
| 17 | + <button data-parent-id="<%= item.id %>" data-menu-button class="bg-gray-100 dark:bg-white/5 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center rounded-full p-2 text-sm"> |
| 18 | + <svg class="group-data-[open]:rotate-90 group-data-[open]:rtl:-rotate-90 ms-auto h-5 w-5 shrink-0 rtl:-scale-x-100" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> |
| 19 | + <path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" /> |
| 20 | + </svg> |
| 21 | + </button> |
| 22 | + </div> |
13 | 23 | <ul role="list" class="mt-1 space-y-1 hidden group-data-[open]:block">
|
14 | 24 | <% children.each do |j| %>
|
15 | 25 | <li data-item-id="<%= j.id %>">
|
16 | 26 | <%= link_to j.label(self), j.url(self), j.html_options.merge(class: "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white block rounded-md py-1.5 px-2 text-sm no-underline #{(current_menu_item?(j) ? "bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white selected" : "")}") %>
|
17 | 27 | </li>
|
18 | 28 | <% end %>
|
19 | 29 | </ul>
|
20 |
| - <% elsif url = item.url(self) %> |
21 |
| - <%= link_to item.label(self), url, item.html_options.merge(class: "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center w-full rounded-md p-2 gap-x-2 text-sm no-underline #{(current_menu_item?(item) ? "bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white selected" : "")}") %> |
22 | 30 | <% else %>
|
23 |
| - <%= item.label(self) %> |
| 31 | + <%= label %> |
24 | 32 | <% end %>
|
25 | 33 | </li>
|
26 | 34 | <% end %>
|
|
0 commit comments