this repo has no description
1{{ define "layouts/fragments/topbar" }}
2 <nav class="mx-auto space-x-4 px-6 py-2 dark:text-white drop-shadow-sm bg-white dark:bg-gray-800">
3 <div class="flex justify-between p-0 items-center">
4 <div id="left-items">
5 <a href="/" hx-boost="true" class="text-2xl no-underline hover:no-underline flex items-center gap-2">
6 {{ template "fragments/logotypeSmall" }}
7 </a>
8 </div>
9
10 <div id="right-items" class="flex items-center gap-4">
11 {{ with .LoggedInUser }}
12 {{ block "newButton" . }} {{ end }}
13 {{ template "notifications/fragments/bell" }}
14 {{ block "profileDropdown" . }} {{ end }}
15 {{ else }}
16 <a href="/login">login</a>
17 <span class="text-gray-500 dark:text-gray-400">or</span>
18 <a href="/signup" class="btn-create py-0 hover:no-underline hover:text-white flex items-center gap-2">
19 join now {{ i "arrow-right" "size-4" }}
20 </a>
21 {{ end }}
22 </div>
23 </div>
24 </nav>
25{{ end }}
26
27{{ define "newButton" }}
28<details class="relative inline-block text-left nav-dropdown">
29 <summary class="btn-create py-0 cursor-pointer list-none flex items-center gap-2">
30 {{ i "plus" "w-4 h-4" }} <span class="hidden md:inline">new</span>
31 </summary>
32 <div class="absolute flex flex-col right-0 mt-3 p-4 rounded w-48 bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700">
33 <a href="/repo/new" class="flex items-center gap-2">
34 {{ i "book-plus" "w-4 h-4" }}
35 new repository
36 </a>
37 <a href="/strings/new" class="flex items-center gap-2">
38 {{ i "line-squiggle" "w-4 h-4" }}
39 new string
40 </a>
41 </div>
42</details>
43{{ end }}
44
45{{ define "profileDropdown" }}
46<details class="relative inline-block text-left nav-dropdown">
47 <summary class="cursor-pointer list-none flex items-center gap-1">
48 {{ $user := .Did }}
49 <img
50 src="{{ tinyAvatar $user }}"
51 alt=""
52 class="rounded-full h-6 w-6 border border-gray-300 dark:border-gray-700"
53 />
54 <span class="hidden md:inline">{{ $user | resolve | truncateAt30 }}</span>
55 </summary>
56 <div class="absolute flex flex-col right-0 mt-4 p-4 rounded w-48 bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700">
57 <a href="/{{ $user }}">profile</a>
58 <a href="/{{ $user }}?tab=repos">repositories</a>
59 <a href="/{{ $user }}?tab=strings">strings</a>
60 <a href="/settings">settings</a>
61 <a href="#"
62 hx-post="/logout"
63 hx-swap="none"
64 class="text-red-400 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300">
65 logout
66 </a>
67 </div>
68</details>
69
70<script>
71document.addEventListener('click', function(event) {
72 const dropdowns = document.querySelectorAll('.nav-dropdown');
73 dropdowns.forEach(function(dropdown) {
74 if (!dropdown.contains(event.target)) {
75 dropdown.removeAttribute('open');
76 }
77 });
78});
79</script>
80{{ end }}