Monorepo for Tangled
tangled.org
1{{ define "timeline/fragments/trending" }}
2 <div class="border border border-gray-200 dark:border-gray-700 rounded-sm divide-y divide-gray-200 dark:divide-gray-700">
3 <h3 class="text-base dark:text-white flex items-center gap-2 px-4 py-2 bg-white/50 dark:bg-gray-800/50">
4 {{ i "trending-up" "size-4 flex-shrink-0" }}
5 Trending
6 </h3>
7 {{ if .Repos }}
8 <div class="w-full py-1 bg-white dark:bg-gray-800">
9 {{ range $index, $repo := .Repos }}
10 {{ template "singleLineRepo" (list $ $repo) }}
11 {{ end }}
12 </div>
13 {{ else }}
14 <div class="p-6 text-sm text-gray-500 dark:text-gray-400 text-center">
15 No trending repositories this week
16 </div>
17 {{ end }}
18 </div>
19{{ end }}
20
21{{ define "singleLineRepo" }}
22 {{ $root := index . 0 }}
23 {{ $repo := index . 1 }}
24 {{ with $repo }}
25 {{ $repoOwner := resolve .Did }}
26 {{/* a real anchor per row: a stretched (absolute inset-0) link inside a
27 position:relative table row breaks hit-testing on safari, which does
28 not support positioned table rows as containing blocks */}}
29 <a href="/{{ $repoOwner }}/{{ .Slug }}"
30 class="grid grid-cols-[3.5rem_minmax(0,1fr)_auto] gap-x-4 px-4 py-3 no-underline hover:no-underline hover:bg-gray-100/50 dark:hover:bg-gray-700/50">
31 <div class="flex text-sm items-start justify-end gap-1 text-gray-400 tabular-nums whitespace-nowrap">
32 {{ i "star" "w-3 h-3 fill-current shrink-0 mt-1" }}
33 {{ if .RepoStats }}
34 <span>{{ scaleFmt .RepoStats.StarCount }}</span>
35 {{ else }}
36 <span>0</span>
37 {{ end }}
38 </div>
39 <div class="min-w-0">
40 <span class="text-sm font-medium dark:text-white truncate block">{{ $repoOwner }}/{{ .Name }}</span>
41 {{ with .Description }}
42 <span class="text-sm text-gray-500 dark:text-gray-400 truncate line-clamp-1 block">{{ . | description }}</span>
43 {{ end }}
44 </div>
45 <div class="text-gray-400 text-sm whitespace-nowrap font-mono">
46 {{ if and .RepoStats .RepoStats.Language }}
47 {{ $lang := .RepoStats.Language }}
48 {{ $display := $lang }}
49 {{ if gt (len $lang) 6 }}
50 {{ $display = .RepoStats.LangShortName }}
51 {{ end }}
52 <div class="flex items-center gap-1.5">
53 {{ template "repo/fragments/colorBall" (dict "color" (langColor $lang)) }}
54 <span>{{ $display }}</span>
55 </div>
56 {{ end }}
57 </div>
58 </a>
59 {{ end }}
60{{ end }}
61