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