Skip to content

Improve Image Diff UI #26696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions templates/repo/diff/image_diff.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{end}}
</div>
</div>
<div class="gt-hidden">
<div class="image-diff-tabs is-loading">
<div class="ui bottom attached tab image-diff-container active" data-tab="diff-side-by-side-{{.file.Index}}">
<div class="diff-side-by-side">
{{if .blobBase}}
Expand Down Expand Up @@ -63,18 +63,15 @@
</div>
<div class="ui bottom attached tab image-diff-container" data-tab="diff-overlay-{{.file.Index}}">
<div class="diff-overlay">
<input type="range" min="0" max="100" value="50">
<div class="overlay-frame">
<div class="ui centered">
<input type="range" min="0" max="100" value="50">
</div>
<span class="before-container"><img class="image-before"></span>
<span class="after-container"><img class="image-after"></span>
</div>
</div>
</div>
{{end}}
</div>
<div class="ui active centered inline loader gt-mb-4"></div>
</div>
</td>
</tr>
Expand Down
13 changes: 11 additions & 2 deletions web_src/css/features/imagediff.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
.image-diff-tabs {
min-height: 60px;

}
.image-diff-tabs.is-loading .tab {
display: none;
}

.image-diff-container {
text-align: center;
padding: 1em 0;
padding: 0.5em 0 1em;
}

.image-diff-container img {
Expand Down Expand Up @@ -31,6 +39,7 @@

.image-diff-container .diff-swipe {
margin: auto;
padding: 1em 0;
}

.image-diff-container .diff-swipe .swipe-frame {
Expand Down Expand Up @@ -89,7 +98,7 @@
}

.image-diff-container .diff-overlay .overlay-frame {
margin: 0 auto;
margin: 1em auto 0;
position: relative;
}

Expand Down
7 changes: 3 additions & 4 deletions web_src/js/features/imagediff.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export function initImageDiff() {
initOverlay(createContext($imageAfter[2], $imageBefore[2]));
}

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

function initSideBySide(sizes) {
Expand Down Expand Up @@ -205,7 +204,7 @@ export function initImageDiff() {
});
$container.find('.diff-swipe').css({
width: sizes.max.width * factor + 2,
height: sizes.max.height * factor + 4
height: sizes.max.height * factor + 30 /* extra height for inner "position: absolute" elements */,
});
$container.find('.swipe-bar').on('mousedown', function(e) {
e.preventDefault();
Expand Down Expand Up @@ -261,7 +260,7 @@ export function initImageDiff() {
// the "css(width, height)" is somewhat hacky and not easy to understand, it could be improved in the future
sizes.image2.parent().parent().css({
width: sizes.max.width * factor + 2,
height: sizes.max.height * factor + 2 + 20 /* extra height for inner "position: absolute" elements */,
height: sizes.max.height * factor + 2,
});

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