Files
ubicloud/views/layouts/topbar.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

50 lines
2.4 KiB
Plaintext

<div
class="sticky top-0 z-40 flex h-16 shrink-0 items-center gap-x-4 border-b border-gray-200 bg-white px-4 shadow-sm sm:gap-x-6 sm:px-6 lg:px-8"
>
<button type="button" class="toggle-mobile-menu -m-2.5 p-2.5 text-gray-700 lg:hidden">
<span class="sr-only">Open sidebar</span>
<%== part("components/icon", name: "hero-bars-3") %>
</button>
<!-- Separator -->
<div class="h-6 w-px bg-gray-900/10 lg:hidden"></div>
<a href="<%= @project_data ? "#{@project_data[:path]}/dashboard" : "/project" %>">
<img class="h-5 w-auto lg:hidden" src="/logo-primary.png" alt="Ubicloud">
</a>
<div class="flex flex-1 gap-x-4 self-stretch justify-end lg:gap-x-6">
<div class="flex items-center gap-x-4 lg:gap-x-6">
<!-- Profile dropdown -->
<div class="relative group dropdown text-sm leading-6 text-gray-900">
<button type="button" class="-m-1.5 flex items-center p-1.5" title="<%= current_account.email %>">
<%== part("components/icon", name: "hero-user-circle", classes: "h-8 w-8 rounded-full bg-gray-50") %>
<span class="hidden lg:flex lg:items-center">
<span class="ml-3 font-semibold" aria-hidden="true"><%= current_account.name %></span>
<%== part("components/icon", name: "hero-chevron-down", classes: "h-5 w-5 ml-2 text-gray-400") %>
</span>
</button>
<div
class="hidden group-[.active]:block absolute right-0 z-10 mt-2.5 w-48 origin-top-right rounded-md bg-white pb-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none divide-y divide-gray-100"
role="menu"
tabindex="-1"
>
<div class="px-3 py-2">
<p class="text-sm">Signed in as</p>
<p class="truncate text-sm font-medium text-gray-900">
<%= current_account.email %></p>
</div>
<div>
<a href="/account" class="block px-3 py-1 hover:bg-gray-100" role="menuitem" tabindex="-1">My Account</a>
<a href="/project" class="block px-3 py-1 hover:bg-gray-100" role="menuitem" tabindex="-1">Projects</a>
</div>
<div>
<form action="/logout" method="post">
<%== csrf_tag("/logout") %>
<button type="submit" class="block px-3 py-1 hover:bg-gray-100 w-full text-left" role="menuitem" tabindex="-1">Log out</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>