Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ enhancement(side-navigation): component markup revamp #415

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions assets/js/showcase/globals/side-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,23 @@
dataBox = wrapper.find( 'div[data-tab="' + dataNav + '"]' )
;

parent.find( 'li a' ).attr({
'tabindex': '-1',
'aria-selected': 'false',
'active': 'false'
});
parent.find( 'li' ).removeClass( 'current' );
button.parent().addClass( 'current' );
button.attr({
'tabindex': '0',
'aria-selected': 'true',
'active': 'true'
});
button.focus();

content.attr({ 'aria-hidden': 'true' });
content.hide();
dataBox.attr({ 'aria-hidden': 'false' });
dataBox.show();

}
Expand All @@ -42,6 +55,22 @@
e.stopPropagation();

});

// change content tab on arrow click
$( '.sui-vertical-tabs' ).on( 'keydown', 'a', function( e ) {
var prev = $( this ).parent().prev().find( 'a' );
var next = $( this ).parent().next().find( 'a' );
if ( 37 === e.keyCode || 38 === e.keyCode ) {
if ( prev.length ) {
prev.trigger( 'click' );
}
} else if ( 39 === e.keyCode || 40 === e.keyCode ) {
if ( next.length ) {
next.trigger( 'click' );
}
}
e.preventDefault();
});
}

init();
Expand Down
24 changes: 12 additions & 12 deletions page-sidenav.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
<ul class="sui-vertical-tabs sui-sidenav-hide-md">

<li class="sui-vertical-tab current">
<a href="#" role="button" data-tab="section-1">Section 1</a>
<a href="#" role="button" aria-selected="true" tabindex="0" data-tab="section-1">Section 1</a>
</li>

<li class="sui-vertical-tab">
<a href="#" role="button" data-tab="section-2">Section 2</a>
<a href="#" role="button" aria-selected="false" tabindex="-1" data-tab="section-2">Section 2</a>
<span class="sui-tag sui-tag-warning">4</span>
</li>

<li class="sui-vertical-tab">
<a href="#" role="button" data-tab="section-3">Section 3</a>
<a href="#" role="button" aria-selected="false" tabindex="-1" data-tab="section-3">Section 3</a>
<span class="sui-icon-check-tick" aria-hidden="true"></span>
</li>

Expand Down Expand Up @@ -53,7 +53,7 @@
</div>

<!-- SECTION: 1 -->
<div class="sui-box" data-tab="section-1">
<div class="sui-box" tabindex="0" aria-hidden="false" data-tab="section-1">

<div class="sui-box-header">
<h1 class="sui-box-title">Section 1</h1>
Expand All @@ -68,7 +68,7 @@ <h1 class="sui-box-title">Section 1</h1>
</div>

<!-- SECTION: 2 -->
<div class="sui-box" data-tab="section-2" style="display: none;">
<div class="sui-box" tabindex="0" aria-hidden="true" data-tab="section-2" style="display: none;">

<div class="sui-box-header">
<h1 class="sui-box-title">Section 2</h1>
Expand All @@ -83,7 +83,7 @@ <h1 class="sui-box-title">Section 2</h1>
</div>

<!-- SECTION: 3 -->
<div class="sui-box" data-tab="section-3" style="display: none;">
<div class="sui-box" tabindex="0" aria-hidden="true" data-tab="section-3" style="display: none;">

<div class="sui-box-header">
<h1 class="sui-box-title">Section 3</h1>
Expand All @@ -110,16 +110,16 @@ <h1 class="sui-box-title">Section 3</h1>
&lt;ul class=&quot;sui-vertical-tabs sui-sidenav-hide-md&quot;&gt;

&lt;li class=&quot;sui-vertical-tab current&quot;&gt;
&lt;a href=&quot;#&quot; role=&quot;button&quot;&gt;Tab 1&lt;/a&gt;
&lt;a href=&quot;#&quot; aria-selected=&quot;true&quot; tabindex=&quot;0&quot; role=&quot;button&quot;&gt;Tab 1&lt;/a&gt;
&lt;/li&gt;

&lt;li class=&quot;sui-vertical-tab&quot;&gt;
&lt;a href=&quot;#&quot; role=&quot;button&quot;&gt;Tab 2&lt;/a&gt;
&lt;a href=&quot;#&quot; aria-selected=&quot;false&quot; tabindex=&quot;-1&quot; role=&quot;button&quot;&gt;Tab 2&lt;/a&gt;
&lt;span class=&quot;sui-tag sui-tag-warning&quot;&gt;4&lt;/span&gt;
&lt;/li&gt;

&lt;li class=&quot;sui-vertical-tab&quot;&gt;
&lt;a href=&quot;#&quot; role=&quot;button&quot;&gt;Tab 3&lt;/a&gt;
&lt;a href=&quot;#&quot; aria-selected=&quot;false&quot; tabindex=&quot;-1&quot; role=&quot;button&quot;&gt;Tab 3&lt;/a&gt;
&lt;span class=&quot;sui-icon-check-tick&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;
&lt;/li&gt;

Expand All @@ -138,13 +138,13 @@ <h1 class="sui-box-title">Section 3</h1>
&lt;/div&gt;

&lt;!-- SECTION: Tab 1 (Current) --&gt;
&lt;div class=&quot;sui-box&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;sui-box&quot; tabindex=&quot;0&quot; aria-hidden=&quot;false&quot; &gt;...&lt;/div&gt;

&lt;!-- SECTION: Tab 2 --&gt;
&lt;div class=&quot;sui-box&quot; style=&quot;display: none;&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;sui-box&quot; tabindex=&quot;0&quot; aria-hidden=&quot;true&quot; style=&quot;display: none;&quot;&gt;...&lt;/div&gt;

&lt;!-- SECTION: Tab 3 --&gt;
&lt;div class=&quot;sui-box&quot; style=&quot;display: none;&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;sui-box&quot; tabindex=&quot;0&quot; aria-hidden=&quot;true&quot; style=&quot;display: none;&quot;&gt;...&lt;/div&gt;

&lt;/section&gt;
</pre>
Expand Down