Files
ubicloud/views/layouts/sidebar/project_switcher.erb
Jeremy Evans cb389c5144 Use Roda part plugin to simplify render calls with locals
This uses the new part plugin to simplify and optimize render
calls with locals.

```ruby
render(:template, locals: {foo: 'bar'})

part(:template, foo: 'bar')
```

This simplifies a large number of calls in Clover, since
rendering with locals is one of the most common method
calls in the templates.

The main advantage of this is simplicity, but the part method
is also more optimized, and will be even more optimized when
we upgrade to Ruby 3.4.

Diff best reviewed with:

```
git diff -b --color-words --word-diff-regex='\\w+|[^[:space:]]'
```
2025-01-31 09:47:06 -08:00

43 lines
1.8 KiB
Plaintext

<div class="group dropdown inline-block w-full">
<div>
<button
type="button"
class="inline-flex w-full items-center gap-x-4 px-6 py-3 text-md font-semibold leading-6 text-white bg-orange-700 hover:bg-orange-800"
id="menu-button"
>
<%== part("components/icon", name: "hero-folder-open", classes: "h-8 w-8 rounded-full") %>
<span><%= @project ? @project[:name] : "Global" %></span>
<%== part("components/icon", name: "hero-chevron-up-down", classes: "h-8 w-8 ml-auto") %>
</button>
</div>
<div
class="hidden opacity-0 scale-95 group-[.active]:block group-[.active]:opacity-100 group-[.active]:scale-100 transition ease-out duration-100 absolute bottom-12 left-12 z-10 mt-2 w-64 origin-bottom divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none text-gray-800"
role="menu"
tabindex="-1"
>
<div class="py-1 max-h-64 overflow-y-auto" role="none">
<% current_account.projects.each do |p| %>
<a
href="<%= p.path %>/dashboard"
class="block px-4 py-2 hover:bg-gray-100 hover:text-gray-900 <% if p.id == @project&.id %> bg-orange-50 text-orange-600 hover:bg-orange-50 hover:text-orange-700 <% end %>"
role="menuitem"
tabindex="-1"
><%= p.name %></a>
<% end %>
</div>
<div class="py-1" role="none">
<a
href="/project/create"
class="group flex items-center px-4 py-2 hover:bg-gray-100 hover:text-gray-900"
role="menuitem"
tabindex="-1"
>
<div class="mr-2 text-gray-400 group-hover:text-gray-500">
<%== part("components/icon", name: "hero-plus", classes: "h-5 w-5 stroke-[2.5px]") %>
</div>
Create Project
</a>
</div>
</div>
</div>