From 477d6268e603a0f6c8123211b1c3cccbc478014a Mon Sep 17 00:00:00 2001 From: Tom Schraitle Date: Wed, 21 Aug 2024 13:29:44 +0200 Subject: [PATCH] Convert variablelist into a HTML tab structure (#611) If you want to turn your variablelist into tabs, use one of the following methods: * With a role attribute: * With a processing instruction: --------- Co-authored-by: Gayathri Gandaboyina --- .../sass/custom/content-formal-informal.sass | 32 +++++ suse2022-ns/static/css/style-new.css | 27 ++++ suse2022-ns/static/css/style.css | 27 ++++ suse2022-ns/static/js/script-purejs.js | 26 ++++ suse2022-ns/static/js/script.js | 26 ++++ suse2022-ns/xhtml/lists.xsl | 128 ++++++------------ 6 files changed, 183 insertions(+), 83 deletions(-) diff --git a/source-assets/styles2022/sass/custom/content-formal-informal.sass b/source-assets/styles2022/sass/custom/content-formal-informal.sass index dffbfb9a..75112ed3 100644 --- a/source-assets/styles2022/sass/custom/content-formal-informal.sass +++ b/source-assets/styles2022/sass/custom/content-formal-informal.sass @@ -349,3 +349,35 @@ li > p div.blockquote margin: 17px 35px + +// CSS for Tab structure +.tab-structure + display: flex + border: 1px solid #30ba78 + flex-direction: column + margin-top: 32px + margin-bottom: 32px + + .tabs + display: flex + overflow-x: auto + padding: 0 + margin: 0 + + .tab + cursor: pointer + list-style: none + padding-top: 8px + padding-bottom: 8px + padding-left: 16px + padding-right: 16px + + .tab.active-tab + border-bottom: 3px solid #30ba78 + color: #0c322c + font-size: bold + + .content-container + background-color: rgb(246, 248, 250) + padding: 8px + overflow-x: auto diff --git a/suse2022-ns/static/css/style-new.css b/suse2022-ns/static/css/style-new.css index 5a60222d..0dcca200 100644 --- a/suse2022-ns/static/css/style-new.css +++ b/suse2022-ns/static/css/style-new.css @@ -2775,6 +2775,33 @@ li > p { div.blockquote { margin: 17px 35px; } +.tab-structure { + display: flex; + border: 1px solid #30ba78; + flex-direction: column; + margin-top: 32px; + margin-bottom: 32px; } + .tab-structure .tabs { + display: flex; + overflow-x: auto; + padding: 0; + margin: 0; } + .tab-structure .tabs .tab { + cursor: pointer; + list-style: none; + padding-top: 8px; + padding-bottom: 8px; + padding-left: 16px; + padding-right: 16px; } + .tab-structure .tabs .tab.active-tab { + border-bottom: 3px solid #30ba78; + color: #0c322c; + font-size: bold; } + .tab-structure .content-container { + background-color: #f6f8fa; + padding: 8px; + overflow-x: auto; } + .qandadiv { margin: 0 0 40px 0; } diff --git a/suse2022-ns/static/css/style.css b/suse2022-ns/static/css/style.css index 09bde999..f96ec8d6 100644 --- a/suse2022-ns/static/css/style.css +++ b/suse2022-ns/static/css/style.css @@ -3029,6 +3029,33 @@ li > p { div.blockquote { margin: 17px 35px; } +.tab-structure { + display: flex; + border: 1px solid #30ba78; + flex-direction: column; + margin-top: 32px; + margin-bottom: 32px; } + .tab-structure .tabs { + display: flex; + overflow-x: auto; + padding: 0; + margin: 0; } + .tab-structure .tabs .tab { + cursor: pointer; + list-style: none; + padding-top: 8px; + padding-bottom: 8px; + padding-left: 16px; + padding-right: 16px; } + .tab-structure .tabs .tab.active-tab { + border-bottom: 3px solid #30ba78; + color: #0c322c; + font-size: bold; } + .tab-structure .content-container { + background-color: #f6f8fa; + padding: 8px; + overflow-x: auto; } + .qandadiv { margin: 0 0 40px 0; } diff --git a/suse2022-ns/static/js/script-purejs.js b/suse2022-ns/static/js/script-purejs.js index 9a01ef17..ffd1be27 100644 --- a/suse2022-ns/static/js/script-purejs.js +++ b/suse2022-ns/static/js/script-purejs.js @@ -676,3 +676,29 @@ function addBugLinks() { return true; }); } + +function showTabContent(event) { + var tab = event.target.closest('.tab') + if (tab) { + var tabs = tab.parentElement; + + // Get the index of the clicked tab + var index = Array.from(tabs.children).indexOf(tab); + + // Hide all tab contents + Array.from(tabs.nextElementSibling.children).forEach(content => { + content.style.display = 'none'; + }); + + // Remove "active" class from all tabs + tabs.querySelectorAll('.tab').forEach(tab => { + tab.classList.remove('active-tab'); + }); + + // Display the selected tab content + tabs.nextElementSibling.children[index].style.display = 'block'; + + // Add "active" class to the clicked tab + tab.classList.add('active-tab'); + } +} diff --git a/suse2022-ns/static/js/script.js b/suse2022-ns/static/js/script.js index b90a5212..699591ed 100644 --- a/suse2022-ns/static/js/script.js +++ b/suse2022-ns/static/js/script.js @@ -585,3 +585,29 @@ function addBugLinks() { }); } + +function showTabContent(event) { + var tab = event.target.closest('.tab') + if (tab) { + var tabs = tab.parentElement; + + // Get the index of the clicked tab + var index = Array.from(tabs.children).indexOf(tab); + + // Hide all tab contents + Array.from(tabs.nextElementSibling.children).forEach(content => { + content.style.display = 'none'; + }); + + // Remove "active" class from all tabs + tabs.querySelectorAll('.tab').forEach(tab => { + tab.classList.remove('active-tab'); + }); + + // Display the selected tab content + tabs.nextElementSibling.children[index].style.display = 'block'; + + // Add "active" class to the clicked tab + tab.classList.add('active-tab'); + } +} diff --git a/suse2022-ns/xhtml/lists.xsl b/suse2022-ns/xhtml/lists.xsl index 2bc0a889..92dda945 100644 --- a/suse2022-ns/xhtml/lists.xsl +++ b/suse2022-ns/xhtml/lists.xsl @@ -18,7 +18,7 @@ xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="exsl d"> - + @@ -31,105 +31,67 @@ - + table - + list - - - - compact - - - - tabs - - - - - - - - - - - - - - -
- + + tab-structure + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - -
-
-
+
    + +
+
+ +
+ +
  • + + + tab active-tab + tab + + + +
  • +
    + + +
    + + + display: none; + + + + +
    +
    + + + + + +