Update GreedyNav to use flexbox instead of display: table

- ref #836
This commit is contained in:
Michael Rose 2017-02-13 22:15:57 -05:00
parent 943456cae7
commit 1cbac04650
3 changed files with 71 additions and 26 deletions

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,12 @@
&__inner-wrap { &__inner-wrap {
@include container; @include container;
@include clearfix; @include clearfix;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-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 +37,30 @@
} }
} }
.site-title {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding: 0.5rem 0;
-ms-flex-item-align: stretch;
align-self: stretch;
-webkit-box-align: center;
-ms-flex-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,12 @@
.greedy-nav { .greedy-nav {
position: relative; position: relative;
min-width: 250px; display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
background: $background-color; background: $background-color;
a { a {
@ -188,12 +193,16 @@
&:hover { &:hover {
color: $masthead-link-color-hover; color: $masthead-link-color-hover;
} }
&.site-title {
margin-left: 0;
}
} }
button { button {
position: absolute; -ms-flex-item-align: stretch;
height: 100%; -ms-grid-row-align: stretch;
right: 0; align-self: stretch;
padding: 0 0.5rem; padding: 0 0.5rem;
border: 0; border: 0;
outline: none; outline: none;
@ -203,19 +212,22 @@
} }
.visible-links { .visible-links {
display: table; display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
padding-right: 3.5rem;
overflow: hidden;
li { li {
display: table-cell; -webkit-box-flex: 0;
vertical-align: middle; -ms-flex: none;
flex: none;
&:first-child {
font-weight: bold;
a {
margin-left: 0;
}
}
&:last-child { &:last-child {
a { a {
@ -238,13 +250,11 @@
-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*/
} }
&:hover:before { &:hover:before {
-webkit-transform: scaleX(1); -webkit-transform: scaleX(1);
-ms-transform: scaleX(1);
transform: scaleX(1); /* reveal*/ transform: scaleX(1); /* reveal*/
} }
} }
@ -261,6 +271,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,11 +362,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 {
transform: rotate(90deg); -webkit-transform: rotate(90deg);
transform: rotate(90deg);
} }
&:hover { &:hover {
@ -378,13 +394,15 @@
} }
} }
// on hover show expand /* on hover show expand*/
label:hover:after { label:hover:after {
transform: rotate(90deg); -webkit-transform: rotate(90deg);
transform: rotate(90deg);
} }
input:checked + label:hover:after { input:checked + label:hover:after {
transform: rotate(0); -webkit-transform: rotate(0);
transform: rotate(0);
} }
ul { ul {
@ -438,7 +456,6 @@
-webkit-transition: 0.3s ease-in-out; -webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out; transition: 0.3s ease-in-out;
-webkit-transform: translate(0, 10%); -webkit-transform: translate(0, 10%);
-ms-transform: translate(0, 10%);
transform: translate(0, 10%); transform: translate(0, 10%);
} }
} }
@ -447,12 +464,11 @@
.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;
-webkit-transform: translate(0, 0); -webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); transform: translate(0, 0);
} }
} }