-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESY-6582 Updated tab component to accept a list of tabs
- Loading branch information
Showing
2 changed files
with
56 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
<div class="tabs" id="tabs-showcase-example"> | ||
{%- comment -%} | ||
**Parameters | ||
tab_list(required): An array with items having the attributes title(required), content (required) | ||
{%- endcomment -%} | ||
|
||
{% assign tabs = include.tab_list %} | ||
|
||
<div class="m-5 "> | ||
{{tabs}} | ||
</div> | ||
<div id="tabs-container" class="tabs"> | ||
<ul> | ||
<li class="full-checkout"> | ||
<a href="#full-checkout" id="full-checkout">Full Checkout</a> | ||
</li> | ||
<li class="payments-only"> | ||
<a href="#payments-only" id="payments-only">Payments Only</a> | ||
{% for tab in tabs %} | ||
<li class="tab-title {% if forloop.first %}active{% endif %}"> | ||
<a id="tab-title-{{ forloop.index }}">{{ tab.title }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
|
||
<section> | ||
<div id="tab1"> | ||
<div class="tab-intro"> | ||
{{ include.tab1_intro | markdownify}} | ||
</div> | ||
<div class="tab1-content"> | ||
{{ include.tab1_content | markdownify}} | ||
</div> | ||
</div> | ||
<div id="tab2" class="d-none"> | ||
<div class="tab-intro"> | ||
{{ include.tab2_intro | markdownify}} | ||
</div> | ||
<div> | ||
{{ include.tab2_content | markdownify}} | ||
</div> | ||
</div> | ||
</section> | ||
{% for tab in tabs %} | ||
<p id="tab-content-{{ forloop.index }}" class="tab-content {% unless forloop.first %}d-none{% endunless %}"> | ||
{{ tab.content }} | ||
</p> | ||
{% endfor %} | ||
|
||
<script> | ||
$( "#full-checkout" ).click(function() { | ||
$( "#tab2" ).addClass( "d-none" ) | ||
$( "#tab1" ).removeClass( "d-none" ) | ||
$( ".full-checkout" ).addClass( "active" ) | ||
$( ".payments-only" ).removeClass( "active" ) | ||
$("#tabs-container ul li a").click(function () { | ||
let tabs = $(".tab-title"); | ||
for (let index = 0; index < tabs.length; index++) { | ||
const tab = tabs[index]; | ||
tab.classList.remove("active"); | ||
} | ||
|
||
$(this).parent().addClass("active"); | ||
var tabContentId = $(this).attr("id").replace("tab-title-", "tab-content-"); | ||
|
||
let tabContents = $(".tab-content"); | ||
for (let index = 0; index < tabContents.length; index++) { | ||
const tabContent = tabContents[index]; | ||
|
||
}); | ||
$( "#payments-only" ).click(function() { | ||
$( "#tab2" ).removeClass( "d-none" ) | ||
$( "#tab1" ).addClass( "d-none" ) | ||
$( ".full-checkout" ).removeClass( "active" ) | ||
$( ".payments-only" ).addClass( "active" ) | ||
}); | ||
</script> | ||
switch (tabContent.id) { | ||
case tabContentId: | ||
tabContent.classList.remove("d-none"); | ||
break; | ||
default: | ||
if (!tabContent.classList.contains("d-none")) | ||
tabContent.classList.add("d-none"); | ||
break; | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters