Spookie/assets/js/components/tabs/TabsGroup.vue

79 lines
1.2 KiB
Vue
Raw Normal View History

2022-05-11 14:48:04 +02:00
<template lang="html">
<div class="tabs">
<ul class="tabs-header">
<li
v-for="title in tabTitles"
:key="title"
:class="{ selected: title === selectedTitle }"
2022-05-23 16:25:55 +02:00
class="btn"
2022-05-12 19:29:14 +02:00
@click="handleClick(title)"
2022-05-11 14:48:04 +02:00
>
{{ title }}
</li>
</ul>
<slot/>
</div>
</template>
<script>
import { ref, provide } from 'vue'
export default {
2022-05-13 17:58:13 +02:00
name: 'TabsGroup',
2022-05-11 14:48:04 +02:00
setup(props, { slots }) {
const tabTitles = ref(slots.default()
.map((tab) => tab.props.title))
const selectedTitle = ref(tabTitles.value[0])
provide('selectedTitle', selectedTitle)
return {
selectedTitle,
tabTitles
}
},
2022-05-12 19:29:14 +02:00
methods: {
handleClick(title) {
this.selectedTitle = title
this.$emit('tabActivated', title)
}
2022-05-11 14:48:04 +02:00
},
}
</script>
2022-05-23 16:25:55 +02:00
<style lang="scss">
@import "~styles/app.scss";
2022-05-11 14:48:04 +02:00
.tabs {
width: auto;
margin: 0 auto;
}
.tabs-header {
margin-bottom: 10px;
list-style: none;
display: flex;
}
.tabs-header li {
width: 140px;
text-align: center;
padding: 10px 20px;
margin-right: 10px;
2022-05-23 16:25:55 +02:00
background-color: #2e2e2e;
2022-05-11 14:48:04 +02:00
border-radius: 5px;
2022-05-23 16:25:55 +02:00
color: #999999;
2022-05-11 14:48:04 +02:00
cursor: pointer;
transition: 0.4s all ease-out;
}
.tabs-header li.selected {
2022-05-23 16:25:55 +02:00
background-color: $primary;
color: $jet-black;
}
.tabs-header li.selected:hover {
2022-05-25 14:41:58 +02:00
/*border-color: $body-color; */
2022-05-11 14:48:04 +02:00
}
2022-05-23 16:25:55 +02:00
2022-05-11 14:48:04 +02:00
</style>