Monorepo for Tangled
at e949a86d926b049287187fad78915dbc05492253 118 lines 5.3 kB view raw
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 := .Active.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 right-0 mt-4 p-4 rounded bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700 shadow-lg z-50" style="width: 14rem;"> 57 {{ $active := .Active.Did }} 58 59 <div class="pb-2 mb-2 border-b border-gray-200 dark:border-gray-700"> 60 <div class="flex items-center gap-2"> 61 <img src="{{ tinyAvatar $active }}" alt="" class="rounded-full h-8 w-8 flex-shrink-0 border border-gray-300 dark:border-gray-700" /> 62 <div class="flex-1 overflow-hidden"> 63 <p class="font-medium text-sm truncate">{{ $active | resolve }}</p> 64 <p class="text-xs text-green-600 dark:text-green-400">active</p> 65 </div> 66 </div> 67 </div> 68 69 {{ $others := .Accounts | otherAccounts $active }} 70 {{ if $others }} 71 <div class="pb-2 mb-2 border-b border-gray-200 dark:border-gray-700"> 72 <p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1">Switch Account</p> 73 {{ range $others }} 74 <button 75 type="button" 76 hx-post="/account/switch" 77 hx-vals='{"did": "{{ .Did }}"}' 78 hx-swap="none" 79 class="flex items-center gap-2 w-full py-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-left" 80 > 81 <img src="{{ tinyAvatar .Did }}" alt="" class="rounded-full h-6 w-6 flex-shrink-0 border border-gray-300 dark:border-gray-700" /> 82 <span class="text-sm truncate flex-1">{{ .Did | resolve }}</span> 83 </button> 84 {{ end }} 85 </div> 86 {{ end }} 87 88 <a href="/login?mode=add_account" class="flex items-center gap-2 py-1 text-sm"> 89 {{ i "plus" "w-4 h-4 flex-shrink-0" }} 90 <span>Add another account</span> 91 </a> 92 93 <div class="pt-2 mt-2 border-t border-gray-200 dark:border-gray-700 space-y-1"> 94 <a href="/{{ $active }}" class="block py-1 text-sm">profile</a> 95 <a href="/{{ $active }}?tab=repos" class="block py-1 text-sm">repositories</a> 96 <a href="/{{ $active }}?tab=strings" class="block py-1 text-sm">strings</a> 97 <a href="/settings" class="block py-1 text-sm">settings</a> 98 <a href="#" 99 hx-post="/logout" 100 hx-swap="none" 101 class="block py-1 text-sm text-red-400 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 102 logout 103 </a> 104 </div> 105 </div> 106</details> 107 108<script> 109document.addEventListener('click', function(event) { 110 const dropdowns = document.querySelectorAll('.nav-dropdown'); 111 dropdowns.forEach(function(dropdown) { 112 if (!dropdown.contains(event.target)) { 113 dropdown.removeAttribute('open'); 114 } 115 }); 116}); 117</script> 118{{ end }}