Merge branch 'feature/greedy-nav-long-title-fix' into develop

This commit is contained in:
Michael Rose 2017-02-14 14:07:43 -05:00
commit a3ccadc8e3
10 changed files with 162 additions and 100 deletions

View file

@ -16,4 +16,19 @@
<!-- For all browsers --> <!-- For all browsers -->
<link rel="stylesheet" href="{{ '/assets/css/main.css' | absolute_url }}"> <link rel="stylesheet" href="{{ '/assets/css/main.css' | absolute_url }}">
<!--[if lte IE 9]>
<style>
/* old IE unsupported flexbox fixes */
.greedy-nav .site-title {
padding-right: 3em;
}
.greedy-nav button {
position: absolute;
top: 0;
right: 0;
height: 100%;
}
</style>
<![endif]-->
<meta http-equiv="cleartype" content="on"> <meta http-equiv="cleartype" content="on">

View file

@ -2,9 +2,8 @@
<div class="masthead__inner-wrap"> <div class="masthead__inner-wrap">
<div class="masthead__menu"> <div class="masthead__menu">
<nav id="site-nav" class="greedy-nav"> <nav id="site-nav" class="greedy-nav">
<button><div class="navicon"></div></button> <a class="site-title" href="{{ '/' | absolute_url }}">{{ site.title }}</a>
<ul class="visible-links"> <ul class="visible-links">
<li class="masthead__menu-item masthead__menu-item--lg"><a href="{{ '/' | absolute_url }}">{{ site.title }}</a></li>
{% for link in site.data.navigation.main %} {% for link in site.data.navigation.main %}
{% if link.url contains 'http' %} {% if link.url contains 'http' %}
{% assign domain = '' %} {% assign domain = '' %}
@ -14,6 +13,7 @@
<li class="masthead__menu-item"><a href="{{ domain }}{{ link.url }}">{{ link.title }}</a></li> <li class="masthead__menu-item"><a href="{{ domain }}{{ link.url }}">{{ link.title }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
<button><div class="navicon"></div></button>
<ul class="hidden-links hidden"></ul> <ul class="hidden-links hidden"></ul>
</nav> </nav>
</div> </div>

View file

@ -14,6 +14,10 @@
&__inner-wrap { &__inner-wrap {
@include container; @include container;
@include clearfix; @include clearfix;
display: -webkit-box;
display: flex;
-webkit-box-pack: justify;
justify-content: space-between;
padding: 1em 1em 1em; padding: 1em 1em 1em;
font-family: $sans-serif-narrow; font-family: $sans-serif-narrow;
@ -31,7 +35,27 @@
} }
} }
.site-title {
display: -webkit-box;
display: flex;
padding: 0.5rem 0;
align-self: stretch;
-webkit-box-align: center;
align-items: center;
font-weight: bold;
z-index: 20;
}
.masthead__menu { .masthead__menu {
width: 100%;
.site-nav {
margin-left: 0;
@include breakpoint($small) {
float: right;
}
}
ul { ul {
margin: 0; margin: 0;

View file

@ -175,7 +175,10 @@
.greedy-nav { .greedy-nav {
position: relative; position: relative;
min-width: 250px; display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
background: $background-color; background: $background-color;
a { a {
@ -188,34 +191,35 @@
&:hover { &:hover {
color: $masthead-link-color-hover; color: $masthead-link-color-hover;
} }
&.site-title {
margin-left: 0;
}
} }
button { button {
position: absolute;
height: 100%;
right: 0;
padding: 0 0.5rem; padding: 0 0.5rem;
align-self: stretch;
border: 0; border: 0;
outline: none; outline: none;
background-color: $primary-color;
color: #fff; color: #fff;
background-color: $primary-color;
cursor: pointer; cursor: pointer;
} }
.visible-links { .visible-links {
display: table; display: -webkit-box;
display: flex;
-webkit-box-pack: end;
justify-content: flex-end;
-webkit-box-flex: 1;
flex: 1;
padding-right: 2rem;
overflow: hidden;
li { li {
display: table-cell; -webkit-box-flex: 0;
vertical-align: middle; flex: none;
&:first-child {
font-weight: bold;
a {
margin-left: 0;
}
}
&:last-child { &:last-child {
a { a {
@ -238,7 +242,6 @@
-webkit-transition: $global-transition; -webkit-transition: $global-transition;
transition: $global-transition; transition: $global-transition;
-webkit-transform: scaleX(0) translate3d(0, 0 , 0); -webkit-transform: scaleX(0) translate3d(0, 0 , 0);
-ms-transform: scaleX(0) translate3d(0, 0 , 0);
transform: scaleX(0) translate3d(0, 0 , 0); /* hide*/ transform: scaleX(0) translate3d(0, 0 , 0); /* hide*/
} }
@ -261,6 +264,10 @@
background: #fff; background: #fff;
box-shadow: 0 0 10px rgba(#000, 0.25); box-shadow: 0 0 10px rgba(#000, 0.25);
&.hidden {
display: none;
}
a { a {
margin: 0; margin: 0;
padding: 10px 20px; padding: 10px 20px;
@ -348,10 +355,13 @@
height: 0.125em; height: 0.125em;
line-height: 1; line-height: 1;
background-color: $gray; background-color: $gray;
-webkit-transition: 0.2s ease-out;
transition: 0.2s ease-out; transition: 0.2s ease-out;
} }
&:after { &:after {
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg); transform: rotate(90deg);
} }
@ -378,12 +388,16 @@
} }
} }
// on hover show expand /* on hover show expand*/
label:hover:after { label:hover:after {
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg); transform: rotate(90deg);
} }
input:checked + label:hover:after { input:checked + label:hover:after {
-webkit-transform: rotate(0);
-ms-transform: rotate(0);
transform: rotate(0); transform: rotate(0);
} }
@ -447,7 +461,7 @@
.nav__list input:checked ~ .nav__items { .nav__list input:checked ~ .nav__items {
-webkit-transition: 0.5s ease-in-out; -webkit-transition: 0.5s ease-in-out;
transition: 0.5s ease-in-out; transition: 0.5s ease-in-out;
max-height: 9999px; // exaggerate max-height to accommodate tall lists max-height: 9999px; /* exaggerate max-height to accommodate tall lists*/
overflow: visible; overflow: visible;
opacity: 1; opacity: 1;
margin-top: 1em; margin-top: 1em;

View file

@ -8,7 +8,9 @@
margin-top: 2em; margin-top: 2em;
padding-left: 1em; padding-left: 1em;
padding-right: 1em; padding-right: 1em;
-webkit-animation: intro 0.3s both;
animation: intro 0.3s both; animation: intro 0.3s both;
-webkit-animation-delay: 0.35s;
animation-delay: 0.35s; animation-delay: 0.35s;
@include breakpoint($x-large) { @include breakpoint($x-large) {
@ -111,7 +113,9 @@
position: relative; position: relative;
margin-bottom: 2em; margin-bottom: 2em;
@include clearfix; @include clearfix;
-webkit-animation: intro 0.3s both;
animation: intro 0.3s both; animation: intro 0.3s both;
-webkit-animation-delay: 0.25s;
animation-delay: 0.25s; animation-delay: 0.25s;
&--overlay { &--overlay {
@ -122,7 +126,9 @@
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
-webkit-animation: intro 0.3s both;
animation: intro 0.3s both; animation: intro 0.3s both;
-webkit-animation-delay: 0.25s;
animation-delay: 0.25s; animation-delay: 0.25s;
a { a {
@ -297,6 +303,7 @@
.page__comments-form { .page__comments-form {
padding: 1em; padding: 1em;
background: $lighter-gray; background: $lighter-gray;
-webkit-transition: $global-transition;
transition: $global-transition; transition: $global-transition;
&.disabled { &.disabled {

View file

@ -46,7 +46,7 @@ figure.highlight {
padding: 5px; padding: 5px;
border: 0; border: 0;
// line numbers /* line numbers*/
&.gutter { &.gutter {
padding-right: 1em; padding-right: 1em;
color: $light-gray; color: $light-gray;

View file

@ -123,6 +123,6 @@ $right-sidebar-width-wide : 400px !default;
$border-radius : 4px !default; $border-radius : 4px !default;
$box-shadow : 0 1px 1px rgba(0, 0, 0, 0.125) !default; $box-shadow : 0 1px 1px rgba(0, 0, 0, 0.125) !default;
$navicon-width : 28px !default; $navicon-width : 1.5rem !default;
$navicon-height : 4px !default; $navicon-height : 0.25rem !default;
$global-transition : all 0.2s ease-in-out !default; $global-transition : all 0.2s ease-in-out !default;

File diff suppressed because one or more lines are too long

View file

@ -1,72 +1,74 @@
/* /*
* Greedy Navigation GreedyNav.js - https://github.com/lukejacksonn/GreedyNav
* Licensed under the MIT license - http://opensource.org/licenses/MIT
* http://codepen.io/lukejacksonn/pen/PwmwWV Copyright (c) 2015 Luke Jackson
*
*/ */
var $nav = $('#site-nav'); $(document).ready(function(){
var $btn = $('#site-nav button');
var $vlinks = $('#site-nav .visible-links');
var $hlinks = $('#site-nav .hidden-links');
var breaks = []; var $btn = $('nav.greedy-nav button');
var $vlinks = $('nav.greedy-nav .visible-links');
var $hlinks = $('nav.greedy-nav .hidden-links');
function updateNav() { var numOfItems = 0;
var totalSpace = 0;
var closingTime = 1000;
var breakWidths = [];
var availableSpace = $btn.hasClass('hidden') ? $nav.width() : $nav.width() - $btn.width() - 30; // Get initial state
$vlinks.children().outerWidth(function(i, w) {
totalSpace += w;
numOfItems += 1;
breakWidths.push(totalSpace);
});
// The visible list is overflowing the nav var availableSpace, numOfVisibleItems, requiredSpace, timer;
if($vlinks.width() > availableSpace) {
// Record the width of the list function check() {
breaks.push($vlinks.width());
// Move item to the hidden list // Get instant state
availableSpace = $vlinks.width() - 10;
numOfVisibleItems = $vlinks.children().length;
requiredSpace = breakWidths[numOfVisibleItems - 1];
// There is not enough space
if (requiredSpace > availableSpace) {
$vlinks.children().last().prependTo($hlinks); $vlinks.children().last().prependTo($hlinks);
numOfVisibleItems -= 1;
// Show the dropdown btn check();
if($btn.hasClass('hidden')) { // There is more than enough space
$btn.removeClass('hidden'); } else if (availableSpace > breakWidths[numOfVisibleItems]) {
}
// The visible list is not overflowing
} else {
// There is space for another item in the nav
if(availableSpace > breaks[breaks.length-1]) {
// Move the item to the visible list
$hlinks.children().first().appendTo($vlinks); $hlinks.children().first().appendTo($vlinks);
breaks.pop(); numOfVisibleItems += 1;
check();
} }
// Update the button accordingly
// Hide the dropdown btn if hidden list is empty $btn.attr("count", numOfItems - numOfVisibleItems);
if(breaks.length < 1) { if (numOfVisibleItems === numOfItems) {
$btn.addClass('hidden'); $btn.addClass('hidden');
$hlinks.addClass('hidden'); } else $btn.removeClass('hidden');
}
}
// Keep counter updated
$btn.attr("count", breaks.length);
// Recur if the visible list is still overflowing the nav
if($vlinks.width() > availableSpace) {
updateNav();
}
} }
// Window listeners // Window listeners
$(window).resize(function() { $(window).resize(function() {
updateNav(); check();
}); });
$btn.on('click', function() { $btn.on('click', function() {
$hlinks.toggleClass('hidden'); $hlinks.toggleClass('hidden');
$(this).toggleClass('close'); clearTimeout(timer);
}); });
updateNav(); $hlinks.on('mouseleave', function() {
// Mouse has left, start the timer
timer = setTimeout(function() {
$hlinks.addClass('hidden');
}, closingTime);
}).on('mouseenter', function() {
// Mouse is back, cancel the timer
clearTimeout(timer);
})
check();
});

View file

@ -9,7 +9,7 @@ theme : "minimal-mistakes-jekyll"
# Site Settings # Site Settings
locale : "en" locale : "en"
title : "dev_MM" title : "Minimal Mistakes Development Test Site"
title_separator : "-" title_separator : "-"
name : "Your Name" name : "Your Name"
description : "Minimal Mistakes theme test." description : "Minimal Mistakes theme test."