| 1 | <script setup lang="ts"> |
| 2 | // import { parseTimesplits } from '@slidev/parser/utils' |
| 3 | import { computed, reactive } from 'vue' |
| 4 | // import { useNav } from '../composables/useNav' |
| 5 | import { useTimer } from '../composables/useTimer' |
| 6 | |
| 7 | // const { slides } = useNav() |
| 8 | |
| 9 | const timer = reactive(useTimer()) |
| 10 | // TODO: timesplit |
| 11 | // const slidesWithTimesplits = computed(() => slides.value.filter(i => i.meta.slide?.frontmatter.timesplit)) |
| 12 | |
| 13 | // const _timesplits = computed(() => { |
| 14 | // const parsed = parseTimesplits( |
| 15 | // slidesWithTimesplits.value |
| 16 | // .map(i => ({ no: i.no, timesplit: i.meta.slide?.frontmatter.timesplit as string })), |
| 17 | // ) |
| 18 | // return parsed |
| 19 | // }) |
| 20 | |
| 21 | // TODO: maybe make it configurable, or somehow more smart |
| 22 | const color = computed(() => { |
| 23 | if (timer.status === 'stopped') |
| 24 | return 'op50' |
| 25 | if (timer.status === 'paused') |
| 26 | return 'bg-blue' |
| 27 | |
| 28 | if (timer.percentage > 100) |
| 29 | return 'bg-red' |
| 30 | else if (timer.percentage > 80) |
| 31 | return 'bg-yellow' |
| 32 | else |
| 33 | return 'bg-green' |
| 34 | }) |
| 35 | </script> |
| 36 | |
| 37 | <template> |
| 38 | <div |
| 39 | class="border-b mt-px border-main relative flex h-4px" |
| 40 | > |
| 41 | <div |
| 42 | v-if="timer.status !== 'stopped'" |
| 43 | class="h-4px" |
| 44 | :class="color" |
| 45 | :style="{ width: `${timer.percentage}%` }" |
| 46 | /> |
| 47 | <!-- {{ timesplits }} --> |
| 48 | </div> |
| 49 | </template> |
| 50 |