Skip to content

Commit

Permalink
Merge pull request #717 from matthewcarleton/notification-drawer-mobile
Browse files Browse the repository at this point in the history
updates notification drawer to support mobile
  • Loading branch information
LHinson authored Aug 31, 2017
2 parents ac19518 + 52d27a4 commit e09fc17
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 11 deletions.
13 changes: 12 additions & 1 deletion src/js/patternfly-functions-vertical-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(function ($) {
'use strict';

$.fn.setupVerticalNavigation = function (handleItemSelections) {
$.fn.setupVerticalNavigation = function (handleItemSelections, ignoreDrawer) {

var navElement = $('.nav-pf-vertical'),
bodyContentElement = $('.container-pf-nav-pf-vertical'),
Expand Down Expand Up @@ -249,6 +249,8 @@

bindMenuBehavior = function () {
toggleNavBarButton.on('click', function (e) {
var $drawer;

enableTransitions();

if (inMobileState()) {
Expand All @@ -259,6 +261,15 @@
// Always start at the primary menu
updateMobileMenu();
navElement.addClass('show-mobile-nav');

// If the notification drawer is shown, hide it
if (!ignoreDrawer) {
$drawer = $('.drawer-pf');
if ($drawer.length) {
$('.drawer-pf-trigger').removeClass('open');
$drawer.addClass('hide');
}
}
}
} else if (navElement.hasClass('collapsed')) {
window.localStorage.setItem('patternfly-navigation-primary', 'expanded');
Expand Down
2 changes: 1 addition & 1 deletion src/less/navbar-vertical.less
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
color: @navbar-pf-vertical-active-color;
}
}

.badge {
background-color: @notification-badge-color;
border-radius: 20px;
Expand Down
22 changes: 21 additions & 1 deletion src/less/notifications-drawer.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
display: block;
}
&.drawer-pf-expanded {
left: 270px;
@media (max-width: @screen-xs-max) {
left:0;
width: 100%;
}
@media (min-width: @screen-xs-max) {
left: 270px;
} // if the drawer is expanded and the screen is reduced this ensures it switches to full width on smaller screens.
width: inherit;
.drawer-pf-toggle-expand:before {
content: "\f101";
Expand Down Expand Up @@ -190,6 +196,9 @@
.drawer-pf-notification.expanded-notification {
.drawer-pf-notification-content {
display: flex;
@media (max-width: @screen-sm-max) {
flex-direction: column;
}
.drawer-pf-notification-message {
flex: 1 1;
}
Expand All @@ -201,6 +210,12 @@
.drawer-pf {
height: calc(~"100vh - 80px");//to create a 20px offset bottom
top: 58px; //menu height;

@media (max-width: @screen-xs-max) {
width:100%;
height: calc(~"100vh - 58px");
}

}
.nav .drawer-pf-trigger {
.drawer-pf-trigger-icon {
Expand All @@ -220,6 +235,11 @@
.drawer-pf {
height: calc(~"100vh - 46px");
top: 26px;
@media (max-width: @screen-xs-max) {
width:100%;
height: calc(~"100vh - 58px");
top:34px;
}
}
.drawer-pf-trigger-icon { cursor: pointer; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<a href="/" class="navbar-brand">
{% if site.navbar-pf-navbar-brand-icon %}<img class="navbar-brand-icon" src="{{site.baseurl}}/{{site.navbar-logo-alt-icon}}" alt=""/>{% endif %}<img class="navbar-brand-name" src="{{site.baseurl}}/{{site.navbar-brand-alt-icon}}" alt="{{site.title-product}}" />
</a>
<ul class="nav pull-right visible-xs-block navbar-iconic">
<li class="drawer-pf-trigger">
<a class="nav-item-iconic">
<span class="fa fa-bell" title="Notifications"></span>
<span class="badge"> </span><!-- in order to show the empty badge this requires a space, otherwise add a value -->
</a>
</li>
</ul>
</div>
<nav class="collapse navbar-collapse">
<ul class="nav navbar-nav">
Expand Down Expand Up @@ -42,6 +50,6 @@
</ul>
</li>
</ul>
{% include widgets/notification-drawer.html %}
</nav>
{% include widgets/notification-drawer.html %}
</nav> <!--/.navbar-->
6 changes: 3 additions & 3 deletions tests/pages/_includes/widgets/layouts/navbar-vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</ul>
</li>
</ul>
{% if include.notification-drawer %}
{% include widgets/notification-drawer.html %}
{% endif %}
</nav>
{% if include.notification-drawer %}
{% include widgets/notification-drawer.html %}
{% endif %}
</nav> <!--/.navbar-->
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{% include widgets/kebab.html dropmenuType="dropdown" dropmenuPosition="pull-right" dropmenuId=menu_id dropdownPosition="dropdown-menu-right" dropmenuVariation="dropdown-kebab-pf" %}
<span class="pficon pficon-warning-triangle-o pull-left"></span>
<div class="drawer-pf-notification-content">
<span class="drawer-pf-notification-message">Another Event Notification</span>
<span class="drawer-pf-notification-message">Another Event Notification that is really long to see how it reacts on smaller screens sizes.</span>
<div class="drawer-pf-notification-info">
<span class="date">3/31/16</span>
<span class="time">12:12:44 PM</span>
Expand All @@ -37,8 +37,8 @@
<div class="drawer-pf-notification">
{% assign menu_id = 'dropdownKebabRight4' | append: include.id %}
{% include widgets/kebab.html dropmenuType="dropdown" dropmenuPosition="pull-right" dropmenuId=menu_id dropdownPosition="dropdown-menu-right" dropmenuVariation="dropdown-kebab-pf" %}
<span class="pficon pficon-error-circle-o pull-left"></span>
<div class="drawer-pf-notification-content">
<span class="pficon pficon-error-circle-o pull-left"></span>
<span class="drawer-pf-notification-message">Another Event Notification</span>
<div class="drawer-pf-notification-info">
<span class="date">3/31/16</span>
Expand Down
6 changes: 5 additions & 1 deletion tests/pages/_includes/widgets/notification-drawer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="drawer-pf hide drawer-pf-notifications-non-clickable">
<div class="drawer-pf-title">
<a class="drawer-pf-toggle-expand fa fa-angle-double-left"></a>
<a class="drawer-pf-toggle-expand fa fa-angle-double-left hidden-xs"></a>
<a class="drawer-pf-close pficon pficon-close"></a>
<h3 class="text-center">Notifications Drawer</h3>
</div>
Expand Down Expand Up @@ -134,6 +134,10 @@ <h1>There are no notifications to display.</h1>
} else {
$drawer.addClass('hide');
}
// Special case, close navigation menu in mobile mode
if ($('.container-pf-nav-pf-vertical').hasClass('hidden-nav')) {
$('.nav-pf-vertical').removeClass('show-mobile-nav');
}
});
$('.drawer-pf-close').click(function() {
var $drawer = $('.drawer-pf');
Expand Down
2 changes: 1 addition & 1 deletion tests/pages/wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ <h3 class="blank-slate-pf-main-action">Deployment in progress</h3>

</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div><!-- /.modal -->

0 comments on commit e09fc17

Please sign in to comment.