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
The following commit(s) were added to refs/heads/master by this push:
new abab456 Collapse the side menu on phones and link to it from the top
abab456 is described below
commit abab4561ea6c2a09e92849271dc71db47928da4f
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Nov 2 16:17:26 2026 +0000
Collapse the side menu on phones and link to it from the top
The menu follows the content on phones, so it starts collapsed there behind
a Menu summary, and a link at the top of the page leads to it. Without
JavaScript the menu stays open.
---
src/it/mskins-13/verify.groovy | 5 ++++-
src/it/sidebar/verify.groovy | 5 +++++
src/it/topbar/verify.groovy | 4 ++++
src/main/resources/META-INF/maven/site.vm | 8 ++++++++
src/main/resources/css/maven-base.css | 17 +++++++++++++++++
src/main/resources/js/fluido.js | 15 +++++++++++++++
6 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/src/it/mskins-13/verify.groovy b/src/it/mskins-13/verify.groovy
index 12d809e..1883f1d 100644
--- a/src/it/mskins-13/verify.groovy
+++ b/src/it/mskins-13/verify.groovy
@@ -19,4 +19,7 @@
File index = new File( basedir, "target/site/index.html" )
assert index.exists()
-assert !index.text.contains( 'Generated by Apache Maven Doxia at' )
\ No newline at end of file
+assert !index.text.contains( 'Generated by Apache Maven Doxia at' )
+// no side menu, so nothing to collapse or jump to
+assert !index.text.contains( 'sidebar-menu' )
+assert !index.text.contains( 'menu-jump' )
diff --git a/src/it/sidebar/verify.groovy b/src/it/sidebar/verify.groovy
index 6571a7c..3aa7b0f 100644
--- a/src/it/sidebar/verify.groovy
+++ b/src/it/sidebar/verify.groovy
@@ -33,3 +33,8 @@ assert html.contains( '<li><a
href="https://www.apache.org/">Apache</a><span cla
// MSKINS-263 - image without class in banner
assert html.contains('<div class="pull-left"><div id="bannerLeft"><h1><a
href="../../../"><img
src="../../../images/apache-maven-project-light-theme.svg" alt="Apache Maven
Fluido Skin IT, sidebar layout" style="width: 489px;height: 83px;"
/></a></h1></div></div>')
assert html.contains('<div class="pull-right"><div id="bannerRight"><div
class="banner-decoration"><img src="../../../images/logos/MavenLogoLeaf.svg"
alt="" style="width: 340px;height: 83px;" /></div></div></div>')
+
+// the side menu collapses on phones: open by default, with a link at the top
that leads to it
+assert html.contains( '<details class="sidebar-menu" open>' )
+assert html.contains( '<summary>Menu</summary>' )
+assert html.contains( '<p class="menu-jump"><a
href="#leftColumn">Menu</a></p>' )
diff --git a/src/it/topbar/verify.groovy b/src/it/topbar/verify.groovy
index cc0a7ca..2774e66 100644
--- a/src/it/topbar/verify.groovy
+++ b/src/it/topbar/verify.groovy
@@ -38,3 +38,7 @@ assert html.contains('<div class="pull-right"><div
id="bannerRight"><div class="
assert html =~ /<a href="[^"]+"><img src="\.\/images\/edit\.svg" alt="Edit"
width="14" height="14" \/><\/a><\/li>/
assert new File( basedir, "target/site/images/edit.svg" ).exists()
assert !new File( basedir, "target/site/images/accessories-text-editor.png"
).exists()
+
+// no side menu, so nothing to collapse or jump to
+assert !html.contains( 'sidebar-menu' )
+assert !html.contains( 'menu-jump' )
diff --git a/src/main/resources/META-INF/maven/site.vm
b/src/main/resources/META-INF/maven/site.vm
index b410b9b..a27d6c1 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -208,6 +208,10 @@
#* *#$!linksContent##
</ul>
</div>
+#* *##end
+#* *##if( $sideBarEnabled )
+## on phones the menu comes after the content, so this link at the top leads
to it (maven-base.css shows it there only)
+ <p class="menu-jump"><a href="#leftColumn">Menu</a></p>
#* *##end
</header>
##
@@ -232,9 +236,13 @@
#* *##if( $sideBarEnabled )
<header id="leftColumn" class="$leftColumnClass">
<nav class="well sidebar-nav">
+## open by default, so the menu stays usable without JavaScript; fluido.js
collapses it on phones
+ <details class="sidebar-menu" open>
+ <summary>Menu</summary>
#* *##publishDate( "navigation-top" $site.publishDate $site.version )
#* *##mainMenu( $site.body.menus )
#* *##publishDate( "navigation-bottom" $site.publishDate $site.version )
+ </details>
</nav>
## no empty box when nothing is configured for it
#* *##if( $searchEnabled || ( $site.poweredBy &&
!$site.poweredBy.isEmpty() ) )
diff --git a/src/main/resources/css/maven-base.css
b/src/main/resources/css/maven-base.css
index b4a61df..6aa76c7 100644
--- a/src/main/resources/css/maven-base.css
+++ b/src/main/resources/css/maven-base.css
@@ -56,7 +56,24 @@ section > pre {
overflow-x: auto;
}
+/* the side menu collapses on phones only: its summary, and the link that
leads to it, show there alone */
+.sidebar-menu > summary,
+.menu-jump {
+ display: none;
+}
+
@media (max-width: 767px) {
+ .sidebar-menu > summary {
+ display: list-item;
+ cursor: pointer;
+ font-weight: bold;
+ padding: 3px 15px;
+ }
+ .menu-jump {
+ display: block;
+ margin: 0 0 10px;
+ text-align: right;
+ }
/* long identifiers, paths and URLs wrap instead of pushing the page
sideways */
#bodyColumn {
word-wrap: break-word;
diff --git a/src/main/resources/js/fluido.js b/src/main/resources/js/fluido.js
index d1d89b1..3f6e4b6 100644
--- a/src/main/resources/js/fluido.js
+++ b/src/main/resources/js/fluido.js
@@ -55,6 +55,21 @@ jQuery( document ).ready( function()
} );
} );
+ // the side menu starts collapsed on phones, where maven-base.css shows
the summary that opens it, and is
+ // opened again on wider screens, where the summary is hidden; the link at
the top of the page opens it too
+ var menu = $( 'details.sidebar-menu' );
+ var phone = window.matchMedia ? window.matchMedia( '(max-width: 767px)' )
: null;
+ if ( menu.length && phone ) {
+ var collapseOnPhone = function() { menu.prop( 'open', !phone.matches
); };
+ collapseOnPhone();
+ if ( phone.addEventListener ) {
+ phone.addEventListener( 'change', collapseOnPhone );
+ } else if ( phone.addListener ) {
+ phone.addListener( collapseOnPhone );
+ }
+ }
+ $( '.menu-jump a' ).on( 'click', function() { menu.prop( 'open', true ); }
);
+
} );
function asyncJs( url ) {