-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(api): add toggle component for side nav on API page.
- Loading branch information
Noah Mulfinger
committed
Jul 25, 2018
1 parent
834ad79
commit 1432c22
Showing
6 changed files
with
217 additions
and
50 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
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 |
---|---|---|
|
@@ -110,8 +110,4 @@ Vue.component("api-search", { | |
keys: ["title"] | ||
}); | ||
} | ||
}); | ||
|
||
new Vue({ | ||
el: "#page" | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Vue.component("nav-toggle", { | ||
props: ["index", "packageName"], | ||
mounted: function() { | ||
this.trigger = document.getElementById("trigger" + this.index); | ||
this.list = document.getElementById("list" + this.index); | ||
this.toggle = false; | ||
|
||
if (this.packageName.indexOf(window.location.pathname.split("/")[2]) > -1) { | ||
this.show(); | ||
} | ||
|
||
this.trigger.onclick = () => { | ||
if (this.toggle) { | ||
this.hide(); | ||
} else { | ||
this.show(); | ||
} | ||
}; | ||
}, | ||
methods: { | ||
hide: function() { | ||
for (var i = 0; i < this.list.children.length; i++) { | ||
this.trigger.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" class="svg-icon"><path d="M7 4h5l12 12-12 12H7l12-12L7 4z"/></svg>`; | ||
this.list.children[i].classList.add("visually-hidden"); | ||
} | ||
this.toggle = false; | ||
}, | ||
show: function() { | ||
for (var i = 0; i < this.list.children.length; i++) { | ||
this.trigger.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" class="svg-icon"><path d="M28 9v5L16 26 4 14V9l12 12L28 9z"/></svg>`; | ||
this.list.children[i].classList.remove("visually-hidden"); | ||
if (this.list.children[i].children[0].classList.contains("is-active")) { | ||
this.list.children[i].classList.add("list-item-active"); | ||
} | ||
} | ||
this.toggle = true; | ||
} | ||
}, | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.