Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
feat(doppio): fancier score indicator and faction selection
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalHonegger committed May 16, 2021
1 parent 08f21bd commit 82880ba
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 16 deletions.
3 changes: 1 addition & 2 deletions frontend/public/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ button:focus {
left: 0;
z-index: 10;
display: grid;
align-items: center;
justify-items: center;
place-items: center;
background-color: #2022253d;
}
20 changes: 15 additions & 5 deletions frontend/src/components/Cell.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<script lang="ts">
import type {Cell} from "../lib/GameState";
import twemoji from "../lib/Twemoji";
import type { Cell } from "../lib/GameState";
import Piece from "./Piece.svelte";
export let cell: Cell;
</script>

<div class="cell" class:scored={cell.scored}>
<div class="cell">
{#if cell.piece}
<Piece piece={cell.piece}/>
<Piece piece={cell.piece}>
{#if cell.scored}
<div class="score-indicator" use:twemoji>⭐</div>
{/if}
</Piece>
{/if}
</div>

Expand All @@ -28,7 +33,12 @@
border-top-width: 2px;
}
.scored {
background: gold;
.score-indicator {
position: absolute;
display: flex;
place-content: center;
place-items: center;
width: var(--piece-size);
height: var(--piece-size);
}
</style>
54 changes: 46 additions & 8 deletions frontend/src/components/FactionSelect.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts">
import twemoji from "../lib/Twemoji";
import type { Faction } from "../gen/game_pb";
import { startPlaying } from "../lib/ChaosConnectClient";
import type { Player } from "../lib/GameState";
import type { Player } from "../lib/GameState";
import { authMetadata } from "../stores/Auth";
import { playersByFaction } from "../stores/GameState";
import Piece from "./Piece.svelte";
Expand Down Expand Up @@ -59,18 +60,55 @@ import type { Player } from "../lib/GameState";
<Spinner />
{:else}
<h2>Choose Your Faction</h2>
{#each [...$playersByFaction] as [faction, players]}
<button disabled={isUnbalanced(faction)} on:click={() => chooseFaction(faction)}>
<Piece {faction} />
{countConnected(players)} Player{#if countConnected(players) !== 1}s{/if}
</button>
{/each}
<div class="wrapper">
{#each [...$playersByFaction] as [faction, players], i}
{#if i !== 0}
<span use:twemoji class="vs-button">🆚</span>
{/if}
<button
disabled={isUnbalanced(faction)}
on:click={() => chooseFaction(faction)}
>
<span class="piece-wrapper">
<Piece {faction} />
</span>
<span>
{countConnected(players)} Player{#if countConnected(players) !== 1}s{/if}
</span>
</button>
{/each}
</div>
{/if}
</div>

<style>
.faction-select {
text-align: center;
align-self: center;
}
.wrapper {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.vs-button {
font-size: 2em;
display: flex;
margin: 0 var(--spacing);
}
.piece-wrapper {
position: relative;
display: block;
width: var(--piece-size);
height: var(--piece-size);
margin-left: auto;
margin-right: auto;
}
button {
margin: 0;
}
</style>
2 changes: 1 addition & 1 deletion frontend/src/components/Piece.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class:yellow={faction === Faction.YELLOW}
class:red={faction === Faction.RED}
title={playerName != null ? `Placed by ${playerName}` : undefined}
/>
><slot /></div>

<style>
.piece {
Expand Down

0 comments on commit 82880ba

Please sign in to comment.