Skip to content
This repository was archived by the owner on Oct 24, 2018. It is now read-only.

Commit c1e9ac5

Browse files
Merge pull request #16 from Microdisseny/set-tab-enabled
Set tab visibility
2 parents 0c76966 + f8c6a64 commit c1e9ac5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/components/Tab.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
data: () => ({
2222
isActive: false,
23+
isVisible: true,
2324
}),
2425
2526
computed: {

src/components/Tabs.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:class="{ 'is-active': tab.isActive }"
66
class="tabs-component-tab"
77
role="presentation"
8+
v-show="tab.isVisible"
89
>
910

1011
<a v-html="tab.header"
@@ -101,6 +102,26 @@
101102
102103
expiringStorage.set(this.storageKey, selectedTab.hash, this.cacheLifetime);
103104
},
105+
setTabVisible(hash, visible) {
106+
const tab = this.findTab(hash);
107+
108+
if (! tab) {
109+
return;
110+
}
111+
112+
tab.isVisible = visible;
113+
if (tab.isActive) {
114+
// if tab is active, set a different one as active
115+
tab.isActive = visible;
116+
this.tabs.every(function(element, index, array) {
117+
if (element.isVisible) {
118+
element.isActive = true;
119+
return false;
120+
}
121+
return true;
122+
})
123+
}
124+
},
104125
},
105126
};
106127
</script>

0 commit comments

Comments
 (0)