forked from tangled.org/core
this repo has no description

appview/pages: add diff opts selector

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by Tangled 82208177 23a0ae17

Changed files
+54 -16
appview
types
+4 -1
appview/pages/templates/repo/commit.html
··· 123 123 {{end}} 124 124 125 125 {{ define "contentAfterLeft" }} 126 - <div class="sticky top-0"> 126 + <div class="flex flex-col gap-4 col-span-1 md:col-span-2 mt-4"> 127 + {{ template "repo/fragments/diffOpts" .DiffOpts }} 128 + </div> 129 + <div class="sticky top-0 mt-4"> 127 130 {{ template "repo/fragments/diffChangedFiles" .Diff }} 128 131 </div> 129 132 {{end}}
+5 -2
appview/pages/templates/repo/compare/compare.html
··· 54 54 {{end}} 55 55 56 56 {{ define "contentAfterLeft" }} 57 - <div class="sticky top-0"> 58 - {{ template "repo/fragments/diffChangedFiles" .Diff }} 57 + <div class="flex flex-col gap-4 col-span-1 md:col-span-2 mt-4"> 58 + {{ template "repo/fragments/diffOpts" .DiffOpts }} 59 + </div> 60 + <div class="sticky top-0 mt-4"> 61 + {{ template "repo/fragments/diffChangedFiles" .Diff }} 59 62 </div> 60 63 {{end}}
+8 -10
appview/pages/templates/repo/fragments/diffChangedFiles.html
··· 1 1 {{ define "repo/fragments/diffChangedFiles" }} 2 2 {{ $stat := .Stat }} 3 3 {{ $fileTree := fileTree .ChangedFiles }} 4 - <div class="col-span-1 md:col-span-2 mt-4"> 5 - <section class="sticky top-0 overflow-x-auto text-sm px-6 py-2 border border-gray-200 dark:border-gray-700 w-full mx-auto md:min-h-screen rounded bg-white dark:bg-gray-800 drop-shadow-sm"> 6 - <div class="diff-stat"> 7 - <div class="flex gap-2 items-center"> 8 - <strong class="text-sm uppercase dark:text-gray-200">Changed files</strong> 9 - {{ template "repo/fragments/diffStatPill" $stat }} 10 - </div> 11 - {{ template "repo/fragments/fileTree" $fileTree }} 4 + <section class="overflow-x-auto text-sm px-6 py-2 border border-gray-200 dark:border-gray-700 w-full mx-auto md:min-h-screen rounded bg-white dark:bg-gray-800 drop-shadow-sm"> 5 + <div class="diff-stat"> 6 + <div class="flex gap-2 items-center"> 7 + <strong class="text-sm uppercase dark:text-gray-200">Changed files</strong> 8 + {{ template "repo/fragments/diffStatPill" $stat }} 12 9 </div> 13 - </section> 14 - </div> 10 + {{ template "repo/fragments/fileTree" $fileTree }} 11 + </div> 12 + </section> 15 13 {{ end }}
+28
appview/pages/templates/repo/fragments/diffOpts.html
··· 1 + {{ define "repo/fragments/diffOpts" }} 2 + <section class="flex flex-col gap-2 overflow-x-auto text-sm px-6 py-2 border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm"> 3 + <strong class="text-sm uppercase dark:text-gray-200">options</strong> 4 + {{ $active := "unified" }} 5 + {{ if .Split }} 6 + {{ $active = "split" }} 7 + {{ end }} 8 + {{ $values := list "unified" "split" }} 9 + {{ block "tabSelector" (dict "Name" "diff" "Values" $values "Active" $active) }} {{ end }} 10 + </section> 11 + {{ end }} 12 + 13 + {{ define "tabSelector" }} 14 + {{ $name := .Name }} 15 + {{ $all := .Values }} 16 + {{ $active := .Active }} 17 + <div class="flex justify-between divide-x divide-gray-200 dark:divide-gray-700 rounded border border-gray-200 dark:border-gray-700 overflow-hidden"> 18 + {{ $activeTab := "bg-white dark:bg-gray-700 shadow-sm" }} 19 + {{ $inactiveTab := "bg-gray-100 dark:bg-gray-800 shadow-inner" }} 20 + {{ range $index, $value := $all }} 21 + {{ $isActive := eq $value $active }} 22 + <a href="?{{ $name }}={{ $value }}" 23 + class="py-2 text-sm w-full block hover:no-underline text-center {{ if $isActive }} {{$activeTab }} {{ else }} {{ $inactiveTab }} {{ end }}"> 24 + {{ $value }} 25 + </a> 26 + {{ end }} 27 + </div> 28 + {{ end }}
+4 -1
appview/pages/templates/repo/pulls/interdiff.html
··· 72 72 {{end}} 73 73 74 74 {{ define "contentAfterLeft" }} 75 - <div class="sticky top-0"> 75 + <div class="flex flex-col gap-4 col-span-1 md:col-span-2 mt-4"> 76 + {{ template "repo/fragments/diffOpts" .DiffOpts }} 77 + </div> 78 + <div class="sticky top-0 mt-4"> 76 79 {{ template "repo/fragments/interdiffFiles" .Interdiff }} 77 80 </div> 78 81 {{end}}
+4 -1
appview/pages/templates/repo/pulls/patch.html
··· 78 78 {{end}} 79 79 80 80 {{ define "contentAfterLeft" }} 81 - <div class="sticky top-0"> 81 + <div class="flex flex-col gap-4 col-span-1 md:col-span-2 mt-4"> 82 + {{ template "repo/fragments/diffOpts" .DiffOpts }} 83 + </div> 84 + <div class="sticky top-0 mt-4"> 82 85 {{ template "repo/fragments/diffChangedFiles" .Diff }} 83 86 </div> 84 87 {{end}}
+1 -1
types/split.go
··· 36 36 lines := fragment.Lines 37 37 var leftLines, rightLines []SplitLine 38 38 oldLineNum := fragment.OldPosition 39 - newLineNum := fragment.OldPosition 39 + newLineNum := fragment.NewPosition 40 40 41 41 // process deletions and additions in groups for better alignment 42 42 i := 0