1{{ define "repo/fragments/unifiedDiff" }}
2{{ $name := .Id }}
3<pre class="overflow-x-auto"><div class="overflow-x-auto"><div class="min-w-full inline-block">{{- range .TextFragments -}}<div class="bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 select-none text-center">···</div>
4 {{- $oldStart := .OldPosition -}}
5 {{- $newStart := .NewPosition -}}
6 {{- $lineNrStyle := "min-w-[3.5rem] flex-shrink-0 select-none text-right bg-white dark:bg-gray-800 target:bg-yellow-200 target:dark:bg-yellow-600" -}}
7 {{- $linkStyle := "text-gray-400 dark:text-gray-500 hover:underline" -}}
8 {{- $lineNrSepStyle1 := "" -}}
9 {{- $lineNrSepStyle2 := "pr-2 border-r border-gray-200 dark:border-gray-700" -}}
10 {{- $containerStyle := "flex min-w-full items-center target:border target:rounded-sm target:border-yellow-200 target:dark:border-yellow-700 scroll-mt-20" -}}
11 {{- $addStyle := "bg-green-100 dark:bg-green-800/30 text-green-700 dark:text-green-400 " -}}
12 {{- $delStyle := "bg-red-100 dark:bg-red-800/30 text-red-700 dark:text-red-400 " -}}
13 {{- $ctxStyle := "bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400" -}}
14 {{- $opStyle := "w-5 flex-shrink-0 select-none text-center" -}}
15 {{- range .Lines -}}
16 {{- if eq .Op.String "+" -}}
17 <div class="{{ $addStyle }} {{ $containerStyle }}" id="{{$name}}-N{{$newStart}}">
18 <div class="{{$lineNrStyle}} {{$lineNrSepStyle1}}"><span aria-hidden="true" class="invisible">{{$newStart}}</span></div>
19 <div class="{{$lineNrStyle}} {{$lineNrSepStyle2}}"><a class="{{$linkStyle}}" href="#{{$name}}-N{{$newStart}}">{{ $newStart }}</a></div>
20 <div class="{{ $opStyle }}">{{ .Op.String }}</div>
21 <div class="px-2">{{ .Line }}</div>
22 </div>
23 {{- $newStart = add64 $newStart 1 -}}
24 {{- end -}}
25 {{- if eq .Op.String "-" -}}
26 <div class="{{ $delStyle }} {{ $containerStyle }}" id="{{$name}}-O{{$oldStart}}">
27 <div class="{{$lineNrStyle}} {{$lineNrSepStyle1}}"><a class="{{$linkStyle}}" href="#{{$name}}-O{{$oldStart}}">{{ $oldStart }}</a></div>
28 <div class="{{$lineNrStyle}} {{$lineNrSepStyle2}}"><span aria-hidden="true" class="invisible">{{$oldStart}}</span></div>
29 <div class="{{ $opStyle }}">{{ .Op.String }}</div>
30 <div class="px-2">{{ .Line }}</div>
31 </div>
32 {{- $oldStart = add64 $oldStart 1 -}}
33 {{- end -}}
34 {{- if eq .Op.String " " -}}
35 <div class="{{ $ctxStyle }} {{ $containerStyle }}" id="{{$name}}-O{{$oldStart}}-N{{$newStart}}">
36 <div class="{{$lineNrStyle}} {{$lineNrSepStyle1}}"><a class="{{$linkStyle}}" href="#{{$name}}-O{{$oldStart}}-N{{$newStart}}">{{ $oldStart }}</a></div>
37 <div class="{{$lineNrStyle}} {{$lineNrSepStyle2}}"><a class="{{$linkStyle}}" href="#{{$name}}-O{{$oldStart}}-N{{$newStart}}">{{ $newStart }}</a></div>
38 <div class="{{ $opStyle }}">{{ .Op.String }}</div>
39 <div class="px-2">{{ .Line }}</div>
40 </div>
41 {{- $newStart = add64 $newStart 1 -}}
42 {{- $oldStart = add64 $oldStart 1 -}}
43 {{- end -}}
44 {{- end -}}
45 {{- end -}}</div></div></pre>
46{{ end }}
47