mirror of
https://github.com/jcreek/EstimationPoker.git
synced 2026-07-12 18:43:47 +00:00
Merge pull request #29 from OllyNicholass/23-guy-fawkes
feat(#23): triggering fireworks when everyone's on board 🎆
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fireworks-js/svelte": "^2.10.7",
|
||||||
"@joeattardi/emoji-button": "^4.6.4",
|
"@joeattardi/emoji-button": "^4.6.4",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"ws": "^8.13.0"
|
"ws": "^8.13.0"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
const changesLog = [
|
const changesLog = [
|
||||||
{ timestamp: '2024-01-05T00:00:00', message: 'Added the ability to kick a user' },
|
{ timestamp: '2024-01-05T00:00:00', message: 'Added the ability to kick a user' },
|
||||||
{ timestamp: '2024-01-05T00:00:00', message: 'Added update notes' },
|
{ timestamp: '2024-01-05T00:00:00', message: 'Added update notes' }
|
||||||
];
|
];
|
||||||
|
|
||||||
let newChanges = [];
|
let newChanges = [];
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
import EstimateGroupsList from '../../../components/EstimateGroupsList.svelte';
|
import EstimateGroupsList from '../../../components/EstimateGroupsList.svelte';
|
||||||
import Modal from '../../../components/Modal.svelte';
|
import Modal from '../../../components/Modal.svelte';
|
||||||
import Estimates from '../../../components/Estimates.svelte';
|
import Estimates from '../../../components/Estimates.svelte';
|
||||||
|
import Fireworks, { type FireworksOptions } from '@fireworks-js/svelte';
|
||||||
|
|
||||||
import { connectToWebSocket, sendMessage, generateId } from '../estimation.js';
|
import { connectToWebSocket, sendMessage, generateId } from '../estimation.js';
|
||||||
|
|
||||||
@@ -89,6 +90,19 @@
|
|||||||
let showEstimates = false;
|
let showEstimates = false;
|
||||||
let disableEstimates: boolean = false;
|
let disableEstimates: boolean = false;
|
||||||
let audioElement;
|
let audioElement;
|
||||||
|
let showFireworks = false;
|
||||||
|
let fireworks: Fireworks;
|
||||||
|
let fireworkOptions: FireworksOptions = {
|
||||||
|
opacity: 0.5,
|
||||||
|
sound: {
|
||||||
|
enabled: true,
|
||||||
|
files: ['/sounds/explosion0.mp3', '/sounds/explosion1.mp3', '/sounds/explosion2.mp3'],
|
||||||
|
volume: {
|
||||||
|
min: 1,
|
||||||
|
max: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
let selectedCardSet;
|
let selectedCardSet;
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
@@ -142,6 +156,16 @@
|
|||||||
sendMessage(socket, { roomId: data.roomId, type: 'restart-estimation' });
|
sendMessage(socket, { roomId: data.roomId, type: 'restart-estimation' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function areEstimatesSame(estimateGroups: { [key: number | string]: string[] }): boolean {
|
||||||
|
const estimates = Object.keys(estimateGroups);
|
||||||
|
const users = Object.values(estimateGroups);
|
||||||
|
const allUsers = users.flat();
|
||||||
|
|
||||||
|
if (allUsers.length > 2 && estimates.length === 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onMessageReceived(message) {
|
function onMessageReceived(message) {
|
||||||
if (message.type === 'user-joined') {
|
if (message.type === 'user-joined') {
|
||||||
sendMessage(socket, { type: 'get-user-estimates' });
|
sendMessage(socket, { type: 'get-user-estimates' });
|
||||||
@@ -166,10 +190,17 @@
|
|||||||
users = users.filter((user) => user.userId !== message.userId);
|
users = users.filter((user) => user.userId !== message.userId);
|
||||||
} else if (message.type === 'estimation-closed') {
|
} else if (message.type === 'estimation-closed') {
|
||||||
estimateGroups = message.groupedEstimates;
|
estimateGroups = message.groupedEstimates;
|
||||||
|
showFireworks = areEstimatesSame(estimateGroups);
|
||||||
|
if (showFireworks) {
|
||||||
|
setTimeout(() => {
|
||||||
|
showFireworks = false;
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
showRestartButton = true;
|
showRestartButton = true;
|
||||||
showEstimates = true;
|
showEstimates = true;
|
||||||
disableEstimates = true;
|
disableEstimates = true;
|
||||||
} else if (message.type === 'estimation-restarted') {
|
} else if (message.type === 'estimation-restarted') {
|
||||||
|
showFireworks = false;
|
||||||
estimateGroups = {};
|
estimateGroups = {};
|
||||||
showRestartButton = false;
|
showRestartButton = false;
|
||||||
showEstimates = false;
|
showEstimates = false;
|
||||||
@@ -244,6 +275,12 @@
|
|||||||
<EstimateGroupsList {estimateGroups} />
|
<EstimateGroupsList {estimateGroups} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if showFireworks}
|
||||||
|
<div class="fireworks-container">
|
||||||
|
<Fireworks bind:this={fireworks} options={fireworkOptions} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<audio src="/call-to-attention-50-percent-volume.mp3" bind:this={audioElement} />
|
<audio src="/call-to-attention-50-percent-volume.mp3" bind:this={audioElement} />
|
||||||
|
|
||||||
{#if showTooltip && newChanges.length > 0}
|
{#if showTooltip && newChanges.length > 0}
|
||||||
@@ -251,10 +288,9 @@
|
|||||||
<h3>Latest Updates</h3>
|
<h3>Latest Updates</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{#each newChanges as change (change.timestamp)}
|
{#each newChanges as change (change.timestamp)}
|
||||||
<li>{new Date(change.timestamp).toLocaleDateString()}: {change.message}</li>
|
<li>{new Date(change.timestamp).toLocaleDateString()}: {change.message}</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -344,12 +380,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#tooltip-container ul {
|
#tooltip-container ul {
|
||||||
list-style-position: inside;
|
list-style-position: inside;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tooltip-container ul li {
|
#tooltip-container ul li {
|
||||||
text-indent: -10px;
|
text-indent: -10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fireworks-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
z-index: -1;
|
||||||
|
pointer-events: none;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user