2023-12-01 15:29:26 +01:00
|
|
|
<script setup>
|
|
|
|
const props = defineProps({
|
|
|
|
stepCount: {
|
|
|
|
type: Number,
|
|
|
|
default: 10
|
2023-04-14 17:13:28 +02:00
|
|
|
},
|
2023-12-01 15:29:26 +01:00
|
|
|
initialIndex: {
|
|
|
|
type: Number,
|
|
|
|
default: null
|
2023-05-29 11:33:30 +02:00
|
|
|
},
|
2023-12-01 15:29:26 +01:00
|
|
|
period: { // Used only to identify the dots component in Accounts.vue
|
|
|
|
type: Number,
|
|
|
|
default: null
|
2023-05-29 11:33:30 +02:00
|
|
|
},
|
2023-12-01 15:29:26 +01:00
|
|
|
})
|
2023-05-29 11:33:30 +02:00
|
|
|
|
2023-12-01 15:29:26 +01:00
|
|
|
const activeDot = ref(0)
|
|
|
|
const isOff = computed(() => {
|
|
|
|
return activeDot.value == -1
|
|
|
|
})
|
2023-05-29 11:33:30 +02:00
|
|
|
|
2023-12-01 15:29:26 +01:00
|
|
|
/**
|
|
|
|
* Turns On dots
|
|
|
|
*/
|
|
|
|
function turnOn(index) {
|
|
|
|
activeDot.value = index < props.stepCount ? index + 1 : 1
|
2023-04-14 17:13:28 +02:00
|
|
|
}
|
2023-12-01 15:29:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Turns Off all dots
|
|
|
|
*/
|
|
|
|
function turnOff() {
|
|
|
|
activeDot.value = -1
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (! isNaN(props.initialIndex)) {
|
|
|
|
turnOn(props.initialIndex)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
turnOn,
|
|
|
|
turnOff,
|
|
|
|
props
|
|
|
|
})
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<ul class="dots" :class="{'off' : isOff}">
|
|
|
|
<li v-for="n in stepCount" :key="n" :data-is-active="n == activeDot ? true : null"></li>
|
|
|
|
</ul>
|
|
|
|
</template>
|