disable tabs when 0 results found

This commit is contained in:
Alina Beck 2020-03-23 13:57:56 +01:00
parent 6d531c2cf8
commit e03260d28d
2 changed files with 19 additions and 3 deletions

View File

@ -54,8 +54,16 @@ export default {
}, },
tabOptions() { tabOptions() {
return [ return [
{ type: 'Post', title: `${this.posts.length} Posts` }, {
{ type: 'User', title: `${this.users.length} Users` }, type: 'Post',
title: `${this.posts.length} Posts`,
disabled: !this.posts.length,
},
{
type: 'User',
title: `${this.users.length} Users`,
disabled: !this.users.length,
},
] ]
}, },
}, },

View File

@ -3,7 +3,7 @@
<li <li
v-for="tab in tabs" v-for="tab in tabs"
:key="tab.type" :key="tab.type"
:class="[activeTab === tab.type && '--active', 'tab']" :class="[activeTab === tab.type && '--active', tab.disabled && '--disabled', 'tab']"
role="button" role="button"
@click="$emit('switchTab', tab.type)" @click="$emit('switchTab', tab.type)"
> >
@ -25,6 +25,7 @@ export default {
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.tabs { .tabs {
display: flex; display: flex;
@ -43,6 +44,13 @@ export default {
border: none; border: none;
} }
&.--disabled {
background: $background-color-disabled;
border: 1px solid $color-neutral-80;
pointer-events: none;
cursor: default;
}
&:hover:not(.--active) { &:hover:not(.--active) {
background: $color-neutral-85; background: $color-neutral-85;
} }