From 83ce2849c72fb7cefa7d99cb502f4b27af5618ed Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Sat, 21 Jan 2023 19:31:23 +0100 Subject: [PATCH] improved mobile ui (fix #6), more animations --- client/src/lib/game.svelte | 154 ++++++++++++++++++++++++++++--------- client/src/lib/move.svelte | 4 +- 2 files changed, 120 insertions(+), 38 deletions(-) diff --git a/client/src/lib/game.svelte b/client/src/lib/game.svelte index da50220..b803f3f 100644 --- a/client/src/lib/game.svelte +++ b/client/src/lib/game.svelte @@ -1,7 +1,7 @@ + + @@ -191,6 +219,20 @@ {/if} +{#if innerWidth < 1024} + +{/if} +
{#each classes as className, i} @@ -199,7 +241,7 @@ {@const moveIndex = moves.findIndex(cmove => cmove.i == i && cmove.j == j)} {@const move = moves[moveIndex]}
addMove(i, j)} on:keydown={() => addMove(i, j)} class:hover={hoveredPiece?.i == i && hoveredPiece.j == j} @@ -242,22 +284,22 @@ {#if containerStates[i] == 1}
- - + +
{:else if containerStates[i] == 2}
- +
{:else if containerStates[i] == 3}
- - - + + +
{/if} @@ -267,22 +309,22 @@ {#if overallState == 1}
- - + +
{:else if overallState == 2}
- +
{:else if overallState == 3}
- - - + + +
{/if} @@ -325,36 +367,47 @@ {/key}
-
-
- {#if twoPlayer} -
- - - - - {self == 1 ? (selfName || "you") : (opponentName || "opponent")} + + {#if movesShown || innerWidth >= 1024} +
movesShown = false} on:keydown={() => movesShown = false} /> + +
+
+
+ Moves + {#key moves.length} + {moves.length} + {/key}
-
- - - - {self == 2 ? (selfName || "you") : (opponentName || "opponent")} -
- {/if} - {#each moves as move} - hoveredPiece = { i: move.i, j: move.j }} on:mouseout={() => { if(hoveredPiece?.j == move.j && hoveredPiece.i == move.i) hoveredPiece = null }} /> - {/each} - + {#if twoPlayer} +
+ + + + + {self == 1 ? (selfName || "you") : (opponentName || "opponent")} +
+
+ + + + {self == 2 ? (selfName || "you") : (opponentName || "opponent")} +
+ {/if} + {#each moves as move} + hoveredPiece = { i: move.i, j: move.j }} on:mouseout={() => { if(hoveredPiece?.j == move.j && hoveredPiece.i == move.i) hoveredPiece = null }} /> + {/each} + +
-
+ {/if}
\ No newline at end of file diff --git a/client/src/lib/move.svelte b/client/src/lib/move.svelte index 04d20ae..a6b76a5 100644 --- a/client/src/lib/move.svelte +++ b/client/src/lib/move.svelte @@ -1,11 +1,13 @@ -
+
{#if player == 1}