2023-06-18 13:31:38 -05:00
|
|
|
<template>
|
|
|
|
<div class="inline-flex toggle-btn-wrapper shadow-md">
|
2025-01-18 10:38:24 -06:00
|
|
|
<button v-for="(item, index) in items" :key="`${name}-${index}`" type="button" class="toggle-btn outline-none relative border border-border px-4 py-1" :class="{ selected: item.value === value }" @click.stop="clickBtn(item.value)">
|
2023-06-18 13:31:38 -05:00
|
|
|
{{ item.text }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2025-01-18 10:38:24 -06:00
|
|
|
name: String,
|
|
|
|
value: [String, Number, Boolean],
|
2023-06-18 13:31:38 -05:00
|
|
|
items: {
|
|
|
|
type: Array,
|
|
|
|
default: Object
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
methods: {
|
|
|
|
clickBtn(value) {
|
|
|
|
this.$emit('input', value)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.toggle-btn-wrapper .toggle-btn:first-child {
|
|
|
|
border-top-left-radius: 0.375rem /* 6px */;
|
|
|
|
border-bottom-left-radius: 0.375rem /* 6px */;
|
|
|
|
}
|
|
|
|
.toggle-btn-wrapper .toggle-btn:last-child {
|
|
|
|
border-top-right-radius: 0.375rem /* 6px */;
|
|
|
|
border-bottom-right-radius: 0.375rem /* 6px */;
|
|
|
|
}
|
|
|
|
.toggle-btn-wrapper .toggle-btn:first-child::before {
|
|
|
|
border-top-left-radius: 0.375rem /* 6px */;
|
|
|
|
border-bottom-left-radius: 0.375rem /* 6px */;
|
|
|
|
}
|
|
|
|
.toggle-btn-wrapper .toggle-btn:last-child::before {
|
|
|
|
border-top-right-radius: 0.375rem /* 6px */;
|
|
|
|
border-bottom-right-radius: 0.375rem /* 6px */;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-btn-wrapper .toggle-btn:not(:first-child) {
|
|
|
|
margin-left: -1px;
|
|
|
|
}
|
|
|
|
.toggle-btn {
|
2023-12-13 16:57:44 -06:00
|
|
|
background-color: rgb(var(--color-bg-toggle));
|
|
|
|
color: rgb(var(--color-fg) / 0.5);
|
2023-06-18 13:31:38 -05:00
|
|
|
}
|
|
|
|
.toggle-btn.selected {
|
2023-12-13 16:57:44 -06:00
|
|
|
background-color: rgb(var(--color-bg-toggle-selected));
|
|
|
|
color: rgb(var(--color-fg));
|
2023-06-18 13:31:38 -05:00
|
|
|
}
|
|
|
|
</style>
|