Skip to content

Commit

Permalink
updates for reviews (article header topbar)
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Apr 28, 2017
1 parent 6ac7b95 commit bbd8c69
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 81 deletions.
121 changes: 64 additions & 57 deletions assets/html/documenter.css
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ nav.toc li.current > .toctext {
background-color: white;
}

div#topbar {
display: none;
}

article {
margin-left: 20em;
min-width: 20em;
Expand All @@ -277,6 +273,10 @@ article {

article > header {}

article > header div#topbar {
display: none;
}

article > header nav ul {
display: inline-block;
list-style: none;
Expand Down Expand Up @@ -434,73 +434,85 @@ article section.docstring a.source-link {
}

@media only screen and (max-width: 768px) {
div#topbar {
display: block; /* is mobile */
nav.toc {
position: fixed;
width: 100%;
height: 2.7em;
background-color: white;
box-shadow: 0 1px 3px rgba(0,0,0,.26);
z-index: 2;
top: 0em;
-webkit-transition-property: top; /* Safari */
overflow-y: scroll;
width: 16em;
left: -16em;
-webkit-overflow-scrolling: touch;
-webkit-transition-property: left; /* Safari */
-webkit-transition-duration: 0.3s; /* Safari */
transition-property: top;
transition-property: left;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out; /* Safari */
transition-timing-function: ease-out;
z-index: 2;
}

div#topbar span {
nav.toc.show {
left: 0;
}

article {
margin-left: 0;
padding: 3em 0.9em 0 0.9em; /* top right bottom left */
overflow-wrap: break-word;
}

article > header {
position: fixed;
width: 80%;
height: 1.8em;
overflow: hidden;
margin-top: 0.6em;
margin-left: 1em;
left: 0;
z-index: 1;
}

div#topbar a.fa-bars {
float: right;
padding: 0.4em 0.5em 0.2em 1em; /* top right bottom left */
font-size: x-large;
article > header nav, hr {
display: none;
}

div#topbar a.fa-bars:visited {
color: #3091d1;
article > header div#topbar {
display: block; /* is mobile */
position: fixed;
width: 100%;
height: 1.5em;
padding-top: 1em;
padding-bottom: 1em;
background-color: #fcfcfc;
box-shadow: 0 1px 3px rgba(0,0,0,.26);
top: 0;
-webkit-transition-property: top; /* Safari */
-webkit-transition-duration: 0.3s; /* Safari */
transition-property: top;
transition-duration: 0.3s;
}

div#topbar.headroom--unpinned.headroom--not-top.headroom--not-bottom {
top: -3em;
article > header div#topbar.headroom--unpinned.headroom--not-top.headroom--not-bottom {
top: -4em;
-webkit-transition-property: top; /* Safari */
-webkit-transition-duration: 0.7s; /* Safari */
transition-property: top;
transition-duration: 0.7s;
}

nav.toc {
article > header div#topbar span {
position: fixed;
overflow-y: scroll;
width: 16em;
left: -16em;
-webkit-overflow-scrolling: touch;
-webkit-transition-property: left; /* Safari */
-webkit-transition-duration: 0.3s; /* Safari */
transition-property: left;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out; /* Safari */
transition-timing-function: ease-out;
z-index: 3;
width: 80%;
height: 1.5em;
margin-top: -0.1em;
margin-left: 0.9em;
font-size: 1.2em;
overflow: hidden;
}

nav.toc.show {
left: 0em;
article > header div#topbar a.fa-bars {
float: right;
padding: 0.6em;
margin-top: -0.6em;
margin-right: 0.3em;
font-size: 1.5em;
}

article {
margin-left: 0em;
padding-left: 0.9em;
padding-right: 0.9em;
overflow-wrap: break-word;
z-index: 1;
article > header div#topbar a.fa-bars:visited {
color: #3091d1;
}

article table {
Expand All @@ -515,15 +527,10 @@ article section.docstring a.source-link {
article span.MathJax {
overflow: hidden;
}
}

article > header {
display: none;
}

article [id]:before {
display: inline-block;
content: "";
padding-top: 3.5em;
margin-top: -3.5em;
@media only screen and (max-width: 320px) {
body {
font-size: 15px;
}
}
18 changes: 10 additions & 8 deletions assets/html/documenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,25 @@ require(['jquery', 'headroom'], function($, Headroom) {
$("nav.toc li.current a.toctext").click(function() {
navtoc.toggleClass('show');
});
$("div#topbar a.btn").click(function(ev) {
$("article > header div#topbar a.fa-bars").click(function(ev) {
ev.preventDefault();
navtoc.toggleClass('show');
if (navtoc.hasClass('show')) {
var title = $("div#topbar span").text();
var title = $("article > header div#topbar span").text();
$("nav.toc ul li a:contains('" + title + "')").focus();
}
ev.preventDefault();
});
$("article#docs").bind('click', function() {
$("article#docs").bind('click', function(ev) {
if ($(ev.target).is('div#topbar a.fa-bars')) {
return;
}
if (navtoc.hasClass('show')) {
navtoc.toggleClass('show');
navtoc.removeClass('show');
}
});
if ($("div#topbar").css('display') == 'block') {
var headroom = new Headroom(document.querySelector("div#topbar"), {"tolerance": {"down": 10}});
if ($("article > header div#topbar").css('display') == 'block') {
var headroom = new Headroom(document.querySelector("article > header div#topbar"), {"tolerance": {"up": 10, "down": 10}});
headroom.init();
}
})

})
21 changes: 5 additions & 16 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,13 @@ function render_page(ctx, navnode)
page = getpage(ctx, navnode)

head = render_head(ctx, navnode)
topbar = render_topbar(ctx, navnode)
navmenu = render_navmenu(ctx, navnode)
article = render_article(ctx, navnode)

htmldoc = DOM.HTMLDocument(
html[:lang=>"en"](
head,
body(topbar, navmenu, article)
body(navmenu, article)
)
)
open(Formats.extension(:html, page.build), "w") do io
Expand Down Expand Up @@ -276,18 +275,6 @@ function render_search(ctx)
end
end


# topbar for mobile
# ------------------------------------------------------------------------------

function render_topbar(ctx, navnode)
@tags div span a

page_title = string(mdflatten(pagetitle(ctx, navnode)))
div["#topbar"](span(page_title), a[".btn .fa .fa-bars", :href => "#"])
end


# Navigation menu
# ------------------------------------------------------------------------------

Expand Down Expand Up @@ -389,7 +376,7 @@ end
# ------------------------------------------------------------------------------

function render_article(ctx, navnode)
@tags article header footer nav ul li hr span a
@tags article header footer nav ul li hr span a div

header_links = map(Documents.navpath(navnode)) do nn
title = mdconvert(pagetitle(ctx, nn))
Expand All @@ -411,7 +398,9 @@ function render_article(ctx, navnode)
Utilities.unwrap(Utilities.url(ctx.doc.user.repo, getpage(ctx, navnode).source)) do url
push!(topnav.nodes, a[".edit-page", :href => url](span[".fa"](logo), " Edit on $host"))
end
art_header = header(topnav, hr())
page_title = string(mdflatten(pagetitle(ctx, navnode)))
topbar = div["#topbar"](span(page_title), a[".fa .fa-bars", :href => "#"])
art_header = header(topnav, hr(), topbar)

# build the footer with nav links
art_footer = footer(hr())
Expand Down

0 comments on commit bbd8c69

Please sign in to comment.