Skip to content

Commit 09faf43

Browse files
authored
Improve Image Diff UI (#26696)
1. Use `is-loading` instead of `ui loader` 2. Introduce class name `image-diff-tabs`, instead of searching `gt-hidden`, which is fragile 3. Align the UI elements, see the screenshots.
1 parent 4de2244 commit 09faf43

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

templates/repo/diff/image_diff.tmpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{end}}
1212
</div>
1313
</div>
14-
<div class="gt-hidden">
14+
<div class="image-diff-tabs is-loading">
1515
<div class="ui bottom attached tab image-diff-container active" data-tab="diff-side-by-side-{{.file.Index}}">
1616
<div class="diff-side-by-side">
1717
{{if .blobBase}}
@@ -63,18 +63,15 @@
6363
</div>
6464
<div class="ui bottom attached tab image-diff-container" data-tab="diff-overlay-{{.file.Index}}">
6565
<div class="diff-overlay">
66+
<input type="range" min="0" max="100" value="50">
6667
<div class="overlay-frame">
67-
<div class="ui centered">
68-
<input type="range" min="0" max="100" value="50">
69-
</div>
7068
<span class="before-container"><img class="image-before"></span>
7169
<span class="after-container"><img class="image-after"></span>
7270
</div>
7371
</div>
7472
</div>
7573
{{end}}
7674
</div>
77-
<div class="ui active centered inline loader gt-mb-4"></div>
7875
</div>
7976
</td>
8077
</tr>

web_src/css/features/imagediff.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
.image-diff-tabs {
2+
min-height: 60px;
3+
4+
}
5+
.image-diff-tabs.is-loading .tab {
6+
display: none;
7+
}
8+
19
.image-diff-container {
210
text-align: center;
3-
padding: 1em 0;
11+
padding: 0.5em 0 1em;
412
}
513

614
.image-diff-container img {
@@ -31,6 +39,7 @@
3139

3240
.image-diff-container .diff-swipe {
3341
margin: auto;
42+
padding: 1em 0;
3443
}
3544

3645
.image-diff-container .diff-swipe .swipe-frame {
@@ -89,7 +98,7 @@
8998
}
9099

91100
.image-diff-container .diff-overlay .overlay-frame {
92-
margin: 0 auto;
101+
margin: 1em auto 0;
93102
position: relative;
94103
}
95104

web_src/js/features/imagediff.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ export function initImageDiff() {
130130
initOverlay(createContext($imageAfter[2], $imageBefore[2]));
131131
}
132132

133-
$container.find('> .gt-hidden').removeClass('gt-hidden');
134-
hideElem($container.find('.ui.loader'));
133+
$container.find('> .image-diff-tabs').removeClass('is-loading');
135134
}
136135

137136
function initSideBySide(sizes) {
@@ -205,7 +204,7 @@ export function initImageDiff() {
205204
});
206205
$container.find('.diff-swipe').css({
207206
width: sizes.max.width * factor + 2,
208-
height: sizes.max.height * factor + 4
207+
height: sizes.max.height * factor + 30 /* extra height for inner "position: absolute" elements */,
209208
});
210209
$container.find('.swipe-bar').on('mousedown', function(e) {
211210
e.preventDefault();
@@ -261,7 +260,7 @@ export function initImageDiff() {
261260
// the "css(width, height)" is somewhat hacky and not easy to understand, it could be improved in the future
262261
sizes.image2.parent().parent().css({
263262
width: sizes.max.width * factor + 2,
264-
height: sizes.max.height * factor + 2 + 20 /* extra height for inner "position: absolute" elements */,
263+
height: sizes.max.height * factor + 2,
265264
});
266265

267266
const $range = $container.find("input[type='range']");

0 commit comments

Comments
 (0)