WIP: Still working

This commit is contained in:
Pablu23
2025-10-08 10:55:09 +02:00
parent 5a6950899f
commit f99eb3fc01

View File

@@ -29,11 +29,11 @@
let isPlaying = $state(false); let isPlaying = $state(false);
// Mock player data // Mock player data
const players = $state<Player[]>([ const players: Player[] = [
{ id: 1, name: 'YourName', isHost: true }, { id: 1, name: 'YourName', isHost: true },
{ id: 2, name: 'Player2', isHost: false }, { id: 2, name: 'Player2', isHost: false },
{ id: 3, name: 'GamerX', isHost: false } { id: 3, name: 'GamerX', isHost: false }
]); ];
// Mock cards data // Mock cards data
const mockCards = [ const mockCards = [
@@ -183,9 +183,6 @@
newCards.splice(dragTargetIndex, 0, currentCard); newCards.splice(dragTargetIndex, 0, currentCard);
placedCards = newCards; placedCards = newCards;
// Remove the current card
currentCard = null;
// Send update to other players via WebSocket // Send update to other players via WebSocket
ws.sendMessage({ ws.sendMessage({
type: 'cardPlaced', type: 'cardPlaced',
@@ -193,6 +190,9 @@
position: dragTargetIndex position: dragTargetIndex
}); });
// Remove the current card
currentCard = null;
// Reset the card position and style // Reset the card position and style
card.style.position = ''; card.style.position = '';
card.style.left = ''; card.style.left = '';
@@ -218,9 +218,9 @@
onMount(() => { onMount(() => {
// Set up initial game $state // Set up initial game $state
placedCards = [mockCards[0]]; placedCards = [mockCards[0], mockCards[1]];
cards = mockCards.slice(1); cards = mockCards.slice(2);
currentCard = mockCards[1]; currentCard = mockCards[3];
// Set up event listeners for drag and drop // Set up event listeners for drag and drop
window.addEventListener('mousemove', onDrag); window.addEventListener('mousemove', onDrag);
@@ -257,7 +257,7 @@
{#if getPlayerInfo().previous} {#if getPlayerInfo().previous}
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<span class="text-xs text-indigo-200">Previous</span> <span class="text-xs text-indigo-200">Previous</span>
<span class="text-sm font-medium">PREVIOUS PLACE {getPlayerInfo().previous.name}</span> <span class="text-sm font-medium">PREVIOUS NAME</span>
</div> </div>
{/if} {/if}
@@ -269,7 +269,7 @@
{#if getPlayerInfo().next} {#if getPlayerInfo().next}
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<span class="text-xs text-indigo-200">Next</span> <span class="text-xs text-indigo-200">Next</span>
<span class="text-sm font-medium">{getPlayerInfo().next.name}</span> <span class="text-sm font-medium">NEXT NAME</span>
</div> </div>
{/if} {/if}
</div> </div>
@@ -287,7 +287,7 @@
<div class="flex items-center space-x-4"> <div class="flex items-center space-x-4">
<button <button
class="p-2 bg-indigo-600 text-white rounded-full hover:bg-indigo-700" class="p-2 bg-indigo-600 text-white rounded-full hover:bg-indigo-700"
on:click={togglePlayPause} onclick={togglePlayPause}
> >
{#if isPlaying} {#if isPlaying}
<!-- Pause icon --> <!-- Pause icon -->
@@ -336,7 +336,7 @@
min="0" min="0"
max={audioDuration} max={audioDuration}
value={audioProgress} value={audioProgress}
on:input={updateProgress} oninput={updateProgress}
class="w-full h-2 rounded-lg appearance-none bg-gray-200 cursor-pointer" class="w-full h-2 rounded-lg appearance-none bg-gray-200 cursor-pointer"
/> />
<div class="flex justify-between text-xs text-gray-500 mt-1"> <div class="flex justify-between text-xs text-gray-500 mt-1">
@@ -353,11 +353,17 @@
<div class="relative py-10 mb-12"> <div class="relative py-10 mb-12">
<div class="overflow-x-auto pb-4"> <div class="overflow-x-auto pb-4">
<div class="flex space-x-6 min-w-full px-6"> <div class="flex space-x-6 min-w-full px-6">
<div
class="card-slot relative flex-shrink-0 w-48 h-64 border-2 border-dashed border-gray-200 rounded-lg {dragTargetIndex ===
0
? 'highlight'
: ''}"
></div>
{#each placedCards as card, index} {#each placedCards as card, index}
<!-- Adding card-slot class for drop target detection --> <!-- Adding card-slot class for drop target detection -->
<div <div
class="card-slot relative flex-shrink-0 w-48 h-64 rounded-lg overflow-hidden shadow-md border border-gray-200 transition-all {dragTargetIndex === class="card-slot relative flex-shrink-0 w-48 h-64 rounded-lg overflow-hidden shadow-md border border-gray-200 transition-all {dragTargetIndex ===
index index + 1
? 'highlight' ? 'highlight'
: ''}" : ''}"
> >
@@ -378,7 +384,7 @@
<!-- Add an extra slot at the end --> <!-- Add an extra slot at the end -->
<div <div
class="card-slot relative flex-shrink-0 w-48 h-64 border-2 border-dashed border-gray-200 rounded-lg {dragTargetIndex === class="card-slot relative flex-shrink-0 w-48 h-64 border-2 border-dashed border-gray-200 rounded-lg {dragTargetIndex ===
placedCards.length placedCards.length + 1
? 'highlight' ? 'highlight'
: ''}" : ''}"
></div> ></div>
@@ -389,13 +395,14 @@
<!-- Current card to place - will be draggable --> <!-- Current card to place - will be draggable -->
{#if currentCard} {#if currentCard}
<div class="flex justify-center mb-8"> <div class="flex justify-center mb-8">
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div <div
id="current-card" id="current-card"
class="card relative w-48 h-64 rounded-lg overflow-hidden shadow-lg border border-indigo-400 cursor-move {currentPlayerId !== class="card relative w-48 h-64 rounded-lg overflow-hidden shadow-lg border border-indigo-400 cursor-move {currentPlayerId !==
players[0].id players[0].id
? 'pointer-events-none opacity-70' ? 'pointer-events-none opacity-70'
: ''}" : ''}"
on:mousedown={startDrag} onmousedown={startDrag}
> >
<div class="absolute inset-0 flex flex-col p-4 bg-white"> <div class="absolute inset-0 flex flex-col p-4 bg-white">
<div class="text-center text-gray-600 text-sm mb-1">Artist</div> <div class="text-center text-gray-600 text-sm mb-1">Artist</div>
@@ -424,7 +431,7 @@
</div> </div>
</div> </div>
<style> <style lang="css">
/* Prevent text selection during drag */ /* Prevent text selection during drag */
:global(.no-select) { :global(.no-select) {
user-select: none; user-select: none;