Add mobile navigation on project page
This commit is contained in:
parent
fe0c3b79d9
commit
cb83c50d46
6 changed files with 117 additions and 31 deletions
|
@ -1,5 +1,6 @@
|
||||||
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, no-unused-vars, one-var, one-var-declaration-per-line, vars-on-top, max-len */
|
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, no-unused-vars, one-var, one-var-declaration-per-line, vars-on-top, max-len */
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
|
import NewNavSidebar from './new_sidebar';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var hideEndFade;
|
var hideEndFade;
|
||||||
|
@ -53,6 +54,7 @@ import _ from 'underscore';
|
||||||
}
|
}
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
|
new NewNavSidebar();
|
||||||
$(window).on('scroll', _.throttle(applyScrollNavClass, 100));
|
$(window).on('scroll', _.throttle(applyScrollNavClass, 100));
|
||||||
});
|
});
|
||||||
}).call(window);
|
}).call(window);
|
||||||
|
|
23
app/assets/javascripts/new_sidebar.js
Normal file
23
app/assets/javascripts/new_sidebar.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const SIDEBAR_EXPANDED_CLASS = 'nav-sidebar-expanded';
|
||||||
|
|
||||||
|
export default class NewNavSidebar {
|
||||||
|
constructor() {
|
||||||
|
this.initDomElements();
|
||||||
|
this.bindEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
initDomElements() {
|
||||||
|
this.$sidebar = $('.nav-sidebar');
|
||||||
|
this.$openSidebar = $('.toggle-mobile-nav');
|
||||||
|
this.$closeSidebar = $('.close-nav-button');
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents() {
|
||||||
|
this.$openSidebar.on('click', e => this.toggleSidebarNav(e, true));
|
||||||
|
this.$closeSidebar.on('click', e => this.toggleSidebarNav(e, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleSidebarNav(show) {
|
||||||
|
this.$sidebar.toggleClass(SIDEBAR_EXPANDED_CLASS, show);
|
||||||
|
}
|
||||||
|
}
|
|
@ -275,8 +275,6 @@ header.navbar-gitlab-new {
|
||||||
.breadcrumbs {
|
.breadcrumbs {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-height: 60px;
|
min-height: 60px;
|
||||||
padding-top: $gl-padding-top;
|
|
||||||
padding-bottom: $gl-padding-top;
|
|
||||||
color: $gl-text-color;
|
color: $gl-text-color;
|
||||||
border-bottom: 1px solid $border-color;
|
border-bottom: 1px solid $border-color;
|
||||||
|
|
||||||
|
@ -300,6 +298,7 @@ header.navbar-gitlab-new {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
.dropdown-menu-projects {
|
.dropdown-menu-projects {
|
||||||
margin-top: -$gl-padding;
|
margin-top: -$gl-padding;
|
||||||
|
|
|
@ -26,41 +26,75 @@ $new-sidebar-width: 220px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-header {
|
.context-header {
|
||||||
border-bottom: 1px solid $border-color;
|
position: relative;
|
||||||
font-weight: 600;
|
|
||||||
display: flex;
|
a {
|
||||||
align-items: center;
|
border-bottom: 1px solid $border-color;
|
||||||
padding: 10px 16px 10px 10px;
|
font-weight: 600;
|
||||||
color: $gl-text-color;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 16px 10px 10px;
|
||||||
|
color: $gl-text-color;
|
||||||
|
|
||||||
|
@media (max-width: $screen-xs-max) {
|
||||||
|
padding-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $hover-background;
|
||||||
|
color: $hover-color;
|
||||||
|
border-color: $hover-background;
|
||||||
|
|
||||||
|
.avatar-container {
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-avatar {
|
||||||
|
background-color: $indigo-500;
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: $hover-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-container {
|
.avatar-container {
|
||||||
flex: 0 0 40px;
|
flex: 0 0 40px;
|
||||||
background-color: $white-light;
|
background-color: $white-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $hover-background;
|
|
||||||
color: $hover-color;
|
|
||||||
border-color: $hover-background;
|
|
||||||
|
|
||||||
.avatar-container {
|
|
||||||
border-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-avatar {
|
|
||||||
background-color: $indigo-500;
|
|
||||||
|
|
||||||
i {
|
|
||||||
color: $hover-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-title,
|
.project-title,
|
||||||
.group-title {
|
.group-title {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.close-nav-button {
|
||||||
|
color: $white-light;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-nav-button {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 100%;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 0;
|
||||||
|
padding: 0 10px;
|
||||||
|
|
||||||
|
@media (max-width: $screen-xs-max) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: $gl-text-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-avatar {
|
.settings-avatar {
|
||||||
|
@ -89,6 +123,10 @@ $new-sidebar-width: 220px;
|
||||||
background-color: $gray-normal;
|
background-color: $gray-normal;
|
||||||
box-shadow: inset -2px 0 0 $border-color;
|
box-shadow: inset -2px 0 0 $border-color;
|
||||||
|
|
||||||
|
&.nav-sidebar-expanded {
|
||||||
|
width: $new-sidebar-width;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +223,25 @@ $new-sidebar-width: 220px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toggle-mobile-nav {
|
||||||
|
display: none;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 0;
|
||||||
|
padding: 6px 16px;
|
||||||
|
margin: 0 16px 0 -15px;
|
||||||
|
height: 46px;
|
||||||
|
border-right: 1px solid $gl-text-color-quaternary;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 20px;
|
||||||
|
color: $gl-text-color-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: $screen-xs-max) {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make issue boards full-height now that sub-nav is gone
|
// Make issue boards full-height now that sub-nav is gone
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
%nav.breadcrumbs{ role: "navigation" }
|
%nav.breadcrumbs{ role: "navigation" }
|
||||||
.breadcrumbs-container{ class: [container_class, @content_class] }
|
.breadcrumbs-container{ class: [container_class, @content_class] }
|
||||||
|
%button.toggle-mobile-nav
|
||||||
|
= icon ('bars')
|
||||||
.breadcrumbs-links.js-title-container
|
.breadcrumbs-links.js-title-container
|
||||||
- unless hide_top_links
|
- unless hide_top_links
|
||||||
.title
|
.title
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
.nav-sidebar
|
.nav-sidebar
|
||||||
- can_edit = can?(current_user, :admin_project, @project)
|
- can_edit = can?(current_user, :admin_project, @project)
|
||||||
= link_to project_path(@project), title: @project.name, class: 'context-header' do
|
.context-header
|
||||||
.avatar-container.s40.project-avatar
|
= link_to project_path(@project), title: @project.name do
|
||||||
= project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile')
|
.avatar-container.s40.project-avatar
|
||||||
.project-title
|
= project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile')
|
||||||
= @project.name
|
.project-title
|
||||||
|
= @project.name
|
||||||
|
%button.close-nav-button
|
||||||
|
= icon('times')
|
||||||
%ul.sidebar-top-level-items
|
%ul.sidebar-top-level-items
|
||||||
= nav_link(path: ['projects#show', 'projects#activity', 'cycle_analytics#show'], html_options: { class: 'home' }) do
|
= nav_link(path: ['projects#show', 'projects#activity', 'cycle_analytics#show'], html_options: { class: 'home' }) do
|
||||||
= link_to project_path(@project), title: 'Project', class: 'shortcuts-project' do
|
= link_to project_path(@project), title: 'Project', class: 'shortcuts-project' do
|
||||||
|
|
Loading…
Reference in a new issue