-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from zusorio/confetti-champions
feat: Add confetti and champions overlays 🎉
- Loading branch information
Showing
8 changed files
with
198 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
website/src/components/broadcast/roots/ChampionsOverlay.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<ConfettiOverlay v-if="winner" :theme="winner?.theme" :active="active" :animation-active="animationActive"/> | ||
</template> | ||
|
||
<script> | ||
import ConfettiOverlay from "@/components/broadcast/roots/ConfettiOverlay.vue"; | ||
import { ReactiveArray, ReactiveRoot, ReactiveThing } from "@/utils/reactive"; | ||
export default { | ||
components: { ConfettiOverlay }, | ||
props: ["broadcast", "stingerText", "active", "animationActive"], | ||
name: "ChampionsOverlay", | ||
data: () => ({ | ||
confettiStarted: false, | ||
prodData: { | ||
minor: true | ||
} | ||
}), | ||
mounted() { | ||
console.log(this.stingerText); | ||
this.$parent.updateText(); | ||
this.$parent.setTextVisibility(this.stingerTextVal); | ||
}, | ||
computed: { | ||
stingerTextVal() { | ||
return this.winner ? (this.stingerText || "Winners") : null; | ||
}, | ||
match() { | ||
if (!this.broadcast?.live_match?.length) return null; | ||
return ReactiveRoot(this.broadcast?.live_match?.[0], { | ||
teams: ReactiveArray("teams", { | ||
theme: ReactiveThing("theme") | ||
}) | ||
}); | ||
}, | ||
winner() { | ||
if (!this.match) return null; | ||
if (!(this.match.first_to && [this.match.score_1, this.match.score_2].some(s => s === this.match.first_to))) return null; | ||
return this.match.teams[this.match.score_1 === this.match.first_to ? 0 : 1]; | ||
} | ||
}, | ||
watch: { | ||
winner: { | ||
deep: true, | ||
handler(winner) { | ||
console.log("winner change", this.$parent); | ||
this.$parent.updateTheme(winner?.theme); | ||
this.$parent.updateText(this.winner ? (this.stingerText || "Winners") : null); | ||
this.$parent.setTextVisibility(this.stingerTextVal); | ||
} | ||
} | ||
}, | ||
metaInfo() { | ||
return { | ||
title: `Champions | ${this.broadcast?.code || this.broadcast?.name || ""}` | ||
}; | ||
} | ||
}; | ||
</script> |
104 changes: 104 additions & 0 deletions
104
website/src/components/broadcast/roots/ConfettiOverlay.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<template> | ||
<div></div> | ||
</template> | ||
<script> | ||
import VueConfetti from "vue-confetti"; | ||
import { ReactiveRoot } from "@/utils/reactive"; | ||
import Vue from "vue"; | ||
Vue.use(VueConfetti); | ||
export default { | ||
props: ["themeId", "theme", "active", "animationActive"], | ||
name: "ConfettiOverlay", | ||
data: () => ({ | ||
confettiStarted: false, | ||
confettiDisabled: false, | ||
noStinger: true, | ||
prodData: { | ||
minor: true | ||
} | ||
}), | ||
methods: { | ||
startOrUpdateConfetti() { | ||
if (this.confettiDisabled) return; | ||
console.log("start confetti"); | ||
if (!this.confettiStarted) { | ||
this.$confetti.start({ | ||
particles: [ | ||
{ | ||
type: "circle" | ||
} | ||
], | ||
defaultColors: this.confettiColors | ||
}); | ||
this.confettiStarted = true; | ||
} else { | ||
this.$confetti.update({ | ||
particles: [ | ||
{ | ||
type: "circle" | ||
} | ||
], | ||
defaultColors: this.confettiColors | ||
}); | ||
} | ||
} | ||
}, | ||
watch: { | ||
confettiColors: { | ||
handler() { | ||
if (this.confettiColors.length === 0) return; | ||
this.startOrUpdateConfetti(); | ||
}, | ||
immediate: true | ||
}, | ||
animationActive: { | ||
handler(isActive) { | ||
console.log("active", isActive); | ||
if (!isActive) return; | ||
if (this.confettiColors.length === 0) return; | ||
this.startOrUpdateConfetti(); | ||
}, | ||
immediate: true | ||
} | ||
}, | ||
computed: { | ||
themeData() { | ||
return this.theme || ReactiveRoot(this.themeId); | ||
}, | ||
confettiColors() { | ||
return Array.from(new Set( | ||
[ | ||
this.themeData?.color_theme, | ||
this.themeData?.color_logo_background, | ||
this.themeData?.color_logo_accent, | ||
this.themeData?.color_accent, | ||
this.themeData?.color_alt | ||
].filter(Boolean)) | ||
); | ||
} | ||
}, | ||
metaInfo() { | ||
return { | ||
title: `Confetti | ${this.broadcast?.code || this.broadcast?.name || ""}` | ||
}; | ||
}, | ||
sockets: { | ||
stop_confetti() { | ||
console.log("confetti stop"); | ||
this.confettiStarted = false; | ||
this.$confetti.stop(); | ||
}, | ||
disable_confetti() { | ||
this.confettiDisabled = true; | ||
}, | ||
enable_confetti() { | ||
this.confettiDisabled = false; | ||
} | ||
} | ||
}; | ||
</script> | ||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters