Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzekiel Kigbo <ekigbo@gitlab.com>2019-03-04 07:49:18 +0300
committerEzekiel Kigbo <ekigbo@gitlab.com>2019-03-04 16:58:22 +0300
commitd53005ef167de0a4b5b560d173435f3e0d0b4d9f (patch)
tree72c3bd7b3af44c0a4efc51b8212144f248681e47 /app/assets/javascripts/contextual_sidebar.js
parent9ef058bee2b13b975cc52d9c9c688c6250ad2363 (diff)
Added test for interacting with the nav-sidebar on smaller screens
Use mobile collapsing behaviour at width 1200px
Diffstat (limited to 'app/assets/javascripts/contextual_sidebar.js')
-rw-r--r--app/assets/javascripts/contextual_sidebar.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/app/assets/javascripts/contextual_sidebar.js b/app/assets/javascripts/contextual_sidebar.js
index a9013025bad..7780ac8a1d2 100644
--- a/app/assets/javascripts/contextual_sidebar.js
+++ b/app/assets/javascripts/contextual_sidebar.js
@@ -4,7 +4,6 @@ import _ from 'underscore';
import bp from './breakpoints';
import { parseBoolean } from '~/lib/utils/common_utils';
-const DESKTOP_BREAKPOINTS = ['xl', 'lg'];
export default class ContextualSidebar {
constructor() {
this.initDomElements();
@@ -39,11 +38,9 @@ export default class ContextualSidebar {
this.$closeSidebar.on('click', () => this.toggleSidebarNav(false));
this.$overlay.on('click', () => this.toggleSidebarNav(false));
this.$sidebarToggle.on('click', () => {
- const breakpoint = bp.getBreakpointSize();
-
- if (!ContextualSidebar.isDesktopBreakpoint(breakpoint)) {
+ if (!ContextualSidebar.isDesktopBreakpoint()) {
this.toggleSidebarNav(!this.$sidebar.hasClass('sidebar-expanded-mobile'));
- } else if (breakpoint === 'lg') {
+ } else {
const value = !this.$sidebar.hasClass('sidebar-collapsed-desktop');
this.toggleCollapsedSidebar(value, true);
}
@@ -52,9 +49,13 @@ export default class ContextualSidebar {
$(window).on('resize', () => _.debounce(this.render(), 100));
}
+ // NOTE: at 1200px sidebar should be in 'desktop' mode
+ // https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24555#note_134136110
+ // But, current behaviour starts desktop mode at 1201px
+
// TODO: use the breakpoints from breakpoints.js once they have been updated for bootstrap 4
// See related issue and discussion: https://gitlab.com/gitlab-org/gitlab-ce/issues/56745
- static isDesktopBreakpoint = (_bp = '') => DESKTOP_BREAKPOINTS.indexOf(_bp) > -1;
+ static isDesktopBreakpoint = () => bp.windowWidth() > 1200;
static setCollapsedCookie(value) {
if (bp.getBreakpointSize() !== 'lg') {
return;
@@ -64,12 +65,11 @@ export default class ContextualSidebar {
toggleSidebarNav(show) {
const breakpoint = bp.getBreakpointSize();
- const dbp = ContextualSidebar.isDesktopBreakpoint(breakpoint);
+ const dbp = ContextualSidebar.isDesktopBreakpoint();
this.$sidebar.toggleClass('sidebar-expanded-mobile', !dbp ? show : false);
this.$overlay.toggleClass('mobile-nav-open', breakpoint === 'xs' ? show : false);
this.$sidebar.removeClass('sidebar-collapsed-desktop');
- this.$page.toggleClass('page-with-contextual-sidebar', true);
}
toggleCollapsedSidebar(collapsed, saveCookie) {
@@ -80,7 +80,6 @@ export default class ContextualSidebar {
this.$sidebar.toggleClass('sidebar-collapsed-desktop', collapsed);
this.$sidebar.toggleClass('sidebar-expanded-mobile', !dbp ? !collapsed : false);
this.$page.toggleClass('page-with-icon-sidebar', breakpoint === 'sm' ? true : collapsed);
- this.$page.toggleClass('page-with-contextual-sidebar', true);
}
if (saveCookie) {
@@ -102,7 +101,7 @@ export default class ContextualSidebar {
if (!this.$sidebar.length) return;
const breakpoint = bp.getBreakpointSize();
- if (!ContextualSidebar.isDesktopBreakpoint(breakpoint)) {
+ if (!ContextualSidebar.isDesktopBreakpoint()) {
this.toggleSidebarNav(false);
} else if (breakpoint === 'lg') {
const collapse = parseBoolean(Cookies.get('sidebar_collapsed'));