feat: Add sticky table-column 34/73434/1 master
authorVanessa Valderrama <vvalderrama@linuxfoundation.org>
Thu, 20 Mar 2025 17:19:17 +0000 (12:19 -0500)
committerVanessa Valderrama <vvalderrama@linuxfoundation.org>
Thu, 20 Mar 2025 17:19:17 +0000 (12:19 -0500)
This commit introduces a feature to add a sticky first column
to tables generated from the list-table directive in Sphinx.

The first column now remains fixed during horizontal
scrolling, enhancing the user experience and improving
readability, especially for long tables such as the one in
infra/inventory.rst.

The implementation uses CSS with `position: sticky`. The
CSS is added to _static/css/sticky-table-column.css and
included in the Sphinx build via conf.py.

Change-Id: Ie68a3524bc34c38149e85c86ed4ea0d8a5f09ffe
Signed-off-by: Vanessa Valderrama <vvalderrama@linuxfoundation.org>
docs/_static/css/sticky-table-column.css [new file with mode: 0644]
docs/conf.py

diff --git a/docs/_static/css/sticky-table-column.css b/docs/_static/css/sticky-table-column.css
new file mode 100644 (file)
index 0000000..0304371
--- /dev/null
@@ -0,0 +1,13 @@
+.rst-content .list-table table td:nth-child(1) {
+  position: sticky;
+  left: 0;
+  background-color: white;
+  z-index: 1;
+}
+
+.rst-content .list-table table th:nth-child(1) {
+  position: sticky;
+  left: 0;
+  background-color: white;
+  z-index: 2;
+}
index 1070d7f..c68a23b 100644 (file)
@@ -48,3 +48,4 @@ sphinx_tabs_valid_builders = ["linkcheck"]
 def setup(app):
     """Injects the report issue ribbon."""
     app.add_css_file("css/ribbon.css")
+    app.add_css_file("css/sticky-table-column.css")