this repo has no description
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
12 {{ $last := sub (len $diff) 1 }}
13 {{ range $idx, $hunk := $diff }}
14 {{ with $hunk }}
15 <section class="mt-4 border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm">
16 <div id="file-{{ .Name.New }}">
17 <div id="diff-file">
18 <details open>
19 <summary class="list-none cursor-pointer sticky top-0">
20 <div id="diff-file-header" class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between">
21 <div id="left-side-items" class="p-2 flex gap-2 items-center overflow-x-auto">
22 <div class="flex gap-1 items-center">
23 {{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }}
24 {{ if .IsNew }}
25 <span class="bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400 {{ $markerstyle }}">ADDED</span>
26 {{ else if .IsDelete }}
27 <span class="bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400 {{ $markerstyle }}">DELETED</span>
28 {{ else if .IsCopy }}
29 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">COPIED</span>
30 {{ else if .IsRename }}
31 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">RENAMED</span>
32 {{ else }}
33 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">MODIFIED</span>
34 {{ end }}
35
36 {{ template "repo/fragments/diffStatPill" .Stats }}
37 </div>
38
39 <div class="flex gap-2 items-center overflow-x-auto">
40 {{ if .IsDelete }}
41 <a class="dark:text-white whitespace-nowrap overflow-x-auto" {{if $this }}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}"{{end}}>
42 {{ .Name.Old }}
43 </a>
44 {{ else if (or .IsCopy .IsRename) }}
45 <a class="dark:text-white whitespace-nowrap overflow-x-auto" {{if $parent}}href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}"{{end}}>
46 {{ .Name.Old }}
47 </a>
48 {{ i "arrow-right" "w-4 h-4" }}
49 <a class="dark:text-white whitespace-nowrap overflow-x-auto" {{if $this}}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}"{{end}}>
50 {{ .Name.New }}
51 </a>
52 {{ else }}
53 <a class="dark:text-white whitespace-nowrap overflow-x-auto" {{if $this}}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}"{{end}}>
54 {{ .Name.New }}
55 </a>
56 {{ end }}
57 </div>
58 </div>
59
60 {{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" }}
61 <div id="right-side-items" class="p-2 flex items-center">
62 <a title="top of file" href="#file-{{ .Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-up-to-line" "w-4 h-4" }}</a>
63 {{ if gt $idx 0 }}
64 {{ $prev := index $diff (sub $idx 1) }}
65 <a title="previous file" href="#file-{{ $prev.Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-up" "w-4 h-4" }}</a>
66 {{ end }}
67
68 {{ if lt $idx $last }}
69 {{ $next := index $diff (add $idx 1) }}
70 <a title="next file" href="#file-{{ $next.Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-down" "w-4 h-4" }}</a>
71 {{ end }}
72 </div>
73
74 </div>
75 </summary>
76
77 <div class="transition-all duration-700 ease-in-out">
78 {{ if .IsDelete }}
79 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
80 This file has been deleted.
81 </p>
82 {{ else if .IsCopy }}
83 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
84 This file has been copied.
85 </p>
86 {{ else if .IsBinary }}
87 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
88 This is a binary file and will not be displayed.
89 </p>
90 {{ else }}
91 {{ if $isSplit }}
92 {{- template "repo/fragments/splitDiff" .Split -}}
93 {{ else }}
94 {{- template "repo/fragments/unifiedDiff" . -}}
95 {{ end }}
96 {{- end -}}
97 </div>
98
99 </details>
100
101 </div>
102 </div>
103 </section>
104 {{ end }}
105 {{ end }}
106{{ end }}