This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git

commit ee33517822796e906319db36fba05d247dc02d82
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Tue Nov 3 21:39:50 2026 +0100

    Keep the side menu open on phones, with a button that hides it
    
    Below 992 px the side menu was a Bootstrap offcanvas panel that only a
    script could open, so with JavaScript off a phone reader could not reach
    any menu link. The menu is now open by default above the content; the
    button in the banner row hides and shows it. fluido.js shows the button,
    so without JavaScript the menu is simply open. Nothing is remembered:
    every page starts with the menu open. The menu comes first in the source
    again, so that the open menu sits under the button that controls it.
---
 src/it/sidebar/verify.groovy              | 23 ++++++++++------
 src/main/resources/META-INF/maven/site.vm | 46 +++++++++++++++----------------
 src/main/resources/css/maven-base.css     |  9 +++---
 src/main/resources/js/fluido.js           | 25 ++++++++++++++++-
 4 files changed, 65 insertions(+), 38 deletions(-)

diff --git a/src/it/sidebar/verify.groovy b/src/it/sidebar/verify.groovy
index 94ec53f..dd492d1 100644
--- a/src/it/sidebar/verify.groovy
+++ b/src/it/sidebar/verify.groovy
@@ -35,20 +35,25 @@ assert html.contains('<div id="bannerLeft" 
class="me-auto"><p class="m-0 fs-3 fw
 // the right banner is hidden on phones when there is a left one
 assert html.contains('<div id="bannerRight" class="d-none d-md-block"><img 
class="img-fluid" src="../../../images/logos/MavenLogoLeaf.svg" alt="" 
style="width: 340px;height: 83px;" /></div>')
 
-// below 992 px the side menu is an offcanvas panel, opened by a Menu button 
at the top
-assert html.contains( '<div class="offcanvas-lg offcanvas-start" tabindex="-1" 
id="sidebarMenu" aria-labelledby="sidebarMenuLabel">' )
-// the hamburger that opens it is the first thing in the banner row
-assert html =~ /<div id="banner" class="navbar[^"]*">\s*<button type="button" 
class="navbar-toggler menu-toggle d-lg-none[^"]*" data-bs-toggle="offcanvas" 
data-bs-target="#sidebarMenu"/
+// below 992 px the side menu is open above the content; a button, hidden 
until fluido.js shows it, hides and shows it
+assert html.contains( '<div id="sidebarMenu" class="sidebar-menu mb-3">' )
+assert !html.contains( 'offcanvas' )
+// the button is the first thing in the banner row, controls the menu, starts 
expanded and needs no Bootstrap script
+assert html =~ /<div id="banner" class="navbar[^"]*">\s*<button type="button" 
class="navbar-toggler menu-toggle d-lg-none[^"]*" aria-controls="sidebarMenu" 
aria-expanded="true" aria-label="Menu" hidden>/
+assert !( html =~ /class="navbar-toggler menu-toggle[^>]*data-bs-toggle/ )
+// nothing remembers the menu's state
+def fluidoJs = new File( basedir, "target/site/js" ).listFiles().find { 
it.name.startsWith( 'apache-maven-fluido-' ) }
+assert fluidoJs != null && fluidoJs.text.contains( 'menu-hidden' ) && 
!fluidoJs.text.contains( 'localStorage' )
 
 // Bootstrap 5 stylesheet and script bundle, no jQuery
 assert html.contains( '<link rel="stylesheet" 
href="./css/bootstrap-5.3.8.min.css" />' )
 assert new File( basedir, "target/site/css/bootstrap-5.3.8.min.css" ).exists()
 assert !html.contains( 'jquery' )
 assert new File( basedir, "target/site/js/bootstrap-5.3.8.bundle.min.js" 
).exists()
-// default columns: Bootstrap 5 grid, content first in the source
-assert html.contains( '<main id="bodyColumn" class="col-lg-9 col-xl-10 
order-lg-last">' )
-assert html.contains( '<header id="leftColumn" class="col-lg-3 col-xl-2 
order-lg-first">' )
-assert html.indexOf( 'id="bodyColumn"' ) < html.indexOf( 'id="leftColumn"' )
+// default columns: Bootstrap 5 grid, the menu first in the source so that it 
is open above the content on phones
+assert html.contains( '<main id="bodyColumn" class="col-lg-9 col-xl-10">' )
+assert html.contains( '<header id="leftColumn" class="col-lg-3 col-xl-2">' )
+assert html.indexOf( 'id="leftColumn"' ) < html.indexOf( 'id="bodyColumn"' )
 // the theme switch is on by default: light until the reader chooses, script 
in the head
 assert html.contains( '<button type="button" class="theme-switch btn btn-sm 
border" title="Theme" aria-label="Theme" hidden>' )
 assert html.contains( 'class="theme-icon-dark"' )
@@ -71,7 +76,7 @@ assert html =~ /(?s)<div class="page-tools d-flex 
align-items-center gap-2 mb-2
 // pages listed in sideBarSkipped render without the side menu, the others 
keep it
 String summary = new File( basedir, "target/site/summary.html" ).text
 assert !summary.contains( 'id="leftColumn"' )
-assert !summary.contains( 'data-bs-target="#sidebarMenu"' )
+assert !summary.contains( 'aria-controls="sidebarMenu"' )
 assert !new File( basedir, "target/site/dependency-info.html" ).text.contains( 
'id="leftColumn"' )
 assert html.contains( 'id="leftColumn"' )
 assert new File( basedir, "target/site/plugins.html" ).text.contains( 
'id="leftColumn"' )
diff --git a/src/main/resources/META-INF/maven/site.vm 
b/src/main/resources/META-INF/maven/site.vm
index 06768cd..5014bc7 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -188,10 +188,11 @@
 #*    *##if( $site.edit && $docRenderingContext.editable )
 #*      *##set( $editHref = $docRenderingContext.getDoxiaSourcePath( 
$site.edit ) )
 #*    *##end
-## a navbar row: below 992 px the menu's hamburger at the start, then the 
banners
+## a navbar row: below 992 px the button that hides and shows the menu at the 
start, then the banners
         <div id="banner" class="navbar flex-nowrap align-items-center 
column-gap-2 py-0 mb-2">
 #*    *##if( $sideBarEnabled )
-          <button type="button" class="navbar-toggler menu-toggle d-lg-none 
flex-shrink-0" data-bs-toggle="offcanvas" data-bs-target="#sidebarMenu" 
aria-controls="sidebarMenu" aria-label="Menu"><span 
class="navbar-toggler-icon"></span></button>
+## hidden until fluido.js shows it: without JavaScript the menu is simply open
+          <button type="button" class="navbar-toggler menu-toggle d-lg-none 
flex-shrink-0" aria-controls="sidebarMenu" aria-expanded="true" 
aria-label="Menu" hidden><span class="navbar-toggler-icon"></span></button>
 #*    *##end
           #banner( $site.bannerLeft "bannerLeft" "me-auto" )
           #banner( $site.bannerRight "bannerRight" $bannerRightClass )
@@ -242,8 +243,8 @@
       </header>
 ##
 #*    *##if( $sideBarEnabled )
-## the menu sits beside the content from 992 px up; below that the content 
gets the full width and the menu opens as
-## an offcanvas panel. Fluido 2's Bootstrap 2 grid classes (spanN) become the 
Bootstrap 5 columns of the same width
+## the menu sits beside the content from 992 px up and above it below that. 
Fluido 2's Bootstrap 2 grid classes
+## (spanN) become the Bootstrap 5 columns of the same width
 #*      *##set( $leftColumnClass = $site.getCustomValue( 
'fluidoSkin.leftColumnClass', 'col-lg-3 col-xl-2' ) )
 #*      *##set( $leftColumnClass = $leftColumnClass.replaceAll( 
'\bspan(\d+)\b', 'col-lg-$1' ) )
 #*      *##set( $bodyColumnClass = $site.getCustomValue( 
