added collapsable left nav styles and js

pull/4/head
Scott Anderson 2019-01-11 10:21:33 -07:00
parent 6c78475973
commit 306db565b3
23 changed files with 265 additions and 20 deletions

View File

@ -19,10 +19,9 @@ function switch_style ( css_title )
var i, link_tag ;
for (i = 0, link_tag = document.getElementsByTagName("link") ;
i < link_tag.length ; i++ ) {
if ((link_tag[i].rel.indexOf("stylesheet") != -1) &&
link_tag[i].title) {
if ((link_tag[i].rel.indexOf("stylesheet") != -1) && link_tag[i].title.includes("theme")) {
link_tag[i].disabled = true ;
if (link_tag[i].title == css_title) {
if (link_tag[i].title == css_title ) {
link_tag[i].disabled = false ;
}
}

View File

@ -0,0 +1,38 @@
/*
Copied and pasted this script for CSS swaps w/ cookies from
http://www.thesitewizard.com/javascripts/change-style-sheets.shtml
*/
// *** TO BE CUSTOMISED ***
var sidebar_state_cookie_name = "influx-docs-sidebar-state" ;
var sidebar_state_duration = 30 ;
var style_domain = "docs.influxdata.com" ;
// *** END OF CUSTOMISABLE SECTION ***
// You do not need to customise anything below this line
function toggle_sidebar ( toggle_state )
{
// You may use this script on your site free of charge provided
// you do not remove this notice or the URL below. Script from
// http://www.thesitewizard.com/javascripts/change-style-sheets.shtml
var i, link_tag ;
for (i = 0, link_tag = document.getElementsByTagName("link") ;
i < link_tag.length ; i++ ) {
if ((link_tag[i].rel.indexOf("stylesheet") != -1) && link_tag[i].title.includes("sidebar")) {
link_tag[i].disabled = true ;
if (link_tag[i].title == toggle_state ) {
link_tag[i].disabled = false ;
}
}
Cookies.set(sidebar_state_cookie_name, toggle_state);
}
}
function set_sidebar_state()
{
var toggle_state = Cookies.get(sidebar_state_cookie_name);
if (toggle_state !== undefined) {
toggle_sidebar(toggle_state);
}
}

View File

@ -21,7 +21,7 @@
font-weight: 300;
font-style: italic;
font-size: 2.65rem;
margin-bottom: 1em;
margin: .4em 0 1em;
}
h2 {
font-size: 2rem;

View File

@ -1,6 +1,7 @@
.content-wrapper {
flex-grow: 1;
width: 75%;
position: relative;
border-radius: $border-radius 0 0 $border-radius;
.copyright {

View File

@ -0,0 +1,94 @@
$corner-radius: 8px;
.sidebar-toggle {
position: absolute;
display: block;
height: 35px;
top: 3.25rem;
z-index: 100;
border-radius: $border-radius 0 0 $border-radius;
&:hover {
cursor: pointer;
&:before, &:after { cursor: default; }
a { color: rgba($article-text, 1); }
}
&:before, &:after {
content: "";
display: block;
position: absolute;
width: $corner-radius;
height: $corner-radius;
}
&:before { top: ($corner-radius * -1); }
&:after { bottom: ($corner-radius * -1); }
& > a {
font-family: "icomoon";
color: rgba($article-text, .5);
text-decoration: none;
&:before, &:after {
content: "";
display: block;
position: absolute;
width: ($corner-radius * 2);
height: ($corner-radius * 2);
border-radius: 50%;
z-index: 1;
}
&:before { top: ($corner-radius * -2); }
&:after { bottom: ($corner-radius * -2); }
&:hover {
&:before, &:after { cursor: default; }
}
}
}
.content-wrapper .sidebar-toggle {
display: none;
padding: .3rem .3rem .3rem .4rem;
width: 35px;
left: 0;
background-color: $body-bg;
&:before, &:after {
background: $body-bg;
left: 0;
}
& > a {
font-size: 1.25rem;
&:before, &:after {
left: 0;
background: $article-bg;
}
}
}
.sidebar .sidebar-toggle {
padding: .2rem;
width: 30px;
right: 0;
background-color: $article-bg;
&:before, &:after {
background: $article-bg;
right: 0;
}
& > a {
font-size: 1.5rem;
&:before, &:after {
right: 0;
background: $body-bg;
}
}
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// MEDIA QUERIES ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@include media(medium) {
.sidebar-toggle{
display: none;
}
}

View File

@ -1,5 +1,6 @@
.sidebar {
display: block;
position: relative;
flex-grow: 1;
padding: 0 1em;
width: 25%;
@ -41,7 +42,7 @@
}
}
.search-nav-toggle {
.search-and-nav-toggle {
display: flex;
width: 100%;
margin-bottom: .7rem;

View File

@ -3,9 +3,6 @@
padding: .75rem .75rem .65rem;
justify-content: space-between;
&--left { }
&--right { }
.influx-home {
font-family: 'icomoon';
font-size: 1.9rem;
@ -51,6 +48,7 @@
border-radius: $border-radius;
overflow: hidden;
cursor: pointer;
transition: right .2s;
.selected {
padding: 0 1.5rem 0 .75rem;
@ -109,7 +107,7 @@
}
}
.theme-switcher {
.theme-switcher, #search-btn {
display: inline-block;
padding: 0;
font-size: 1.8rem;
@ -119,7 +117,7 @@
width: 30px;
margin-top: 2px;
border: none;
transition: color .2s;
transition: color .2s, opacity .2s;
appearance: none;
overflow: visible;
&:focus {

View File

@ -0,0 +1,61 @@
// Sets CSS overides for when the sidebar is closed
.sidebar {
width: 0;
overflow: hidden;
padding: 0;
transition: all .4s;
.search-and-nav-toggle,
#nav-tree,
.sidebar-toggle {
white-space: nowrap;
opacity: 0;
transition: all .1s;
}
}
.content-wrapper {
width: 100%;
.sidebar-toggle{
display: block;
}
}
.topnav {
#search-btn {
opacity: 1;
}
.version-selector {
right: 5.5rem;
}
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// MEDIA QUERIES ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@import "tools/media-queries";
@include media(medium) {
.sidebar {
width: 100%;
overflow: auto;
padding: 0 1rem;
}
.search-and-nav-toggle, #nav-tree {
opacity: 1 !important;
white-space: normal;
}
.topnav {
#search-btn {
opacity: 0;
}
.version-selector {
right: 3.5rem;
}
}
.content-wrapper .sidebar-toggle {
display: none;
}
}

View File

@ -0,0 +1,15 @@
// Default state of having the sidebar open.
.sidebar {
transition: all .2s;
.search-and-nav-toggle,
#nav-tree {
opacity: 1;
transition: all .3s;
transition-delay: .1s;
}
}
#search-btn {
opacity: 0;
}

View File

@ -13,6 +13,7 @@
"layouts/layout-global",
"layouts/layout-topnav",
"layouts/layout-sidebar",
"layouts/layout-sidebar-toggle",
"layouts/layout-content-wrapper",
"layouts/layout-article",
"layouts/syntax-highlighting";

View File

@ -19,7 +19,7 @@ $g14-chromium: #C6CAD3;
$g15-platinum: #D4D7DD;
$g16-pearl: #E7E8EB;
$g17-whisper: #EEEFF2;
$g18-cloud: #F6F6F8;
$g18-cloud: #F3F3F7;
$g19-ghost: #FAFAFC;
$g20-white: #ffffff;

View File

@ -1,10 +1,10 @@
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?ppkm5');
src: url('fonts/icomoon.eot?ppkm5#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?ppkm5') format('truetype'),
url('fonts/icomoon.woff?ppkm5') format('woff'),
url('fonts/icomoon.svg?ppkm5#icomoon') format('svg');
src: url('fonts/icomoon.eot?o2njz5');
src: url('fonts/icomoon.eot?o2njz5#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?o2njz5') format('truetype'),
url('fonts/icomoon.woff?o2njz5') format('woff'),
url('fonts/icomoon.svg?o2njz5#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
@ -66,9 +66,24 @@
.icon-check:before {
content: "\e912";
}
.icon-chevron-down:before {
content: "\e917";
}
.icon-chevron-left:before {
content: "\e918";
}
.icon-chevron-right:before {
content: "\e919";
}
.icon-chevron-up:before {
content: "\e91a";
}
.icon-heart1:before {
content: "\e913";
}
.icon-menu:before {
content: "\e91b";
}
.icon-settings:before {
content: "\e914";
}

View File

@ -3,6 +3,7 @@
<div class="page-wrapper">
{{ partial "sidebar.html" . }}
<div class="content-wrapper">
<div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-open');return false;"><a href="#">&#59675;</a></div>
{{ partial "article.html" . }}
<div class="copyright">© {{ now.Year }} InfluxData, Inc.</div>
</div>

View File

@ -3,6 +3,7 @@
<div class="page-wrapper">
{{ partial "sidebar.html" . }}
<div class="content-wrapper">
<div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-open');return false;"><a href="#">&#59675;</a></div>
{{ partial "article.html" . }}
<div class="copyright">© {{ now.Year }} InfluxData, Inc.</div>
</div>

View File

@ -3,7 +3,8 @@
<div class="page-wrapper">
{{ partial "sidebar.html" . }}
<div class="content-wrapper">
<div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-open');return false;"><a href="#">&#59675;</a></div>
<div class="cards">
<div class="full">
<h1>{{ $.Page.Title }}</h1>
@ -12,7 +13,7 @@
</div>
</div>
{{ partial "article.html" . }}
{{ partial "article.html" . }}
<div class="copyright">© {{ now.Year }} InfluxData, Inc.</div>
</div>
</div>

View File

@ -1,7 +1,9 @@
{{ $jquery := resources.Get "js/jquery-3.3.1.min.js" }}
{{ $cookies := resources.Get "js/js.cookie.js" }}
{{ $themes := resources.Get "js/docs-themes.js" }}
{{ $headerjs := slice $jquery $cookies $themes | resources.Concat "js/header.bundle.js" }}
{{ $sidebar := resources.Get "js/sidebar-toggle.js" }}
{{ $headerjs := slice $jquery $cookies $themes $sidebar | resources.Concat "js/header.bundle.js" }}
<script type="text/javascript" src="{{ $headerjs.RelPermalink }}" ></script>
<script type="text/javascript">set_style_from_cookie();</script>
<script type="text/javascript">set_sidebar_state();</script>

View File

@ -1,5 +1,7 @@
{{ $cssOptionsDark := (dict "targetPath" "dark-theme.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $cssOptionsLight := (dict "targetPath" "light-theme.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $cssSidebarOpen := (dict "targetPath" "sidebar-open.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $cssSidebarClose := (dict "targetPath" "sidebar-closed.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $PostCSSOptions := (dict "use" "autoprefixer" "noMap" false) }}
{{ $stylesDark := resources.Get "styles/styles-default.scss" | toCSS $cssOptionsDark | postCSS $PostCSSOptions | fingerprint }}
@ -7,3 +9,9 @@
{{ $stylesLight := resources.Get "styles/styles-light.scss" | toCSS $cssOptionsLight | postCSS $PostCSSOptions | fingerprint }}
<link rel="alternate stylesheet" title="light-theme" type="text/css" href="{{ $stylesLight.RelPermalink }}">
{{ $stylesSidebarOpen := resources.Get "styles/sidebar-open.scss" | toCSS $cssOptionsDark | postCSS $PostCSSOptions | fingerprint }}
<link rel="stylesheet" title="sidebar-open" type="text/css" href="{{ $stylesSidebarOpen.RelPermalink }}">
{{ $stylesSidebarClosed := resources.Get "styles/sidebar-closed.scss" | toCSS $cssOptionsLight | postCSS $PostCSSOptions | fingerprint }}
<link rel="alternate stylesheet" title="sidebar-closed" type="text/css" href="{{ $stylesSidebarClosed.RelPermalink }}">

View File

@ -1,7 +1,10 @@
{{ $currentPage := . }}
{{ $currentVersion := (index (findRE "[^/]+.*?" .RelPermalink) 0) }}
<aside class="sidebar">
<div class="search-nav-toggle">
<div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-closed');return false;"><a href="#">&#59672;</a></div>
<div class="search-and-nav-toggle">
<div class="sidebar--search">
<input class="sidebar--search-field"
id="algolia-search-input"

View File

@ -20,6 +20,7 @@
<li><a href="{{ .URL }}" {{if in .Name "1.x" }}class="legacy" target="_blank"{{ end }}>{{ .Name }}</a></li>
{{ end }}
</div>
<button id="search-btn" onclick="toggle_sidebar('sidebar-open');document.getElementById('algolia-search-input').focus();return false;"><span class="icon-search"></span></button>
<button class="theme-switcher" id="theme-switch-light" onclick="switch_style('light-theme');return false;"><span class="icon-sun1"></span></button>
<button class="theme-switcher" id="theme-switch-dark" onclick="switch_style('dark-theme');return false;"><span class="icon-moon1"></span></button>
</div>

Binary file not shown.

View File

@ -30,6 +30,11 @@
<glyph unicode="&#xe914;" glyph-name="settings" d="M512 597.334c-93.867 0-170.667-76.8-170.667-170.667s76.8-170.667 170.667-170.667c93.867 0 170.667 76.8 170.667 170.667s-76.8 170.667-170.667 170.667zM512 341.334c-46.933 0-85.333 38.4-85.333 85.333s38.4 85.333 85.333 85.333c46.933 0 85.333-38.4 85.333-85.333s-38.4-85.333-85.333-85.333zM866.133 281.6c4.267 8.533 12.8 17.067 29.867 17.067 72.533 0 128 55.467 128 128s-55.467 128-128 128h-8.533c-8.533 0-17.067 4.267-21.333 12.8 0 4.267 0 4.267-4.267 8.533-4.267 8.533-4.267 21.333 8.533 34.133 51.2 51.2 51.2 132.267 0 179.2v0c0 0 0 0 0 0-25.6 25.6-55.467 38.4-89.6 38.4 0 0 0 0 0 0-34.133 0-68.267-12.8-93.867-38.4-8.533-8.533-21.333-8.533-29.867-4.267-8.533 0-17.067 12.8-17.067 25.6 0 72.533-55.467 128-128 128s-128-55.467-128-128v-8.533c0-8.533-4.267-17.067-12.8-21.333-4.267 0-4.267 0-8.533-4.267-8.533-4.267-21.333 0-34.133 8.533-51.2 51.2-132.267 51.2-179.2 0-51.2-51.2-51.2-132.267 4.267-183.467 8.533-8.533 8.533-21.333 4.267-34.133-4.267-8.533-17.067-17.067-29.867-17.067-72.533 0-128-55.467-128-128s55.467-128 128-128h8.533c12.8 0 21.333-8.533 25.6-17.067s4.267-21.333-8.533-34.133c-25.6-25.6-38.4-55.467-38.4-89.6s12.8-64 38.4-89.6c0 0 0 0 0 0 51.2-51.2 132.267-51.2 183.467 4.267 8.533 8.533 21.333 8.533 34.133 4.267s17.067-12.8 17.067-29.867c0-72.533 55.467-128 128-128s128 55.467 128 128v8.533c0 12.8 8.533 21.333 17.067 25.6s21.333 4.267 34.133-8.533c51.2-51.2 132.267-51.2 179.2 0 51.2 51.2 51.2 132.267-4.267 183.467-4.267 8.533-8.533 21.333-4.267 29.867 0 0 0 0 0 0zM789.333 315.734c-17.067-42.667-8.533-89.6 25.6-128 8.533-8.533 12.8-17.067 12.8-29.867s-4.267-21.333-12.8-29.867c-8.533-8.533-17.067-12.8-29.867-12.8 0 0 0 0 0 0-12.8 0-21.333 4.267-34.133 17.067-34.133 34.133-81.067 42.667-123.733 21.333-42.667-17.067-68.267-59.733-68.267-102.4v-8.533c0-25.6-17.067-42.667-42.667-42.667s-42.667 17.067-42.667 42.667c0 0 0 4.267 0 4.267 0 46.933-29.867 85.333-72.533 102.4-12.8 8.533-29.867 8.533-46.933 8.533-29.867 0-59.733-12.8-81.067-34.133-17.067-17.067-42.667-17.067-59.733 0 0 0 0 0 0 0v0c-8.533 8.533-12.8 17.067-12.8 29.867s4.267 21.333 17.067 34.133c34.133 34.133 42.667 81.067 21.333 123.733-17.067 42.667-59.733 68.267-102.4 68.267h-8.533c-25.6 0-42.667 17.067-42.667 42.667s17.067 42.667 42.667 42.667c0 0 4.267 0 4.267 0 46.933 0 85.333 29.867 102.4 72.533s8.533 89.6-25.6 128c-17.067 17.067-17.067 42.667 0 59.733s42.667 17.067 64-4.267c29.867-29.867 76.8-38.4 115.2-25.6 4.267 0 8.533 0 12.8 4.267 42.667 17.067 68.267 59.733 68.267 102.4v8.533c0 25.6 17.067 42.667 42.667 42.667s42.667-17.067 42.667-46.933c0-46.933 25.6-85.333 68.267-102.4s89.6-8.533 128 25.6c8.533 8.533 17.067 12.8 29.867 12.8v0c12.8 0 21.333-4.267 29.867-12.8 0 0 0 0 0 0 17.067-17.067 17.067-42.667-4.267-64-29.867-29.867-38.4-76.8-25.6-115.2 0-4.267 0-8.533 4.267-12.8 17.067-42.667 59.733-68.267 102.4-68.267h8.533c25.6 0 42.667-17.067 42.667-42.667s-17.067-42.667-46.933-42.667c-42.667 0-85.333-25.6-102.4-68.267z" />
<glyph unicode="&#xe915;" glyph-name="zoom-in" d="M925.867 72.534l-157.867 157.867c51.2 64 85.333 149.333 85.333 238.933 0 213.333-170.667 384-384 384s-384-170.667-384-384c0-213.333 170.667-384 384-384 89.6 0 174.933 29.867 238.933 85.333l157.867-157.867c8.533-8.533 21.333-12.8 29.867-12.8s21.333 4.267 29.867 12.8c17.067 17.067 17.067 42.667 0 59.733zM170.667 469.334c0 166.4 132.267 298.667 298.667 298.667s298.667-132.267 298.667-298.667c0-81.067-34.133-157.867-85.333-209.067 0 0 0 0 0 0s0 0 0 0c-55.467-55.467-128-85.333-209.067-85.333-170.667-4.267-302.933 128-302.933 294.4zM597.333 512h-85.333v85.333c0 25.6-17.067 42.667-42.667 42.667s-42.667-17.067-42.667-42.667v-85.333h-85.333c-25.6 0-42.667-17.067-42.667-42.667s17.067-42.667 42.667-42.667h85.333v-85.333c0-25.6 17.067-42.667 42.667-42.667s42.667 17.067 42.667 42.667v85.333h85.333c25.6 0 42.667 17.067 42.667 42.667s-17.067 42.667-42.667 42.667z" />
<glyph unicode="&#xe916;" glyph-name="zoom-out" d="M925.867 72.534l-157.867 157.867c51.2 64 85.333 149.333 85.333 238.933 0 213.333-170.667 384-384 384s-384-170.667-384-384c0-213.333 170.667-384 384-384 89.6 0 174.933 29.867 238.933 85.333l157.867-157.867c8.533-8.533 21.333-12.8 29.867-12.8s21.333 4.267 29.867 12.8c17.067 17.067 17.067 42.667 0 59.733zM170.667 469.334c0 166.4 132.267 298.667 298.667 298.667s298.667-132.267 298.667-298.667c0-81.067-34.133-157.867-85.333-209.067 0 0 0 0 0 0s0 0 0 0c-55.467-55.467-128-85.333-209.067-85.333-170.667-4.267-302.933 128-302.933 294.4zM597.333 512h-256c-25.6 0-42.667-17.067-42.667-42.667s17.067-42.667 42.667-42.667h256c25.6 0 42.667 17.067 42.667 42.667s-17.067 42.667-42.667 42.667z" />
<glyph unicode="&#xe917;" glyph-name="chevron-down" d="M797.867 584.534c-17.067 17.067-42.667 17.067-59.733 0l-226.133-226.133-226.133 226.133c-17.067 17.067-42.667 17.067-59.733 0s-17.067-42.667 0-59.733l256-256c8.533-8.533 21.333-12.8 29.867-12.8s21.333 4.267 29.867 12.8l256 256c17.067 17.067 17.067 42.667 0 59.733z" />
<glyph unicode="&#xe918;" glyph-name="chevron-left" d="M443.733 426.667l226.133 226.133c17.067 17.067 17.067 42.667 0 59.733s-42.667 17.067-59.733 0l-256-256c-17.067-17.067-17.067-42.667 0-59.733l256-256c8.533-8.533 21.333-12.8 29.867-12.8s21.333 4.267 29.867 12.8c17.067 17.067 17.067 42.667 0 59.733l-226.133 226.133z" />
<glyph unicode="&#xe919;" glyph-name="chevron-right" d="M669.867 456.534l-256 256c-17.067 17.067-42.667 17.067-59.733 0s-17.067-42.667 0-59.733l226.133-226.133-226.133-226.133c-17.067-17.067-17.067-42.667 0-59.733 8.533-8.533 17.067-12.8 29.867-12.8s21.333 4.267 29.867 12.8l256 256c17.067 17.067 17.067 42.667 0 59.733z" />
<glyph unicode="&#xe91a;" glyph-name="chevron-up" d="M797.867 328.534l-256 256c-17.067 17.067-42.667 17.067-59.733 0l-256-256c-17.067-17.067-17.067-42.667 0-59.733s42.667-17.067 59.733 0l226.133 226.133 226.133-226.133c8.533-8.533 21.333-12.8 29.867-12.8s21.333 4.267 29.867 12.8c17.067 17.067 17.067 42.667 0 59.733z" />
<glyph unicode="&#xe91b;" glyph-name="menu" d="M896 469.334h-768c-25.6 0-42.667-17.067-42.667-42.667s17.067-42.667 42.667-42.667h768c25.6 0 42.667 17.067 42.667 42.667s-17.067 42.667-42.667 42.667zM128 640h768c25.6 0 42.667 17.067 42.667 42.667s-17.067 42.667-42.667 42.667h-768c-25.6 0-42.667-17.067-42.667-42.667s17.067-42.667 42.667-42.667zM896 213.334h-768c-25.6 0-42.667-17.067-42.667-42.667s17.067-42.667 42.667-42.667h768c25.6 0 42.667 17.067 42.667 42.667s-17.067 42.667-42.667 42.667z" />
<glyph unicode="&#xe934;" glyph-name="folder-upload" d="M576 704l-128 128h-448v-832h1024v704h-448zM512 480l224-224h-160v-256h-128v256h-160l224 224z" />
<glyph unicode="&#xe94c;" glyph-name="map2" d="M672 768l-320 128-352-128v-768l352 128 320-128 352 128v768l-352-128zM384 814.27l256-102.4v-630.138l-256 102.398v630.14zM64 723.172l256 93.090v-631.8l-256-93.088v631.798zM960 172.828l-256-93.092v631.8l256 93.090v-631.798z" />
<glyph unicode="&#xe960;" glyph-name="download" d="M512 384l256 256h-192v256h-128v-256h-192zM744.726 488.728l-71.74-71.742 260.080-96.986-421.066-157.018-421.066 157.018 260.080 96.986-71.742 71.742-279.272-104.728v-256l512-192 512 192v256z" />

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Binary file not shown.