Skip to content

Commit

Permalink
Update GreedyNav to use flexbox instead of display: table
Browse files Browse the repository at this point in the history
- ref #836
  • Loading branch information
mmistakes committed Feb 14, 2017
1 parent 943456c commit 1cbac04
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 26 deletions.
4 changes: 2 additions & 2 deletions _includes/masthead.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<div class="masthead__inner-wrap">
<div class="masthead__menu">
<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">
<li class="masthead__menu-item masthead__menu-item--lg"><a href="{{ '/' | absolute_url }}">{{ site.title }}</a></li>
{% for link in site.data.navigation.main %}
{% if link.url contains 'http' %}
{% assign domain = '' %}
Expand All @@ -14,6 +13,7 @@
<li class="masthead__menu-item"><a href="{{ domain }}{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
</ul>
<button><div class="navicon"></div></button>
<ul class="hidden-links hidden"></ul>
</nav>
</div>
Expand Down
29 changes: 29 additions & 0 deletions _sass/_masthead.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
&__inner-wrap {
@include container;
@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;
font-family: $sans-serif-narrow;

Expand All @@ -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 {
width: 100%;

.site-nav {
margin-left: 0;

@include breakpoint($small) {
float: right;
}
}

ul {
margin: 0;
Expand Down
64 changes: 40 additions & 24 deletions _sass/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@

.greedy-nav {
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;

a {
Expand All @@ -188,12 +193,16 @@
&:hover {
color: $masthead-link-color-hover;
}

&.site-title {
margin-left: 0;
}
}

button {
position: absolute;
height: 100%;
right: 0;
-ms-flex-item-align: stretch;
-ms-grid-row-align: stretch;
align-self: stretch;
padding: 0 0.5rem;
border: 0;
outline: none;
Expand All @@ -203,19 +212,22 @@
}

.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 {
display: table-cell;
vertical-align: middle;

&:first-child {
font-weight: bold;

a {
margin-left: 0;
}
}
-webkit-box-flex: 0;
-ms-flex: none;
flex: none;

&:last-child {
a {
Expand All @@ -238,13 +250,11 @@
-webkit-transition: $global-transition;
transition: $global-transition;
-webkit-transform: scaleX(0) translate3d(0, 0 , 0);
-ms-transform: scaleX(0) translate3d(0, 0 , 0);
transform: scaleX(0) translate3d(0, 0 , 0); /* hide*/
}

&:hover:before {
-webkit-transform: scaleX(1);
-ms-transform: scaleX(1);
transform: scaleX(1); /* reveal*/
}
}
Expand All @@ -261,6 +271,10 @@
background: #fff;
box-shadow: 0 0 10px rgba(#000, 0.25);

&.hidden {
display: none;
}

a {
margin: 0;
padding: 10px 20px;
Expand Down Expand Up @@ -348,11 +362,13 @@
height: 0.125em;
line-height: 1;
background-color: $gray;
-webkit-transition: 0.2s ease-out;
transition: 0.2s ease-out;
}

&:after {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}

&:hover {
Expand All @@ -378,13 +394,15 @@
}
}

// on hover show expand
/* on hover show expand*/
label:hover:after {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}

input:checked + label:hover:after {
transform: rotate(0);
-webkit-transform: rotate(0);
transform: rotate(0);
}

ul {
Expand Down Expand Up @@ -438,7 +456,6 @@
-webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
-webkit-transform: translate(0, 10%);
-ms-transform: translate(0, 10%);
transform: translate(0, 10%);
}
}
Expand All @@ -447,12 +464,11 @@
.nav__list input:checked ~ .nav__items {
-webkit-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;
opacity: 1;
margin-top: 1em;
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
}
Expand Down

0 comments on commit 1cbac04

Please sign in to comment.