Monorepo for Tangled
tangled.org
1{{ define "repo/fragments/diff" }}
2 {{ $diff := index . 0 }}
3 {{ $opts := index . 1 }}
4
5 {{ $commit := $diff.Commit }}
6 {{ $diff := $diff.Diff }}
7 {{ $isSplit := $opts.Split }}
8 {{ $this := $commit.This }}
9 {{ $parent := $commit.Parent }}
10 {{ $last := sub (len $diff) 1 }}
11
12 <div class="flex flex-col gap-4">
13 {{ if eq (len $diff) 0 }}
14 <div class="text-center text-gray-500 dark:text-gray-400 py-8">
15 <p>No differences found between the selected revisions.</p>
16 </div>
17 {{ else }}
18 {{ range $idx, $hunk := $diff }}
19 {{ with $hunk }}
20 <details open id="file-{{ .Id }}" class="group border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm" tabindex="{{ add $idx 1 }}">
21 <summary class="list-none cursor-pointer sticky top-0">
22 <div id="diff-file-header" class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between">
23 <div id="left-side-items" class="p-2 flex gap-2 items-center overflow-x-auto">
24 <span class="group-open:hidden inline">{{ i "chevron-right" "w-4 h-4" }}</span>
25 <span class="hidden group-open:inline">{{ i "chevron-down" "w-4 h-4" }}</span>
26 {{ template "repo/fragments/diffStatPill" .Stats }}
27
28 <div class="flex gap-2 items-center overflow-x-auto">
29 {{ if .IsDelete }}
30 {{ .Name.Old }}
31 {{ else if (or .IsCopy .IsRename) }}
32 {{ .Name.Old }} {{ i "arrow-right" "w-4 h-4" }} {{ .Name.New }}
33 {{ else }}
34 {{ .Name.New }}
35 {{ end }}
36 </div>
37 </div>
38 </div>
39 </summary>
40
41 <div class="transition-all duration-700 ease-in-out">
42 {{ if .IsBinary }}
43 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
44 This is a binary file and will not be displayed.
45 </p>
46 {{ else }}
47 {{ if $isSplit }}
48 {{- template "repo/fragments/splitDiff" .Split -}}
49 {{ else }}
50 {{- template "repo/fragments/unifiedDiff" . -}}
51 {{ end }}
52 {{- end -}}
53 </div>
54 </details>
55 {{ end }}
56 {{ end }}
57 {{ end }}
58 </div>
59{{ end }}