5
5
<button
6
6
type =" button"
7
7
@click =" copyUrlToClipboard"
8
- class =" inline-flex justify-center px-4 py-2 text-white transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
8
+ class =" inline-flex justify-center px-4 py-2 transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
9
9
v-bind:class =" {
10
10
'bg-blue-600 text-white': !copied,
11
11
'bg-green-500 text-gray-800': copied,
51
51
<main >
52
52
<div class =" flex items-start w-full gap-4" >
53
53
<div
54
- class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm max-h-screen--nav line-numbers min-h-80"
54
+ class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm max-h-screen--nav line-number-gutter min-h-80"
55
55
>
56
56
<RTStickyCopyButton :clickHandler =" copyTextToClipboard" />
57
- <p v-for =" (lineDiff, index) in lhsDiff" :key =" index" >
58
- <span v-html =" lineDiff" ></span >
59
- </p >
57
+ <div v-for =" (lineDiff, index) in lhsDiff" :key =" index" >
58
+ <p
59
+ class =" font-mono break-all whitespace-pre-wrap"
60
+ v-html =" lineDiff"
61
+ ></p >
62
+ </div >
60
63
</div >
61
64
<div
62
- class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm min-h-80 line-numbers max-h-screen--nav"
65
+ class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm min-h-80 line-number-gutter max-h-screen--nav"
63
66
>
64
67
<RTStickyCopyButton :clickHandler =" copyTextToClipboard" />
65
- <p v-for =" (lineDiff, index) in rhsDiff" :key =" index" >
66
- <span v-html =" lineDiff" ></span >
67
- </p >
68
+ <div v-for =" (lineDiff, index) in rhsDiff" :key =" index" >
69
+ <p
70
+ class =" font-mono break-all whitespace-pre-wrap"
71
+ v-html =" lineDiff"
72
+ ></p >
73
+ </div >
68
74
</div >
69
75
</div >
70
76
</main >
@@ -81,33 +87,29 @@ export default {
81
87
const gunzip = pako .ungzip (Buffer .from (undoUrlSafeBase64 (_diff), ' base64' ))
82
88
const diff = JSON .parse (Buffer .from (gunzip).toString (' utf8' ))
83
89
this .lhsDiff = diff
84
- .map ((lineDiff ) => {
85
- return lineDiff
86
- .map ((item ) => {
87
- if (item[0 ] === - 1 || item[0 ] === 0 ) {
88
- const className = item[0 ] === - 1 ? ' bg-red-300' : ' '
89
- return ` <span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${ className} ">${ item[1 ]} </span>`
90
- }
91
- return ' '
92
- })
93
- .filter (Boolean )
94
- .join (' \n ' )
90
+ .map ((item ) => {
91
+ const hunkState = item[0 ]
92
+ if (hunkState === - 1 || hunkState === 0 ) {
93
+ const className = hunkState === - 1 ? ' bg-red-400' : ' '
94
+ return ` <span class="font-mono break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
95
+ }
96
+ return false
95
97
})
96
98
.filter (Boolean )
99
+ .join (' ' )
100
+ .split (' \n ' )
97
101
this .rhsDiff = diff
98
- .map ((lineDiff ) => {
99
- return lineDiff
100
- .map ((item ) => {
101
- if (item[0 ] === 1 || item[0 ] === 0 ) {
102
- const className = item[0 ] === 1 ? ' bg-green-300' : ' '
103
- return ` <span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${ className} ">${ item[1 ]} </span>`
104
- }
105
- return ' '
106
- })
107
- .filter (Boolean )
108
- .join (' \n ' )
102
+ .map ((item ) => {
103
+ const hunkState = item[0 ]
104
+ if (hunkState === 1 || hunkState === 0 ) {
105
+ const className = hunkState === 1 ? ' bg-green-400' : ' '
106
+ return ` <span class="font-mono break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
107
+ }
108
+ return false
109
109
})
110
110
.filter (Boolean )
111
+ .join (' ' )
112
+ .split (' \n ' )
111
113
const maxLineCount =
112
114
this .lhsDiff .length > this .rhsDiff .length
113
115
? this .lhsDiff .length
@@ -177,19 +179,22 @@ export default {
177
179
}
178
180
179
181
/* line numbers in diff view */
180
- .line-numbers {
182
+ .line-number-gutter {
181
183
counter-reset : line- numbers;
184
+
185
+ --line-number-gutter-width : calc (var (--max-line-number-characher ) + 10px );
182
186
@apply relative ;
183
187
p {
184
- padding-left : calc (var (--max-line-number-characher ) - 4px );
188
+ padding-left : calc (var (--line-number-gutter-width ) - 10px );
189
+ line-height : 1.65 ;
185
190
@apply relative ;
186
191
& :hover {
187
192
@apply bg-gray- 200;
188
193
}
189
194
& ::before {
190
195
counter-increment : line- numbers;
191
196
content : counter (line-numbers );
192
- width : calc ( var (--max- line-number-characher ) + 4 px );
197
+ width : var (--line-number-gutter-width );
193
198
@apply absolute left-0 top-0 -mx- 4 bottom-0 text-center bg-gray-200 text-gray-500 flex justify-center items-center text-sm ;
194
199
}
195
200
& :first-of-type {
0 commit comments