ikurotime / gitgud

public
main / internal/interface/web/templates/issues_list.templ
1.7 KB · Templ Raw
 1package templates
 2
 3import "gitgud/internal/domain"
 4
 5templ IssuesList(user *domain.User, repo *domain.Repository, state string, issues []*domain.Issue, openCount, closedCount int) {
 6	@Layout("Issues · "+repo.Name, user) {
 7		@repoHeader(repo, "issues")
 8		<div class="mb-4 flex items-center justify-between">
 9			<div class="flex gap-5 text-sm">
10				<a class={ stateTabClass(state, "open") } href={ templ.SafeURL(repoPath(repo, "/issues?state=open")) }>{ itoa(openCount) } Open</a>
11				<a class={ stateTabClass(state, "closed") } href={ templ.SafeURL(repoPath(repo, "/issues?state=closed")) }>{ itoa(closedCount) } Closed</a>
12			</div>
13			if user != nil {
14				<a class="btn btn-primary" href={ templ.SafeURL(repoPath(repo, "/issues/new")) }>+ New issue</a>
15			}
16		</div>
17		if len(issues) == 0 {
18			@emptyState("No issues here", "There are no "+state+" issues in this repository.", "", "")
19		} else {
20			<div class="card overflow-hidden">
21				for _, i := range issues {
22					<div class="row border-b border-line px-4 py-3 last:border-0">
23						<a class="flex items-start gap-2.5" href={ templ.SafeURL(repoPath(repo, "/issues/"+itoa(i.Number))) }>
24							@issueDot(string(i.State))
25							<span class="min-w-0">
26								<span class="block text-ink hover:text-accent">{ i.Title }</span>
27								<span class="meta">#{ itoa(i.Number) } · opened by { i.AuthorName } · { fmtTime(i.CreatedAt) }</span>
28							</span>
29						</a>
30					</div>
31				}
32			</div>
33		}
34	}
35}
36
37templ issueDot(state string) {
38	if state == "open" {
39		<span class="mt-1 size-3.5 shrink-0 rounded-full border-2 border-accent"></span>
40	} else {
41		<span class="mt-1 size-3.5 shrink-0 rounded-full border-2 border-faint"></span>
42	}
43}