'fluidoSkin.bodyColumnClass', 'col-lg-9 col-xl-10' ) )
@@ -251,26 +252,12 @@
 ##
       <div class="row">
 #*    *##end
-## the page content comes before the menu in the source; from 992 px the menu 
goes to the left
-        <main id="bodyColumn"#if( $sideBarEnabled ) class="$bodyColumnClass 
order-lg-last"#end>
-#*      *##if( $convert.toBoolean( $site.getCustomValue( 
'fluidoSkin.sourceLineNumbersEnabled', 'false' ) ) )
-#*        *##set( $sourceStyle = "prettyprint linenums" )
-#*      *##else
-#*        *##set( $sourceStyle = "prettyprint" )
-#*      *##end
-## additive rewrites only: highlighting classes, Bootstrap table classes, and 
a focusable box for wide tables and
-## code blocks, so a keyboard can scroll them
-#*      *##if ( $bodyContent )$bodyContent.replaceAll( '<pre>(<code[ 
>](?!.*class=\"nohighlight nocode\"))', '<pre class="' + $sourceStyle + '">' + 
$esc.d + '1' ).replace( '<pre', '<pre tabindex="0"' ).replace( 
'class="bodyTable"', 'class="table table-striped"' ).replace( 'class="bodyTable 
bodyTableBorder"', 'class="table table-bordered table-striped"' ).replace( 
'<table', '<div class="table-wrap table-responsive" tabindex="0"><table' 
).replace( '</table>', '</table></div>' )#end
-        </main>
 #*    *##if( $sideBarEnabled )
