Monorepo for Tangled
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 {{ template "user/fragments/pic" (list $user "size-6") }}
50 <span class="hidden md:inline">{{ $user | resolve | truncateAt30 }}</span>
51 </summary>
52 <div class="absolute right-0 mt-4 rounded bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700 shadow-lg z-50 text-sm" style="width: 14rem;">
53 {{ $active := .Active.Did }}
54 {{ $linkStyle := "flex items-center gap-3 px-4 py-2 hover:no-underline hover:bg-gray-50 hover:dark:bg-gray-700/50" }}
55
56 {{ $others := .Accounts | otherAccounts $active }}
57 {{ if $others }}
58 <div class="text-sm text-gray-500 dark:text-gray-400 px-3 py-1 pt-2">switch account</div>
59 {{ range $others }}
60 <button
61 type="button"
62 hx-post="/account/switch"
63 hx-vals='{"did": "{{ .Did }}"}'
64 hx-swap="none"
65 class="{{$linkStyle}} w-full text-left pl-3"
66 >
67 {{ template "user/fragments/pic" (list .Did "size-6") }}
68 <span class="truncate flex-1">{{ .Did | resolve }}</span>
69 </button>
70 {{ end }}
71 {{ end }}
72
73 <a href="/login?mode=add_account" class="{{$linkStyle}} pl-3">
74 <div class="size-6 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center">
75 {{ i "plus" "size-3" }}
76 </div>
77
78 <div class="text-left flex-1 min-w-0 block truncate">
79 add account
80 </div>
81 </a>
82
83 <div class="border-t border-gray-200 dark:border-gray-700">
84 <a href="/{{ $active }}" class="{{$linkStyle}}">
85 {{ i "user" "size-4" }}
86 profile
87 </a>
88 <a href="/{{ $active }}?tab=repos" class="{{$linkStyle}}">
89 {{ i "book-marked" "size-4" }}
90 repositories
91 </a>
92 <a href="/{{ $active }}?tab=strings" class="{{$linkStyle}}">
93 {{ i "line-squiggle" "size-4" }}
94 strings
95 </a>
96 <a href="/settings" class="{{$linkStyle}}">
97 {{ i "cog" "size-4" }}
98 settings
99 </a>
100 <a href="#"
101 hx-post="/logout"
102 hx-swap="none"
103 class="{{$linkStyle}} text-red-400 hover:text-red-400 hover:bg-red-100 dark:hover:bg-red-700/20 pb-2">
104 {{ i "log-out" "size-4" }}
105 logout
106 </a>
107 </div>
108 </div>
109</details>
110
111<script>
112document.addEventListener('click', function(event) {
113 const dropdowns = document.querySelectorAll('.nav-dropdown');
114 dropdowns.forEach(function(dropdown) {
115 if (!dropdown.contains(event.target)) {
116 dropdown.removeAttribute('open');
117 }
118 });
119});
120</script>
121{{ end }}