BigW Consortium Gitlab

made the changed files holder sticky

parent 655510ec
export const isSticky = (el, stickyTop) => {
const top = el.getBoundingClientRect().top;
if (top === stickyTop) {
el.classList.add('is-stuck');
} else {
el.classList.remove('is-stuck');
}
};
export default (el) => {
const computedStyle = window.getComputedStyle(el);
if (!/sticky/.test(computedStyle.position)) return;
const stickyTop = parseInt(computedStyle.top, 10);
document.addEventListener('scroll', () => isSticky(el, stickyTop), {
passive: true,
});
};
...@@ -7,6 +7,7 @@ import Cookies from 'js-cookie'; ...@@ -7,6 +7,7 @@ import Cookies from 'js-cookie';
import './breakpoints'; import './breakpoints';
import './flash'; import './flash';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
import stickyMonitor from './lib/utils/sticky';
/* eslint-disable max-len */ /* eslint-disable max-len */
// MergeRequestTabs // MergeRequestTabs
...@@ -268,6 +269,8 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion'; ...@@ -268,6 +269,8 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion';
this.initChangesDropdown(); this.initChangesDropdown();
stickyMonitor(document.querySelector('.js-diff-files-changed'));
if (typeof gl.diffNotesCompileComponents !== 'undefined') { if (typeof gl.diffNotesCompileComponents !== 'undefined') {
gl.diffNotesCompileComponents(); gl.diffNotesCompileComponents();
} }
......
...@@ -559,6 +559,47 @@ ...@@ -559,6 +559,47 @@
} }
} }
.diff-files-changed {
.commit-stat-summary {
z-index: -1;
}
@media (min-width: $screen-sm-min) {
position: -webkit-sticky;
position: sticky;
top: 100px;
background-color: $white-light;
z-index: 190;
+ .files {
margin-top: 1px;
}
.diff-stats-additions-deletions-collapsed {
display: none;
}
&.is-stuck {
padding-top: 0;
padding-bottom: 0;
border-bottom: 1px solid $white-dark;
.diff-stats-additions-deletions-expanded,
.inline-parallel-buttons {
display: none;
}
.diff-stats-additions-deletions-collapsed {
display: block;
}
+ .files {
margin-top: 16px;
}
}
}
}
.diff-file-changes { .diff-file-changes {
width: 450px; width: 450px;
z-index: 150; z-index: 150;
......
- sum_added_lines = diff_files.sum(&:added_lines)
- sum_removed_lines = diff_files.sum(&:removed_lines)
.commit-stat-summary.dropdown .commit-stat-summary.dropdown
Showing Showing
%button.diff-stats-summary-toggler.js-diff-stats-dropdown{ type: "button", data: { toggle: "dropdown" } }< %button.diff-stats-summary-toggler.js-diff-stats-dropdown{ type: "button", data: { toggle: "dropdown" } }<
= pluralize(diff_files.size, "changed file") = pluralize(diff_files.size, "changed file")
= icon("caret-down fw") = icon("caret-down fw")
%span.diff-stats-additions-deletions-expanded
with with
%strong.cgreen #{diff_files.sum(&:added_lines)} additions %strong.cgreen #{sum_added_lines} additions
and and
%strong.cred #{diff_files.sum(&:removed_lines)} deletions %strong.cred #{sum_removed_lines} deletions
.diff-stats-additions-deletions-collapsed.pull-right{ "aria-hidden": "true" }
%strong.cgreen<
+#{sum_added_lines}
%strong.cred<
\-#{sum_removed_lines}
.dropdown-menu.diff-file-changes .dropdown-menu.diff-file-changes
= dropdown_filter("Search file") = dropdown_filter("Search file")
.dropdown-content .dropdown-content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment