From: Luna Date: Fri, 28 May 2021 15:33:11 +0000 (-0400) Subject: Replace jekyll-tabs plugin with custom code X-Git-Url: https://git.arvados.org/rnaseq-cwl-training.git/commitdiff_plain/fe18c05b5fc565ce4a82370d1df110b62655e72f Replace jekyll-tabs plugin with custom code --- diff --git a/_config.yml b/_config.yml index dd76912..9fc41fc 100644 --- a/_config.yml +++ b/_config.yml @@ -99,6 +99,3 @@ exclude: # Turn on built-in syntax highlighting. highlighter: rouge - -plugins: - - jekyll-tabs diff --git a/_episodes/03-running.md b/_episodes/03-running.md index 47f7aab..b7c6bb4 100644 --- a/_episodes/03-running.md +++ b/_episodes/03-running.md @@ -31,10 +31,8 @@ plain strings that may or may not be file paths. Note: if you don't have example sequence data or the STAR index files, see [setup](/setup.html). -
-{% tabs input %} - -{% tab input generic %} +{% assign tabs = "generic, arvados" | split: ", " %} +{% capture generic_tab_content %} main-input.yaml ``` fq: @@ -63,10 +61,9 @@ gtf: > logging. The logging you see, how access other logs, and how to > track workflow progress will depend on your CWL runner platform. {: .challenge } +{% endcapture %} -{% endtab %} - -{% tab input arvados %} +{% capture arvados_tab_content %} main-input.yaml ``` fq: @@ -88,8 +85,17 @@ gtf: > then use the `Run CWL Workflow on Arvados` task. > {: .challenge } -{% endtab %} -{% endtabs %} +{% endcapture %} + +
+
    + {% for tab in tabs %} +
  • {{ tab }}
  • + {% endfor %} +
+ +
{{ generic_tab_content | markdownify}}
+
{{ arvados_tab_content | markdownify}}
# Debugging the workflow @@ -228,3 +234,83 @@ The CWL runner will print a results JSON object to standard output. It will loo This has a similar structure as `main-input.yaml`. The each output parameter is listed, with the `location` field of each `File` object indicating where the output file can be found. + + diff --git a/assets/css/tabs.css b/assets/css/tabs.css index e9d72f2..38b0cf3 100644 --- a/assets/css/tabs.css +++ b/assets/css/tabs.css @@ -26,14 +26,27 @@ line-height: 20px; } -.tab > .active > a { +.tab > li { + transition: color .1s ease-in-out; +} + +.tab > li > .active { color:#222; border-color: #1e87f0; } .tab li a { text-decoration: none; - cursor: pointer; + cursor: pointer; +} + +.tab > li > a:focus { + outline: 0; +} + +.tab > li > .active:focus-visible { + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; } .tab-content{ diff --git a/assets/js/tabs.js b/assets/js/tabs.js index 0148f32..0e5b795 100644 --- a/assets/js/tabs.js +++ b/assets/js/tabs.js @@ -1,43 +1,77 @@ -const removeActiveClasses = function (ulElement) { - const lis = ulElement.querySelectorAll('li'); - Array.prototype.forEach.call(lis, function(li) { - li.classList.remove('active'); - }); - } +window.addEventListener('load', function() { + // Get relevant elements and collections + const tabbed = document.querySelector('.tabbed'); + const tablist = tabbed.querySelector('ul'); + const tabs = tablist.querySelectorAll('a'); + const panels = tabbed.querySelectorAll('[id^="section"]'); - const getChildPosition = function (element) { - var parent = element.parentNode; - var i = 0; - for (var i = 0; i < parent.children.length; i++) { - if (parent.children[i] === element) { - return i; - } - } + // The tab switching function + const switchTab = (oldTab, newTab) => { + newTab.focus(); + // Make the active tab focusable by the user (Tab key) + newTab.removeAttribute('tabindex'); + // Set the selected state + newTab.setAttribute('aria-selected', 'true'); + newTab.classList.add('active'); + oldTab.removeAttribute('aria-selected'); + oldTab.setAttribute('tabindex', '-1'); + oldTab.classList.remove('active'); + // Get the indices of the new and old tabs to find the correct + // tab panels to show and hide + let index = Array.prototype.indexOf.call(tabs, newTab); + let oldIndex = Array.prototype.indexOf.call(tabs, oldTab); + panels[oldIndex].hidden = true; + panels[index].hidden = false; + } - throw new Error('No parent found'); - } + // Add the tablist role to the first