From 1d01e164ec7bbf0b30ba21753604227eaa469216 Mon Sep 17 00:00:00 2001 From: Sam Bigelow Date: Thu, 28 Mar 2019 17:37:06 -0400 Subject: Improve diff navigation header - Compare versions header is full width except in the unified diff mode with no tree sidebar - Bar is always full width, but the content within stays centered when unified and no tree sidebar - File header is the same height as the "Compare versions header" - aligns with the design system grid guidelines => 56px - Diff file headers use a button group, switch icon order to open file externally being the last option, all buttons will become icon buttons (icon delivery by @dimitrieh) - If a file header becomes sticky no rounded corner/double border problem is visible anymore --- app/assets/javascripts/breakpoints.js | 3 + app/assets/javascripts/diffs/components/app.vue | 15 ++- .../diffs/components/compare_versions.vue | 18 ++- .../diffs/components/diff_file_header.vue | 137 +++++++++++---------- app/assets/javascripts/diffs/constants.js | 3 + app/assets/javascripts/lib/utils/common_utils.js | 9 +- app/assets/stylesheets/framework/files.scss | 4 + app/assets/stylesheets/pages/diff.scss | 8 +- app/assets/stylesheets/pages/merge_requests.scss | 16 +-- .../unreleased/57364-improve-diff-nav-header.yml | 5 + spec/javascripts/diffs/components/app_spec.js | 18 +++ .../diffs/components/compare_versions_spec.js | 20 +++ .../diffs/components/diff_file_header_spec.js | 4 +- spec/javascripts/lib/utils/common_utils_spec.js | 6 +- 14 files changed, 179 insertions(+), 87 deletions(-) create mode 100644 changelogs/unreleased/57364-improve-diff-nav-header.yml diff --git a/app/assets/javascripts/breakpoints.js b/app/assets/javascripts/breakpoints.js index 7951348d8b2..4d5d6bb864b 100644 --- a/app/assets/javascripts/breakpoints.js +++ b/app/assets/javascripts/breakpoints.js @@ -14,6 +14,9 @@ const BreakpointInstance = { return breakpoint; }, + isDesktop() { + return ['lg', 'md'].includes(this.getBreakpointSize); + }, }; export default BreakpointInstance; diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index e8f8c09152a..5e74998579b 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -20,6 +20,7 @@ import { MAX_TREE_WIDTH, TREE_HIDE_STATS_WIDTH, MR_TREE_SHOW_KEY, + CENTERED_LIMITED_CONTAINER_CLASSES, } from '../constants'; export default { @@ -114,6 +115,9 @@ export default { hideFileStats() { return this.treeWidth <= TREE_HIDE_STATS_WIDTH; }, + isLimitedContainer() { + return !this.showTreeList && !this.isParallelView; + }, }, watch: { diffViewType() { @@ -148,6 +152,7 @@ export default { this.adjustView(); eventHub.$once('fetchedNotesData', this.setDiscussions); eventHub.$once('fetchDiffData', this.fetchData); + this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES; }, beforeDestroy() { eventHub.$off('fetchDiffData', this.fetchData); @@ -202,8 +207,6 @@ export default { adjustView() { if (this.shouldShow) { this.$nextTick(() => { - window.mrTabs.resetViewContainer(); - window.mrTabs.expandViewContainer(this.showTreeList); this.setEventListeners(); }); } else { @@ -256,6 +259,7 @@ export default { :merge-request-diffs="mergeRequestDiffs" :merge-request-diff="mergeRequestDiff" :target-branch="targetBranch" + :is-limited-container="isLimitedContainer" /> -
+