-        <header id="leftColumn" class="$leftColumnClass order-lg-first">
-          <div class="offcanvas-lg offcanvas-start" tabindex="-1" 
id="sidebarMenu" aria-labelledby="sidebarMenuLabel">
-            <div class="offcanvas-header">
-              <p class="offcanvas-title h5 mb-0" id="sidebarMenuLabel">Menu</p>
-              <button type="button" class="btn-close" 
data-bs-dismiss="offcanvas" data-bs-target="#sidebarMenu" 
aria-label="Close"></button>
-            </div>
-            <div class="offcanvas-body flex-column">
-## the page tools at the top of the menu: beside the content on wide screens, 
in the panel on phones
+## the menu comes first: beside the content from 992 px up, above it on 
phones, where it is open until the reader hides
+## it with the button in the banner row (not remembered from page to page)
+        <header id="leftColumn" class="$leftColumnClass">
+          <div id="sidebarMenu" class="sidebar-menu mb-3">
+## the page tools at the top of the menu
           #pageTools( "mb-2 px-3" )
           <nav class="sidebar-nav border-end mb-3" aria-label="Menu">
 #*      *##publishDate( "navigation-top" $site.publishDate $site.version )
@@ -288,9 +275,20 @@
             </div>
           </div>
 #*      *##end
-            </div>
           </div>
         </header>
+#*    *##end
+        <main id="bodyColumn"#if( $sideBarEnabled ) 
class="$bodyColumnClass"#end>
+#*      *##if( $convert.toBoolean( $site.getCustomValue( 
'fluidoSkin.sourceLineNumbersEnabled', 'false' ) ) )
+#*        *##set( $sourceStyle = "prettyprint linenums" )
+#*      *##else
+#*        *##set( $sourceStyle = "prettyprint" )
+#*      *##end
+## additive rewrites only: highlighting classes, Bootstrap table classes, and 
a focusable box for wide tables and
+## code blocks, so a keyboard can scroll them
+#*      *##if ( $bodyContent )$bodyContent.replaceAll( '<pre>(<code[ 
>](?!.*class=\"nohighlight nocode\"))', '<pre class="' + $sourceStyle + '">' + 
$esc.d + '1' ).replace( '<pre', '<pre tabindex="0"' ).replace( 
'class="bodyTable"', 'class="table table-striped"' ).replace( 'class="bodyTable 
bodyTableBorder"', 'class="table table-bordered table-striped"' ).replace( 
'<table', '<div class="table-wrap table-responsive" tabindex="0"><table' 
).replace( '</table>', '</table></div>' )#end
+        </main>
+#*    *##if( $sideBarEnabled )
       </div>
 #*    *##end
     </div>
diff --git a/src/main/resources/css/maven-base.css 
b/src/main/resources/css/maven-base.css
index c0824e2..916c11a 100644
--- a/src/main/resources/css/maven-base.css
+++ b/src/main/resources/css/maven-base.css
@@ -41,10 +41,11 @@
   content: " \203A";
 }
 
-/* the phone menu panel scrolls on its own by touch, and a scroll at its end 
does not move the page behind it */
-#sidebarMenu .offcanvas-body {
-  -webkit-overflow-scrolling: touch;
-  overscroll-behavior: contain;
+/* below 992 px the menu sits above the content, open; the menu button hides 
it until the next page */
+@media (max-width: 991.98px) {
+  #sidebarMenu.menu-hidden {
+    display: none;
+  }
 }
 
 /* parameter tables: fluido.js moved the type and since version under the name 
*/
diff --git a/src/main/resources/js/fluido.js b/src/main/resources/js/fluido.js
index 7c48e98..61cb9e1 100644
--- a/src/main/resources/js/fluido.js
+++ b/src/main/resources/js/fluido.js
@@ -17,7 +17,8 @@
  * under the License.
  */
 
-/* Plain DOM code, ES5: highlighting and labels for the stacked tables. Menus 
are Bootstrap's own components. */
+/* Plain DOM code, ES5: the phone menu button, highlighting and labels for the 
stacked tables. The top bar's menus are
+   Bootstrap's own components. */
 ( function() {
 
     function each( list, fn ) {
@@ -87,7 +88,29 @@
         }
     }
 
+    // below 992 px the side menu is open above the content; the button in the 
banner row hides and shows it. Without
+    // JavaScript the button stays hidden and the menu open. Nothing is 
stored: every page starts with the menu open.
+    function menuToggle() {
+        var button = document.querySelector( '.menu-toggle' );
+        var menu = document.getElementById( 'sidebarMenu' );
+        if ( !button || !menu ) {
+            return;
+        }
+        button.hidden = false;
+        button.addEventListener( 'click', function() {
+            var open = button.getAttribute( 'aria-expanded' ) !== 'false';
+            button.setAttribute( 'aria-expanded', open ? 'false' : 'true' );
+            if ( open ) {
+                addClass( menu, 'menu-hidden' );
+            } else {
+                menu.className = trim( menu.className.replace( 
/(^|\s)menu-hidden(\s|$)/g, ' ' ) );
+            }
+        } );
+    }
+
     function init() {
+        menuToggle();
+
         // highlight the code blocks that site.vm marked; line numbers where 
sourceLineNumbersEnabled added linenums
         if ( window.hljs ) {
             each( document.querySelectorAll( 'pre.prettyprint > code' ), 
function( code ) {

Reply via email to