ikurotime / gitgud

public
main / internal/interface/web/templates/browse_blob.templ
1.3 KB · Templ Raw
 1package templates
 2
 3import "gitgud/internal/domain"
 4
 5templ BrowseBlob(user *domain.User, repo *domain.Repository, ref string, blob *domain.FileBlob, highlighted string) {
 6	@Layout(blob.Path+" · gitgud", user) {
 7		@repoHeader(repo, "code")
 8		<div class="mb-3 flex items-center gap-2 font-mono text-sm">
 9			<span class="inline-flex items-center gap-2 rounded-md border border-line2 bg-panel2 px-2.5 py-1 text-xs text-ink">
10				<span class="inline-block size-2 rounded-full border-[1.5px] border-accent"></span>{ ref }
11			</span>
12			<span class="text-faint">/</span>
13			<span class="text-accent">{ blob.Path }</span>
14		</div>
15		<div class="card overflow-hidden">
16			<div class="flex items-center justify-between border-b border-line bg-[#0e1410] px-4 py-2.5 font-mono text-xs text-muted">
17				<span>{ humanSize(blob.Size) } · <span class="text-accent">{ langLabel(blob.Path) }</span></span>
18				<a class="rounded border border-line2 px-2.5 py-1 text-ink transition hover:border-faint hover:bg-panel2" href={ templ.SafeURL(repoPath(repo, "/raw/"+ref+"/"+blob.Path)) }>Raw</a>
19			</div>
20			if blob.IsBinary {
21				<div class="px-4 py-10 text-center text-sm text-faint">Binary file not shown.</div>
22			} else {
23				<div class="overflow-x-auto bg-[#0c0c0c] text-xs leading-relaxed [&_pre]:!bg-transparent">
24					@templ.Raw(highlighted)
25				</div>
26			}
27		</div>
28	}
29}