diff --git a/docs/extra.css b/docs/extra.css index e7d035aea..ab62371e1 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -89,3 +89,59 @@ h1, h2, h3, h4, h5, h6 { /* import font awesome 4 for icons */ @import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css); + + +/* Tabs */ + +/* Style the tab */ +.tabs { + margin-bottom: 1em; + -webkit-font-smoothing: antialiased; +} + +.tabs-header { + background-color: white; + display: flex; + justify-content: flex-start; + border-bottom: 2px solid #ccc; +} + +/* Style the buttons that are used to open the tab content */ +.tabs-header button { + background-color: transparent; + border: none; + outline: none; + cursor: pointer; + color: inherit; + font: inherit; + font-size: 0.9em; + font-weight: 600; + padding: 8px 16px; + border-bottom: 2px solid transparent; + + /* put the border on top of the parent border */ + margin-bottom: -2px; +} + +.tabs-header button:focus-visible { + /* preserve an outline for accesibility purposes */ + outline: 1px solid currentColor; +} + +/* Change background color of buttons on hover */ +.tabs-header button:hover { + background-color: rgba(0, 0, 0, 0.02); +} + +/* Create an active/current tablink class */ +.tabs-header button.active { + color: #4086bd; + border-bottom-color: currentColor; +} + +/* Style the tab content */ +.tabs-content { + background-color: #f1f6fa; + padding: 1px 1em; + padding-top: 0.8em; +} diff --git a/docs/extra.js b/docs/extra.js index 1965a84e9..9ef194fa4 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -1,4 +1,49 @@ - +// add classes for code-block-filename styling $('.rst-content pre') .prev('blockquote') .addClass('code-block-filename'); + +var tabConversionIterations = 0 + +// convert tab admonition to tabs +while (true) { + const firstTab = $('.rst-content .admonition.tab').first() + if (firstTab.length == 0) break; + + const otherTabs = firstTab.nextUntil(':not(.admonition.tab)'); + const allTabs = $($.merge($.merge([], firstTab), otherTabs)); + + const tabContainer = $('
').addClass('tabs'); + const headerContainer = $('
').addClass('tabs-header'); + const contentContainer = $('
').addClass('tabs-content'); + + tabContainer.insertBefore(firstTab); + tabContainer.append(headerContainer, contentContainer) + + const selectTab = function (index) { + headerContainer.children().removeClass('active') + headerContainer.children().eq(index).addClass('active') + contentContainer.children().hide() + contentContainer.children().eq(index).show() + } + + allTabs.each(function (tabI, el) { + const $el = $(el) + const titleElement = $el.children('.admonition-title') + const title = titleElement.text() + const button = $('