Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
merklejerk committed Jun 6, 2024
1 parent 39602af commit 96d4c8f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/lib/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ export const SITE_CONTEXT_NAME = 'site';
export function getSiteContext(): SiteContext {
return getContext(SITE_CONTEXT_NAME);
}

export function formatScore(rawScore: number): string {
return (rawScore * 1e3 + 1e3).toFixed(0);
}
4 changes: 2 additions & 2 deletions src/lib/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ h1:first-of-type, h2:first-of-type {
}

h1, h2 {
margin-bottom: 0;
margin-bottom: 0.5em;
color: rgb(176, 138, 40);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ button:not(.custom) {
}
}

input:not([type]), input[type='text'] {
input:not([type]), input[type='text'], textarea {
background: none;
border: none;
border-image: url('/text-input-border.png') 15% 22.5% / 0.5em 1.75ex round;
Expand Down
34 changes: 23 additions & 11 deletions src/routes/player/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { page } from "$app/stores";
import { formatEther, isHex, keccak256, zeroHash, type Address, type Hex } from "viem";
import { PUBLIC_DATA_URL } from "$env/static/public";
import { getSiteContext } from "$lib/site";
import { formatScore, getSiteContext } from "$lib/site";
import { encryptPlayerCode } from "$lib/encrypt";
import Lede from "$lib/components/lede.svelte";
import CatSpinner from "$lib/components/cat-spinner.svelte";
Expand Down Expand Up @@ -271,10 +271,23 @@
gap: 1ex;
}
input.bytecode {
font-family: monospace;
font-size: 1.1em;
letter-spacing: -0.33ex;
.submit-bytecode {
display: flex;
flex-direction: column;
.bytecode {
font-family: monospace;
font-size: 1.1em;
letter-spacing: -0.33ex;
display: block;
width: 0 auto;
}
button {
flex: 0 1 fit-content;
justify-self: end;
align-self: flex-end;
width: 20ex;
}
}
.name {
Expand All @@ -300,7 +313,7 @@
</div>
<div class="is-active">
{#if playerIsActive}
Submission received.
Submission received.
{:else}
Awaiting submission.
{/if}
Expand Down Expand Up @@ -348,7 +361,7 @@
</div>
<div>{tr.type === 'scrimmage' ? 'Market Day' : 'Grand Faire'}</div>
<div>{tr.rank+1} / {tr.totalPlayers}</div>
<div>{Math.round(tr.score * 1e3)}</div>
<div>{formatScore(tr.score)}</div>
</div>
{/each}
</div>
Expand Down Expand Up @@ -377,11 +390,10 @@
If you're providing your code manually, make sure you provide the <em>undeployed</em> bytecode and not the "deployed" one. These are typically named <tt>bytecode</tt> and <tt>deployedBytecode</tt>, respectively, in compiler artifacts.
</p>
<div>
<form on:submit|preventDefault={onSubmitCode}>
<input
<form on:submit|preventDefault={onSubmitCode} class="submit-bytecode">
<textarea
class="bytecode"
placeholder="bytecode"
pattern='^(0x)?[a-fA-F0-9]+'
placeholder="Drop JSON artifact or paste (hex) bytecode"
on:drop|preventDefault={onBytecodeDrop}
bind:value={rawCode}
/>
Expand Down
11 changes: 7 additions & 4 deletions src/routes/tournament/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { page } from "$app/stores";
import Page from "$lib/components/page.svelte";
import { createBusy, type BusyState } from "$lib/kit";
import {
formatScore,
type ScoredPlayer,
type TournamentType,
} from "$lib/site";
Expand All @@ -19,7 +20,7 @@ import { page } from "$app/stores";
interface BracketInfo {
idx: number;
rankings: ScoredPlayerWithWinCount[],
matchCount: number;
matches: string[];
}
interface TournamentData {
Expand Down Expand Up @@ -100,7 +101,7 @@ import { page } from "$app/stores";
{#each data.rankings as player (player.address)}
<li>
<a href={`${base}/player?name=${player.name}`}>{player.name}</a>:
{Math.round(player.score * 1e3)}
{formatScore(player.score)}
</li>
{/each}
</ol>
Expand All @@ -112,15 +113,17 @@ import { page } from "$app/stores";
<h2>Bracket {bracket.idx + 1}</h2>
</div>
<div>
Matches: {bracket.matchCount}
Players: {bracket.rankings.length},
Matches: {bracket.matches.length}
({bracket.matches.length / Math.ceil(bracket.rankings.length / 4)}pp)
</div>
<div>
<h3>Bracket Ranking</h3>
<ol>
{#each bracket.rankings as player (player.address)}
<li>
<a href={`${base}/player?name=${player.name}`}>{player.name}</a>:
{Math.round(player.score * 1e3)}</li>
{formatScore(player.score)}</li>
{/each}
</ol>
</div>
Expand Down

0 comments on commit 96d4c8f

Please sign in to comment.