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 87d2c55  Keep pages from scrolling sideways on narrow screens
87d2c55 is described below

commit 87d2c55877301d9c2d71abe1184e462a089b4cce
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Nov 1 22:11:22 2026 +0000

    Keep pages from scrolling sideways on narrow screens
    
    Below 768 px each table row becomes a card with one cell per line,
    labelled with its column heading by fluido.js (without JavaScript the
    heading row stays as a legend). Wider tables scroll in a
    keyboard-focusable wrapper, and long inline code and URLs wrap. Code
    blocks keep white-space: the inline-code rule must not match pre > code.
---
 src/main/resources/META-INF/maven/site.vm |  2 +-
 src/main/resources/css/maven-base.css     | 48 +++++++++++++++++++++++++++++++
 src/main/resources/js/fluido.js           | 18 ++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/src/main/resources/META-INF/maven/site.vm 
b/src/main/resources/META-INF/maven/site.vm
index 393777c..b410b9b 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -227,7 +227,7 @@
 #*        *##set( $sourceStyle = "prettyprint" )
 #*      *##end
 ##
-#*      *##if ( $bodyContent )$bodyContent.replaceAll( '<pre>(<code[ 
>](?!.*class=\"nohighlight nocode\"))', '<pre class="' + $sourceStyle + '">' + 
$esc.d + '1' ).replace( 'class="bodyTable"', 'class="table table-striped"' 
).replace( 'class="bodyTable bodyTableBorder"', 'class="table table-bordered 
table-striped"' )#end
+#*      *##if ( $bodyContent )$bodyContent.replaceAll( '<pre>(<code[ 
>](?!.*class=\"nohighlight nocode\"))', '<pre class="' + $sourceStyle + '">' + 
$esc.d + '1' ).replace( 'class="bodyTable"', 'class="table table-striped"' 
).replace( 'class="bodyTable bodyTableBorder"', 'class="table table-bordered 
table-striped"' ).replace( '<table', '<div class="table-wrap" 
tabindex="0"><table' ).replace( '</table>', '</table></div>' )#end
         </main>
 #*    *##if( $sideBarEnabled )
         <header id="leftColumn" class="$leftColumnClass">
diff --git a/src/main/resources/css/maven-base.css 
b/src/main/resources/css/maven-base.css
index faeae79..b4a61df 100644
--- a/src/main/resources/css/maven-base.css
+++ b/src/main/resources/css/maven-base.css
@@ -30,6 +30,7 @@ section > p,
 section > dt,
 section > dl,
 section > table.table,
+section > .table-wrap,
 section > pre {
   margin-right: 7px;
   margin-left: 7px;
@@ -49,3 +50,50 @@ section > pre {
     margin-left: 0;
   }
 }
+
+/* a wide table scrolls in its own box, reachable by keyboard (site.vm adds 
tabindex), instead of widening the page */
+.table-wrap {
+  overflow-x: auto;
+}
+
+@media (max-width: 767px) {
+  /* long identifiers, paths and URLs wrap instead of pushing the page 
sideways */
+  #bodyColumn {
+    word-wrap: break-word;
+    overflow-wrap: break-word;
+  }
+  /* inline code only: a code block keeps its line breaks and indentation */
+  #bodyColumn :not(pre) > code {
+    white-space: normal;
+  }
+  /* each table row becomes a card with one cell per line; fluido.js labels 
the cells with their column heading
+     and hides the heading row, which stays visible as a legend without 
JavaScript */
+  .table-wrap > table,
+  .table-wrap > table > thead,
+  .table-wrap > table > tbody,
+  .table-wrap > table > * > tr,
+  .table-wrap > table > * > tr > th,
+  .table-wrap > table > * > tr > td {
+    display: block;
+    width: auto;
+  }
+  .table-wrap > table > * > tr {
+    padding: 4px 0;
+    border-top: 1px solid #ddd;
+  }
+  .table-wrap > table > * > tr > th,
+  .table-wrap > table > * > tr > td {
+    padding: 2px 8px;
+    border-top: 0;
+  }
+  .table-wrap > table > * > tr.table-head {
+    display: none;
+  }
+  .table-wrap td[data-label]:before {
+    content: attr(data-label);
+    display: block;
+    font-size: 12px;
+    font-weight: bold;
+    color: #555;
+  }
+}
diff --git a/src/main/resources/js/fluido.js b/src/main/resources/js/fluido.js
index 3b35fad..d1d89b1 100644
--- a/src/main/resources/js/fluido.js
+++ b/src/main/resources/js/fluido.js
@@ -37,6 +37,24 @@ jQuery( document ).ready( function()
         } );
     }
 
+    // label each cell with its column heading, for the stacked tables on 
narrow screens (maven-base.css);
+    // only tables whose first row is a plain heading row, and only rows with 
one cell per heading
+    $( '.table-wrap > table' ).each( function() {
+        var rows = $( this ).find( '> thead > tr, > tbody > tr' );
+        var head = rows.first();
+        if ( head.children( 'td' ).length || !head.children( 'th' ).length || 
head.children( '[rowspan], [colspan]' ).length ) {
+            return;
+        }
+        var labels = head.children( 'th' ).map( function() { return $.trim( $( 
this ).text() ); } ).get();
+        head.addClass( 'table-head' );
+        rows.slice( 1 ).each( function() {
+            var cells = $( this ).children();
+            if ( cells.length === labels.length ) {
+                cells.each( function( i ) { $( this ).attr( 'data-label', 
labels[ i ] ); } );
+            }
+        } );
+    } );
+
 } );
 
 function asyncJs( url ) {

Reply via email to