UX: improve hamburger in desktop

- dock underneath header
- click anywhere to get it to go away
This commit is contained in:
Sam 2015-08-26 13:10:50 +10:00
parent b736b56e97
commit 6c08bd4265
7 changed files with 34 additions and 4 deletions

View File

@ -4,6 +4,23 @@ export default Ember.Component.extend({
classNameBindings: ['visible::slideright'], classNameBindings: ['visible::slideright'],
elementId: 'hamburger-menu', elementId: 'hamburger-menu',
visibilityChanged: function(){
if(this.get("visible")) {
$('html').on('click.close-humburger', (e) => {
const $target = $(e.target);
if ($target.closest('.dropdown.categories').length > 0) {
return;
}
console.log(e.toElement || e.relatedTarget || e.target);
this.set("visible", false);
$('html').off('click.close-humburger');
return true;
});
} else {
$('html').off('click.close-humburger');
}
}.observes("visible"),
@computed() @computed()
showKeyboardShortcuts() { showKeyboardShortcuts() {
return !Discourse.Mobile.mobileView && !this.capabilities.touch; return !Discourse.Mobile.mobileView && !this.capabilities.touch;
@ -43,6 +60,7 @@ export default Ember.Component.extend({
$('body').off('keydown.discourse-hambuger'); $('body').off('keydown.discourse-hambuger');
$('body').off('swipeleft.discourse-hamburger'); $('body').off('swipeleft.discourse-hamburger');
$('body').off('swiperight.discourse-hamburger'); $('body').off('swiperight.discourse-hamburger');
$('body').off('click.close-humburger');
}, },
@computed() @computed()

View File

@ -1,4 +1,5 @@
{{render "header"}} {{render "header"}}
{{hamburger-menu visible=hamburgerVisible showKeyboardAction="showKeyboardShortcutsHelp"}}
<div id="main-outlet" class="wrap"> <div id="main-outlet" class="wrap">
<div class="container"> <div class="container">
@ -19,4 +20,3 @@
{{render "topic-entrance"}} {{render "topic-entrance"}}
{{render "composer"}} {{render "composer"}}
{{hamburger-menu visible=hamburgerVisible showKeyboardAction="showKeyboardShortcutsHelp"}}

View File

@ -1,5 +1,7 @@
{{#if visible}} {{#if visible}}
<a href {{action "close"}} class='close-hamburger'>{{fa-icon 'times'}}</a> <div class='hamburger-header clearfix'>
<a href {{action "close"}} class='close-hamburger'>{{fa-icon 'times'}}</a>
</div>
<ul class="location-links"> <ul class="location-links">
{{#if currentUser.staff}} {{#if currentUser.staff}}
<li> <li>

View File

@ -9,7 +9,7 @@
transition: 0.3s ease-in-out; transition: 0.3s ease-in-out;
@include transform(translateX(0)); @include transform(translateX(0));
box-shadow: 4px 0 4px 5px rgba(0,0,0, .25); box-shadow: 0 4px 4px 4px rgba(0,0,0, .25);
padding: 0.5em 0.5em 0.5em 0.5em; padding: 0.5em 0.5em 0.5em 0.5em;
width: 300px; width: 300px;
@ -17,10 +17,11 @@
float: right; float: right;
color: dark-light-choose(scale-color($header_primary, $lightness: 50%), $header_primary); color: dark-light-choose(scale-color($header_primary, $lightness: 50%), $header_primary);
font-size: 1.5em; font-size: 1.5em;
margin-right: 0.1em; margin-right: 0.5em;
margin-top: 0.1em; margin-top: 0.1em;
} }
ul { ul {
list-style: none; list-style: none;
margin: 0; margin: 0;

View File

@ -17,6 +17,7 @@
@import "desktop/user"; @import "desktop/user";
@import "desktop/history"; @import "desktop/history";
@import "desktop/queued-posts"; @import "desktop/queued-posts";
@import "desktop/hamburger";
/* These files doesn't actually exist, they are injected by DiscourseSassImporter. */ /* These files doesn't actually exist, they are injected by DiscourseSassImporter. */

View File

@ -0,0 +1,8 @@
.docked #hamburger-menu {
position: fixed;
}
#hamburger-menu {
position: absolute;
top: 63px
}