You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
Vue
62 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, watch } from 'vue'
|
|
import { app } from './main'
|
|
import Wordle from './components/Wordle.vue'
|
|
import Solution from './components/Solution.vue'
|
|
import Present from './components/Present.vue'
|
|
|
|
const solution = 'gutschein'
|
|
const video = ref<null | HTMLVideoElement>(null)
|
|
|
|
onMounted(() => {
|
|
const nextTimeout = (delta: number, video: HTMLVideoElement) => {
|
|
const nextDelta = Math.round(2000 + Math.random() * 10000)
|
|
setTimeout(() => {
|
|
video.play()
|
|
nextTimeout(nextDelta, video)
|
|
}, delta)
|
|
}
|
|
nextTimeout(20000, video.value)
|
|
})
|
|
|
|
const level = ref(0)
|
|
watch(level, newLevel => {
|
|
if (newLevel === 0) return
|
|
const confetti = app.config.globalProperties.$confetti
|
|
|
|
if (newLevel === 1) {
|
|
confetti.update({
|
|
particles: [{ type: 'heart', size: 15 }, { type: 'circle', size: 5 }],
|
|
particlesPerFrame: 1,
|
|
})
|
|
confetti.start()
|
|
} else if (newLevel === 2) {
|
|
confetti.update({
|
|
particles: [{ type: 'heart', size: 20 }],
|
|
particlesPerFrame: .1,
|
|
windSpeedMax: 0,
|
|
})
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<header>
|
|
<transition>
|
|
<video v-if="level < 2"
|
|
ref="video" autoplay playsinline
|
|
src="./assets/happybirthday.mp4" width="852" height="480"
|
|
/>
|
|
<img v-else
|
|
src="./assets/present.png"
|
|
/>
|
|
</transition>
|
|
</header>
|
|
|
|
<main>
|
|
<Wordle :solution="solution" @success="level++" v-if="level === 0" />
|
|
<Solution :solution="solution" @success="level++" v-else-if="level === 1" />
|
|
<Present v-else />
|
|
</main>
|
|
</template>
|