Monorepo for Tangled tangled.org

appview/pages: use tabselectors to toggle issue/pull states

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 3ef86ac8 3cd06ef2

verified
Changed files
+101 -55
appview
pages
templates
fragments
repo
fragments
issues
pulls
+12 -4
appview/pages/templates/fragments/tabSelector.html
··· 6 6 {{ $activeTab := "bg-white dark:bg-gray-700 shadow-sm" }} 7 7 {{ $inactiveTab := "bg-gray-100 dark:bg-gray-800 shadow-inner" }} 8 8 {{ range $index, $value := $all }} 9 - {{ $isActive := eq $value $active }} 10 - <a href="?{{ $name }}={{ $value }}" 11 - class="py-2 text-sm w-full block hover:no-underline text-center {{ if $isActive }} {{$activeTab }} {{ else }} {{ $inactiveTab }} {{ end }}"> 12 - {{ $value }} 9 + {{ $isActive := eq $value.Key $active }} 10 + <a href="?{{ $name }}={{ $value.Key }}" 11 + class="p-2 whitespace-nowrap flex justify-center items-center gap-2 text-sm w-full block hover:no-underline text-center {{ if $isActive }} {{$activeTab }} {{ else }} {{ $inactiveTab }} {{ end }}"> 12 + {{ if $value.Icon }} 13 + {{ i $value.Icon "size-4" }} 14 + {{ end }} 15 + 16 + {{ with $value.Meta }} 17 + {{ . }} 18 + {{ end }} 19 + 20 + {{ $value.Value }} 13 21 </a> 14 22 {{ end }} 15 23 </div>
+20 -2
appview/pages/templates/repo/fragments/diffOpts.html
··· 5 5 {{ if .Split }} 6 6 {{ $active = "split" }} 7 7 {{ end }} 8 - {{ $values := list "unified" "split" }} 9 - {{ template "fragments/tabSelector" (dict "Name" "diff" "Values" $values "Active" $active) }} 8 + 9 + {{ $unified := 10 + (dict 11 + "Key" "unified" 12 + "Value" "unified" 13 + "Icon" "square-split-vertical" 14 + "Meta" "") }} 15 + {{ $split := 16 + (dict 17 + "Key" "split" 18 + "Value" "split" 19 + "Icon" "square-split-horizontal" 20 + "Meta" "") }} 21 + {{ $values := list $unified $split }} 22 + 23 + {{ template "fragments/tabSelector" 24 + (dict 25 + "Name" "diff" 26 + "Values" $values 27 + "Active" $active) }} 10 28 </section> 11 29 {{ end }} 12 30
+32 -21
appview/pages/templates/repo/issues/issues.html
··· 8 8 {{ end }} 9 9 10 10 {{ define "repoContent" }} 11 + {{ $active := "closed" }} 12 + {{ if .FilteringByOpen }} 13 + {{ $active = "open" }} 14 + {{ end }} 15 + 16 + {{ $open := 17 + (dict 18 + "Key" "open" 19 + "Value" "open" 20 + "Icon" "circle-dot" 21 + "Meta" (string .RepoInfo.Stats.IssueCount.Open)) }} 22 + {{ $closed := 23 + (dict 24 + "Key" "closed" 25 + "Value" "closed" 26 + "Icon" "ban" 27 + "Meta" (string .RepoInfo.Stats.IssueCount.Closed)) }} 28 + {{ $values := list $open $closed }} 29 + 30 + <div class="flex flex-col gap-2"> 11 31 <div class="flex justify-between items-stretch gap-4"> 12 32 <form class="flex flex-1 relative" method="GET"> 13 33 <input type="hidden" name="state" value="{{ if .FilteringByOpen }}open{{ else }}closed{{ end }}"> ··· 22 42 {{ i "x" "w-4 h-4" }} 23 43 </a> 24 44 </form> 45 + <div class="hidden sm:block"> 46 + {{ template "fragments/tabSelector" (dict "Name" "state" "Values" $values "Active" $active) }} 47 + </div> 25 48 <a 26 - href="/{{ .RepoInfo.FullName }}/issues/new" 27 - class="btn-create text-sm flex items-center justify-center gap-2 no-underline hover:no-underline hover:text-white" 28 - > 29 - {{ i "circle-plus" "w-4 h-4" }} 30 - <span>new</span> 49 + href="/{{ .RepoInfo.FullName }}/issues/new" 50 + class="btn-create text-sm flex items-center justify-center gap-2 no-underline hover:no-underline hover:text-white" 51 + > 52 + {{ i "circle-plus" "w-4 h-4" }} 53 + <span>new</span> 31 54 </a> 32 55 </div> 33 - <div class="mt-2 ml-2 flex gap-4 text-xs"> 34 - <a 35 - href="?state=open" 36 - class="flex items-center gap-2 {{ if .FilteringByOpen }}font-bold {{ else }}text-gray-500 dark:text-gray-400{{ end }}" 37 - > 38 - {{ i "circle-dot" "w-4 h-4" }} 39 - <span>{{ .RepoInfo.Stats.IssueCount.Open }} open</span> 40 - </a> 41 - <a 42 - href="?state=closed" 43 - class="flex items-center gap-2 {{ if not .FilteringByOpen }}font-bold {{ else }}text-gray-500 dark:text-gray-400{{ end }}" 44 - > 45 - {{ i "ban" "w-4 h-4" }} 46 - <span>{{ .RepoInfo.Stats.IssueCount.Closed }} closed</span> 47 - </a> 56 + <div class="sm:hidden"> 57 + {{ template "fragments/tabSelector" (dict "Name" "state" "Values" $values "Active" $active) }} 48 58 </div> 49 - <div class="error" id="issues"></div> 59 + </div> 60 + <div class="error" id="issues"></div> 50 61 {{ end }} 51 62 52 63 {{ define "repoAfter" }}
+37 -28
appview/pages/templates/repo/pulls/pulls.html
··· 8 8 {{ end }} 9 9 10 10 {{ define "repoContent" }} 11 - <div class="flex justify-between items-stretch gap-4"> 11 + {{ $active := "closed" }} 12 + {{ if .FilteringBy.IsOpen }} 13 + {{ $active = "open" }} 14 + {{ else if .FilteringBy.IsMerged }} 15 + {{ $active = "merged" }} 16 + {{ end }} 17 + {{ $open := 18 + (dict 19 + "Key" "open" 20 + "Value" "open" 21 + "Icon" "git-pull-request" 22 + "Meta" (string .RepoInfo.Stats.PullCount.Open)) }} 23 + {{ $merged := 24 + (dict 25 + "Key" "merged" 26 + "Value" "merged" 27 + "Icon" "git-merge" 28 + "Meta" (string .RepoInfo.Stats.PullCount.Merged)) }} 29 + {{ $closed := 30 + (dict 31 + "Key" "closed" 32 + "Value" "closed" 33 + "Icon" "ban" 34 + "Meta" (string .RepoInfo.Stats.IssueCount.Closed)) }} 35 + {{ $values := list $open $merged $closed }} 36 + <div class="flex flex-col gap-2"> 37 + <div class="flex justify-between items-stretch gap-2"> 12 38 <form class="flex flex-1 relative" method="GET"> 13 39 <input type="hidden" name="state" value="{{ .FilteringBy.String }}"> 14 40 <div class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"> ··· 22 48 {{ i "x" "w-4 h-4" }} 23 49 </a> 24 50 </form> 25 - <a 26 - href="/{{ .RepoInfo.FullName }}/pulls/new" 51 + <div class="hidden sm:block"> 52 + {{ template "fragments/tabSelector" (dict "Name" "state" "Values" $values "Active" $active) }} 53 + </div> 54 + <a href="/{{ .RepoInfo.FullName }}/pulls/new" 27 55 class="btn-create text-sm flex items-center gap-2 no-underline hover:no-underline hover:text-white" 28 56 > 29 - {{ i "git-pull-request-create" "w-4 h-4" }} 30 - <span>new</span> 57 + {{ i "git-pull-request-create" "w-4 h-4" }} 58 + <span>new</span> 31 59 </a> 32 60 </div> 33 - <div class="mt-2 ml-2 flex gap-4 text-xs"> 34 - <a 35 - href="?state=open" 36 - class="flex items-center gap-2 {{ if .FilteringBy.IsOpen }}font-bold {{ else }}text-gray-500 dark:text-gray-400{{ end }}" 37 - > 38 - {{ i "git-pull-request" "w-4 h-4" }} 39 - <span>{{ .RepoInfo.Stats.PullCount.Open }} open</span> 40 - </a> 41 - <a 42 - href="?state=merged" 43 - class="flex items-center gap-2 {{ if .FilteringBy.IsMerged }}font-bold {{ else }}text-gray-500 dark:text-gray-400{{ end }}" 44 - > 45 - {{ i "git-merge" "w-4 h-4" }} 46 - <span>{{ .RepoInfo.Stats.PullCount.Merged }} merged</span> 47 - </a> 48 - <a 49 - href="?state=closed" 50 - class="flex items-center gap-2 {{ if .FilteringBy.IsClosed }}font-bold {{ else }}text-gray-500 dark:text-gray-400{{ end }}" 51 - > 52 - {{ i "ban" "w-4 h-4" }} 53 - <span>{{ .RepoInfo.Stats.PullCount.Closed }} closed</span> 54 - </a> 61 + <div class="sm:hidden"> 62 + {{ template "fragments/tabSelector" (dict "Name" "state" "Values" $values "Active" $active) }} 55 63 </div> 56 - <div class="error" id="pulls"></div> 64 + </div> 65 + <div class="error" id="pulls"></div> 57 66 {{ end }} 58 67 59 68 {{ define "repoAfter" }}