simplify code

This commit is contained in:
2022-12-20 16:02:57 +01:00
parent 071d1f9788
commit bd15f631f9
3 changed files with 51 additions and 60 deletions

View File

@@ -2,7 +2,7 @@
<div class="tabs is-centered">
<ul>
<li
v-for="window in windows"
v-for="window in props.windows"
:key="window.label"
@click="emit('set-window', window)"
:class="{ 'is-active': window.label === activeWindow?.label }"
@@ -13,22 +13,15 @@
</div>
</template>
<script setup lang="ts">
import { onMounted, defineProps, defineEmits } from 'vue'
import { windows } from '@/utils/helpers'
import { defineProps, defineEmits } from 'vue'
import type { Window } from '@/utils/types'
const props = defineProps<{
activeWindow: Window | undefined
activeWindow: Window
windows: Window[]
}>()
const emit = defineEmits<{
(e: 'set-window', window: Window): void
}>()
onMounted(() => {
const activeWindow = !props.activeWindow?.label
? windows[1]
: windows.find((w) => w.label === props.activeWindow?.label.replace('-', ' '))
if (activeWindow) emit('set-window', activeWindow)
})
</script>