Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
41d51d9
define nav variable in nav script so it's available to showNav even i…
mojavelinux Mar 31, 2022
8a05e6e
only call highlightBlock on code element with data-lang attribute
mojavelinux Jul 9, 2022
7002d1a
clean up copy to clipboard script; pass UI root path as data attribute
mojavelinux Sep 18, 2022
7e719b9
Break edit-this-page out into separate partial
ferdnyc Jun 7, 2023
d58566e
comment out unused uiRootPath variable assignment
mojavelinux Jul 21, 2023
1d7a6ee
allow page-pagination to be set to next or prev to fine-tune which di…
mojavelinux Aug 22, 2023
9696c97
add fallbacks in scripts if HTML document does not have article.doc
mojavelinux Oct 10, 2023
58dfc21
add aria- attributes to mobile menu button
mojavelinux Nov 7, 2023
7df2b01
replace data-target with aria-controls (but check for data-target as …
mojavelinux Nov 7, 2023
eefdc7b
resolves #72 add toggle expand/collapse all button to nav
mojavelinux Nov 9, 2023
93d6992
resolves #168 don't lock scrolling after resizing when a mobile menu …
mojavelinux Nov 14, 2023
844e9f5
provide better fallback for uiRootPath in copy to clipboard script
mojavelinux Nov 14, 2023
4d545ac
hide expand/collapse button on nav if there are no expandable items
mojavelinux Nov 22, 2023
367d847
move nav menu toggle button outside of conditional for component title
mojavelinux Nov 22, 2023
67ce09f
hide nav toggle button if nav container is absent
mojavelinux Jul 16, 2024
39f4932
feat(a11y): Give the mobile menu button an accessible name and aria s…
lfrancke Aug 12, 2026
46b0794
fix: Guard against a missing toolbar in the fragment jumper
lfrancke Aug 12, 2026
649b2c5
Update ui/src/css/header.css
lfrancke Aug 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ui/src/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* It also handles the mobile version of the menu.
*/

html.is-clipped--navbar {
overflow-y: hidden;
@media screen and (max-width: 1200px) {
html.is-clipped--navbar {
overflow-y: hidden;
}
}

body {
Expand Down
33 changes: 29 additions & 4 deletions ui/src/css/nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
* of the sidebar menu needs to be adjusted.
*/

@media screen and (max-width: 1023.5px) {
html.is-clipped--nav {
overflow-y: hidden;
}
}

.nav-container {
position: fixed;
top: var(--body-top);
Expand Down Expand Up @@ -71,10 +77,6 @@
height: inherit;
}

html.is-clipped--nav {
overflow-y: hidden;
}

.nav-panel-menu {
overflow-y: scroll;
overscroll-behavior: none;
Expand Down Expand Up @@ -108,6 +110,29 @@ html.is-clipped--nav {
color: var(--nav-font-color);
}

.nav-menu-toggle {
background: transparent url(../img/octicons-16.svg#view-unfold) no-repeat center / 100% 100%;
border: none;
float: right;
height: 1em;
margin-right: -0.5rem;
opacity: 0.75;
outline: none;
padding: 0;
position: sticky;
top: calc((var(--nav-line-height) - 1 + 0.5) * 1rem);
visibility: hidden;
width: 1em;
}

.nav-menu-toggle.is-active {
background-image: url(../img/octicons-16.svg#view-fold);
}

.nav-panel-menu.is-active:hover .nav-menu-toggle {
visibility: visible;
}

.nav-menu h3.title {
color: var(--nav-heading-font-color);
font-size: inherit;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/img/octicons-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions ui/src/js/01-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
var SECT_CLASS_RX = /^sect(\d)$/

var navContainer = document.querySelector('.nav-container')
if (!navContainer) return
var navToggle = document.querySelector('.nav-toggle')
if (!navContainer && (!navToggle || (navToggle.hidden = true))) return
var nav = navContainer.querySelector('.nav')
var navMenuToggle = navContainer.querySelector('.nav-menu-toggle')

navToggle.addEventListener('click', showNav)
navContainer.addEventListener('click', trapEvent)

var menuPanel = navContainer.querySelector('[data-panel=menu]')
if (!menuPanel) return
var explorePanel = navContainer.querySelector('[data-panel=explore]')
var nav = navContainer.querySelector('.nav')

var currentPageItem = menuPanel.querySelector('.is-current-page')
var originalPageItem = currentPageItem
Expand All @@ -34,6 +35,22 @@
}
})

if (navMenuToggle && menuPanel.querySelector('.nav-item-toggle')) {
navMenuToggle.style.display = ''
navMenuToggle.addEventListener('click', function () {
var collapse = !this.classList.toggle('is-active')
find(menuPanel, '.nav-item > .nav-item-toggle').forEach(function (btn) {
collapse ? btn.parentElement.classList.remove('is-active') : btn.parentElement.classList.add('is-active')
})
if (currentPageItem) {
if (collapse) activateCurrentPath(currentPageItem)
scrollItemToMidpoint(menuPanel, currentPageItem.querySelector('.nav-link'))
} else {
menuPanel.scrollTop = 0
}
})
}

if (explorePanel) {
explorePanel.querySelector('.context').addEventListener('click', function () {
// NOTE logic assumes there are only two panels
Expand Down
1 change: 1 addition & 0 deletions ui/src/js/02-on-this-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

var articleSelector = 'article.doc'
var article = document.querySelector(articleSelector)
if (!article) return
var headingsSelector = []
for (var level = 0; level <= levels; level++) {
var headingSelector = [articleSelector]
Expand Down
3 changes: 2 additions & 1 deletion ui/src/js/03-fragment-jumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict'

var article = document.querySelector('article.doc')
if (!article) return
var toolbar = document.querySelector('.toolbar')
var supportsScrollToOptions = 'scrollTo' in document.documentElement

Expand All @@ -19,7 +20,7 @@
window.location.hash = '#' + this.id
e.preventDefault()
}
var y = computePosition(this, 0) - toolbar.getBoundingClientRect().bottom
var y = computePosition(this, 0) - (toolbar ? toolbar.getBoundingClientRect().bottom : 0)
var instant = e === false && supportsScrollToOptions
instant ? window.scrollTo({ left: 0, top: y, behavior: 'instant' }) : window.scrollTo(0, y)
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/js/05-mobile-navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
function toggleNavbarMenu (e) {
e.stopPropagation() // trap event
document.documentElement.classList.toggle('is-clipped--navbar')
this.classList.toggle('is-active')
var menu = document.getElementById(this.dataset.target)
navbarBurger.setAttribute('aria-expanded', this.classList.toggle('is-active'))
var menu = document.getElementById(this.getAttribute('aria-controls') || this.dataset.target)
menu.classList.toggle('is-active')
}
})()
Expand Down
12 changes: 8 additions & 4 deletions ui/src/js/06-copy-to-clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
var CMD_RX = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
var LINE_CONTINUATION_RX = /( ) *\\\n *|\\\n( ?) */g
var TRAILING_SPACE_RX = / +$/gm

var config = (document.getElementById('site-script') || { dataset: {} }).dataset
var supportsCopy = window.navigator.clipboard
var svgAs = config.svgAs
var uiRootPath = (config.uiRootPath == null ? window.uiRootPath : config.uiRootPath) || '.'

;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) {
var code, language, lang, copy, toast, toolbox
Expand All @@ -28,19 +32,19 @@
}
;(toolbox = document.createElement('div')).className = 'source-toolbox'
if (lang) toolbox.appendChild(lang)
if (window.navigator.clipboard) {
if (supportsCopy) {
;(copy = document.createElement('button')).className = 'copy-button'
copy.setAttribute('title', 'Copy to clipboard')
if (config.svgAs === 'svg') {
if (svgAs === 'svg') {
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute('class', 'copy-icon')
var use = document.createElementNS('http://www.w3.org/2000/svg', 'use')
use.setAttribute('href', window.uiRootPath + '/img/octicons-16.svg#icon-clippy')
use.setAttribute('href', uiRootPath + '/img/octicons-16.svg#icon-clippy')
svg.appendChild(use)
copy.appendChild(svg)
} else {
var img = document.createElement('img')
img.src = window.uiRootPath + '/img/octicons-16.svg#view-clippy'
img.src = uiRootPath + '/img/octicons-16.svg#view-clippy'
img.alt = 'copy icon'
img.className = 'copy-icon'
copy.appendChild(img)
Expand Down
2 changes: 1 addition & 1 deletion ui/src/js/vendor/highlight.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ hljs.registerLanguage('xml', xml)
hljs.registerLanguage('yaml', yaml)
hljs.registerLanguage('toml', ini)

for (const node of document.querySelectorAll('pre code.hljs')) {
for (const node of document.querySelectorAll('pre code.hljs[data-lang]')) {
hljs.highlightElement(node)
}
5 changes: 5 additions & 0 deletions ui/src/partials/edit-this-page.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#if (and page.fileUri (not env.CI))}}
<div class="edit-this-page"><a href="{{page.fileUri}}">Edit this Page</a></div>
{{else if (and page.editUrl (or env.FORCE_SHOW_EDIT_PAGE_LINK (not page.origin.private)))}}
<div class="edit-this-page"><a href="{{page.editUrl}}">Edit this Page</a></div>
{{/if}}
2 changes: 1 addition & 1 deletion ui/src/partials/footer-scripts.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script src="{{{uiRootPath}}}/js/site.js"></script>
<script id="site-script" src="{{{uiRootPath}}}/js/site.js" data-ui-root-path="{{{uiRootPath}}}"></script>
<script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script>
<script async src="{{{uiRootPath}}}/js/vendor/tabs.js" data-sync-storage-key="preferred-tab"></script>
<script>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/partials/head-scripts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
</script>
-->
{{/with}}
{{!--
<script>var uiRootPath = '{{{uiRootPath}}}'</script>
--}}
2 changes: 1 addition & 1 deletion ui/src/partials/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{/navbar}}
</div>
<div id="topbar-right" class="navbar-end">
<button class="navbar-burger" data-target="popup-menu">
<button class="navbar-burger" aria-controls="popup-menu" aria-expanded="false" aria-label="Toggle main menu">
<span></span>
<span></span>
<span></span>
Expand Down
1 change: 1 addition & 0 deletions ui/src/partials/nav-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{#with page.navigation}}
<div class="nav-panel-menu is-active" data-panel="menu">
<nav class="nav-menu">
<button class="nav-menu-toggle" aria-label="Toggle expand/collapse all" style="display: none"></button>
<div class="title-wrapper">
{{#with @root.page.componentVersion}}
<h3 class="title"><a href="{{{relativize ./url}}}">{{./title}}</a></h3>
Expand Down
4 changes: 4 additions & 0 deletions ui/src/partials/pagination.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{{#unless (eq page.attributes.pagination undefined)}}
{{#if (or page.previous page.next)}}
<nav class="pagination" data-pagefind-ignore>
{{#if (ne page.attributes.pagination 'next')}}
{{#with page.previous}}
<span class="prev"><a href="{{{relativize ./url}}}">{{{./content}}}</a></span>
{{/with}}
{{/if}}
{{#if (ne page.attributes.pagination 'prev')}}
{{#with page.next}}
<span class="next"><a href="{{{relativize ./url}}}">{{{./content}}}</a></span>
{{/with}}
{{/if}}
</nav>
{{/if}}
{{/unless}}
6 changes: 1 addition & 5 deletions ui/src/partials/toolbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@
<a href="{{{relativize this}}}" class="home-link{{#if @root.page.home}} is-current{{/if}}"></a>
{{/with}}
{{> breadcrumbs}}
{{#if (and page.fileUri (not env.CI))}}
<div class="edit-this-page"><a href="{{page.fileUri}}">Edit this Page</a></div>
{{else if (and page.editUrl (or env.FORCE_SHOW_EDIT_PAGE_LINK (not page.origin.private)))}}
<div class="edit-this-page"><a href="{{page.editUrl}}">Edit this Page</a></div>
{{/if}}
{{> edit-this-page}}
</div>
Loading