Skip to content

Commit

Permalink
docs(dev-novel): add tabs to switch between kinds of stories (algolia…
Browse files Browse the repository at this point in the history
  • Loading branch information
bobylito authored May 29, 2018
1 parent 7796e83 commit a5d7064
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dev/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,37 @@ registerDisposer(() => {

const q = window.location.search;

let selectedTab = '';
switch (true) {
case q.includes('widgets=vanilla'):
initVanillaWidgets();
selectedTab = 'vanilla';
break;
case q.includes('widgets=jquery'):
initJqueryWidgets();
selectedTab = 'jquery';
break;
case q.includes('widgets=unmount'):
initUnmountWidgets();
selectedTab = 'unmount';
break;
default:
initBuiltInWidgets();
}

const selectStories = document.createElement('div');
selectStories.className = 'story-selector';
selectStories.innerHTML = `
<a href="?" class="tab ${selectedTab === '' ? 'active' : ''}">Built-in</a>
<a href="?widgets=jquery" class="tab ${
selectedTab === 'jquery' ? 'active' : ''
}">Connectors with jQuery</a>
<a href="?widgets=unmount" class="tab ${
selectedTab === 'unmount' ? 'active' : ''
}">Disposable widgets</a>
`;
document.body.appendChild(selectStories);

start({
projectName: 'instantsearch.js',
projectLink: 'https://community.algolia.com/instantsearch.js/',
Expand Down
20 changes: 20 additions & 0 deletions dev/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,23 @@
.my-custom-info-box__text {
text-align: center;
}

.story-selector {
padding-left: 5px;
background: #333;
}

.tab {
height: 30px;
display: inline-block;
padding: 5px;
margin: 5px 2px 0 2px;
background: #d6d6d6;
color: #777;
text-decoration: none;
}

.tab.active {
background: #f7f7f7;
color: black;
}

0 comments on commit a5d7064

Please sign in to comment.