Skip to content

Commit

Permalink
added simple navbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalKleindienst committed Oct 31, 2018
1 parent c6ed079 commit 63c66ff
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scss/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
list-style-type: none;
}

ul:not(.list-unstyled) {
ul:not(.list-unstyled):not(.navbar-menu) {
padding-left: 0;
list-style-type: none;

Expand Down
161 changes: 161 additions & 0 deletions scss/_navbar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// Navbar
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem;
width: 100%;
box-sizing: border-box;

&.navbar-top,
&.navbar-fixed-top {
position: absolute;
top: 0;
left: 0;
}

&.navbar-fixed-top {
position: fixed;
}
}

// Menu
.navbar-menu {
margin: 0;
padding: 0;

li { display: inline; }
}

// Menu item
.navbar-item {
&::before,
&::after {
display: inline-block;
transition: all .25s;
opacity: 0;
}

&::before {
transform: translateX(.75rem);
margin-right: .375rem;
content: $menu-item-before;
}

&::after {
transform: translateX(-.75rem);
margin-left: .375rem;
content: $menu-item-after;
}

&:hover::before,
&:hover::after,
&:focus::before,
&:focus::after,
&.active::before,
&.active::after {
transform: translateX(0);
opacity: 1;
}
}

// Toggler
.navbar-toggler {
display: none;
position: relative;

input {
display: block;
position: absolute;
top: -7px;
left: -5px;
opacity: 0;
z-index: 2;
cursor: pointer;
width: 40px;
height: 2rem;
}

// Hamburger
span {
display: block;
position: relative;
transform-origin: 4px 0;
transition: transform .5s cubic-bezier(.77, .2, .05, 1),
opacity .5s ease;
z-index: 1;
margin-bottom: 5px;
width: 2rem;
height: 4px;

&:first-child {
transform-origin: 0 0;
}

&:nth-last-child(2) {
transform-origin: 0 100%;
}
}

// Hamburger X
input:checked ~ span:nth-last-child(3) {
transform: rotate(45deg) translate(1px, -1px);
opacity: 1;
}

input:checked ~ span:nth-last-child(2) {
opacity: 0;
}

input:checked ~ span:last-child {
transform: rotate(-45deg) translate(0, -1px);
}

// show menu
&.open ~ .navbar-menu {
visibility: visible;
height: auto;
}
}

// Light theme
.navbar-light {
@extend .bg-light;
@extend .text-gray;

.navbar-toggler span {
background: $light-link-color;
}
}

// Dark Theme
.navbar-dark {
@extend .bg-dark;
@extend .text-white;

.navbar-toggler span {
background: $dark-link-color;
}
}

// Repsonsiveness
@media (max-width: 576px) {
.navbar {
flex-wrap: wrap;
}

.navbar-menu {
visibility: hidden;
width: 100%;
height: 0;

li { display: block; }
}

.navbar-toggler { display: block;}

.navbar-item {
display: block;
padding: .75rem .5rem;
}
}
1 change: 1 addition & 0 deletions scss/consola.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import 'base';
@import 'typography';
@import 'colors';
@import 'navbar';
@import 'buttons';
@import 'lists';
@import 'tables';
Expand Down

0 comments on commit 63c66ff

Please sign in to comment.