Skip to content

Commit

Permalink
Add comfortable utility methods to Tabs component
Browse files Browse the repository at this point in the history
Add getTabIndex, getTabHash, getActiveTab and getActiveTabIndex methods to Tabs component.
  • Loading branch information
matewiszt authored Mar 30, 2018
1 parent 88b969c commit 4c4a155
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,30 @@
});
}
},
getTabIndex(hash){
const tab = this.findTab(hash);
return this.tabs.indexOf(tab);
},
getTabHash(index){
const tab = this.tabs.find(tab => this.tabs.indexOf(tab) === index);
if (!tab) {
return;
}
return tab.hash;
},
getActiveTab(){
return this.findTab(this.activeTabHash);
},
getActiveTabIndex() {
return this.getTabIndex(this.activeTabHash);
},
},
};
</script>

0 comments on commit 4c4a155

Please sign in to comment.