mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Website: Fix docs nav functionality and optimize for mobile
A few minor styling fixes for the docs nav for mobile, refactoring the markup to remove unneeded parent elements, and fixing a bug where the nav overlapped with the footer if the window was too short.
This commit is contained in:
parent
38e851cf0d
commit
08b1a5da88
6 changed files with 72 additions and 29 deletions
|
@ -2,6 +2,11 @@
|
||||||
const $navLinks = $('.main-nav--links');
|
const $navLinks = $('.main-nav--links');
|
||||||
const $navToggle = $('.main-nav--toggle');
|
const $navToggle = $('.main-nav--toggle');
|
||||||
const navBreakpoint = 730; // this should match $nav-breakpoint in _nav.scss
|
const navBreakpoint = 730; // this should match $nav-breakpoint in _nav.scss
|
||||||
|
const $mainContent = $('#main-content');
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$mainContent.css('min-height', $('#main-nav').outerHeight() - $('#main-nav-ctas').outerHeight());
|
||||||
|
});
|
||||||
|
|
||||||
$navToggle.click(function() {
|
$navToggle.click(function() {
|
||||||
$(this).toggleClass('is-active');
|
$(this).toggleClass('is-active');
|
||||||
|
@ -13,4 +18,20 @@ $(window).resize(function() {
|
||||||
$navToggle.removeClass('is-active');
|
$navToggle.removeClass('is-active');
|
||||||
$navLinks.attr("style", "");
|
$navLinks.attr("style", "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// toggles fixed nav position when the window is too short
|
||||||
|
const footerOffsetTop = $("#main-footer").offset().top;
|
||||||
|
var navOffsetBottom;
|
||||||
|
|
||||||
|
function toggleFixedNavPosition() {
|
||||||
|
navOffsetBottom = $("#main-nav").outerHeight() + $(window).scrollTop();
|
||||||
|
|
||||||
|
$("#main-nav").toggleClass("is-fixed-bottom", footerOffsetTop < navOffsetBottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleFixedNavPosition();
|
||||||
|
|
||||||
|
$(window).scroll(function() {
|
||||||
|
toggleFixedNavPosition();
|
||||||
|
});
|
||||||
|
|
|
@ -9,7 +9,8 @@ nav#main-nav class="sidebar-layout-#{locals[:sidebar_layout]}"
|
||||||
a.button.transparent.try-demo href="#" Try the Demo
|
a.button.transparent.try-demo href="#" Try the Demo
|
||||||
a.button.secondary href="https://downloads.chef.io/inspec" Download
|
a.button.secondary href="https://downloads.chef.io/inspec" Download
|
||||||
- if locals[:sidebar_layout] == 'docs'
|
- if locals[:sidebar_layout] == 'docs'
|
||||||
= partial "layouts/sidebar"
|
li.main-nav--sidebar
|
||||||
|
= partial "layouts/sidebar"
|
||||||
- else
|
- else
|
||||||
li.main-nav--link
|
li.main-nav--link
|
||||||
a href="/"
|
a href="/"
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
.container__has-sidebar
|
- if locals[:sidebar_layout] == 'docs'
|
||||||
.row
|
form.main-sidebar--search action="/docs/search/" method="get"
|
||||||
.main-sidebar
|
input type="text" placeholder="Search Documentation" name="q"
|
||||||
- if locals[:sidebar_layout] == 'docs'
|
ul.main-sidebar--links
|
||||||
form.main-sidebar--search action="/docs/search/" method="get"
|
- sidebar_data(sidebar_layout).each do |item|
|
||||||
input type="text" placeholder="Search Documentation" name="q"
|
li.main-sidebar--link
|
||||||
ul.main-sidebar--links
|
h6 = item.title
|
||||||
- sidebar_data(sidebar_layout).each do |item|
|
ul.main-sidebar--list.no-bullet
|
||||||
li.main-sidebar--link
|
- item.links.each do |item_link|
|
||||||
h6 = item.title
|
li.main-sidebar--list--item class=link_classes(current_resource.url, item_link)
|
||||||
ul.main-sidebar--list.no-bullet
|
= link_to item_link.title, item_link.link
|
||||||
- item.links.each do |item_link|
|
- if print_sub_links?(current_resource.url, item_link)
|
||||||
li.main-sidebar--list--item class=link_classes(current_resource.url, item_link)
|
ul.main-sidebar--list--item--dropdown.no-bullet
|
||||||
= link_to item_link.title, item_link.link
|
- item_link.sub_links.each do |sub_link|
|
||||||
- if print_sub_links?(current_resource.url, item_link)
|
li.main-sidebar--list--item class=link_classes(current_resource.url, sub_link)
|
||||||
ul.main-sidebar--list--item--dropdown.no-bullet
|
= link_to sub_link.title, sub_link.link
|
||||||
- item_link.sub_links.each do |sub_link|
|
|
||||||
li.main-sidebar--list--item class=link_classes(current_resource.url, sub_link)
|
|
||||||
= link_to sub_link.title, sub_link.link
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
body {
|
body {
|
||||||
|
position: relative;
|
||||||
font-family: $main-font;
|
font-family: $main-font;
|
||||||
color: $body-text;
|
color: $body-text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ $nav-breakpoint: 730px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
width: $side-nav-width;
|
width: $side-nav-width;
|
||||||
|
|
||||||
|
&.is-fixed-bottom {
|
||||||
|
bottom: 137px;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +98,11 @@ $nav-breakpoint: 730px;
|
||||||
@include nav-small {
|
@include nav-small {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-layout-docs & {
|
||||||
|
max-height: calc(100vh - 64px);
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-nav--link {
|
.main-nav--link {
|
||||||
|
|
|
@ -1,6 +1,26 @@
|
||||||
.main-sidebar ul {
|
.sidebar-layout-docs {
|
||||||
|
.main-nav--links {
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-nav--link-ctas {
|
||||||
|
border-bottom: none;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-nav--sidebar {
|
||||||
|
padding: 0 $side-nav-padding-small;
|
||||||
|
|
||||||
|
@include nav-large {
|
||||||
|
padding: 0 $side-nav-padding-large;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-sidebar--links {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
@ -9,7 +29,6 @@
|
||||||
|
|
||||||
.main-sidebar--link h6 {
|
.main-sidebar--link h6 {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-sidebar--list--item {
|
.main-sidebar--list--item {
|
||||||
|
@ -64,9 +83,3 @@
|
||||||
min-width: 54px;
|
min-width: 54px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this is used to remove the top border line of the search
|
|
||||||
// see https://github.com/chef/inspec/issues/1114#issuecomment-249525984
|
|
||||||
.sidebar-layout-docs > .main-nav--links {
|
|
||||||
border-top: none;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue