diff options
Diffstat (limited to 'web/pw-server/src/routes')
-rw-r--r-- | web/pw-server/src/routes/__layout.svelte | 3 | ||||
-rw-r--r-- | web/pw-server/src/routes/editor.svelte | 10 | ||||
-rw-r--r-- | web/pw-server/src/routes/leaderboard.svelte | 28 |
3 files changed, 31 insertions, 10 deletions
diff --git a/web/pw-server/src/routes/__layout.svelte b/web/pw-server/src/routes/__layout.svelte index 2267491..1ef4b8e 100644 --- a/web/pw-server/src/routes/__layout.svelte +++ b/web/pw-server/src/routes/__layout.svelte @@ -13,6 +13,9 @@ <div class="navbar-item"> <a href="/editor">Editor</a> </div> + <div class="navbar-item"> + <a href="/leaderboard">Leaderboard</a> + </div> </div> <div class="navbar-right"> <UserControls /> diff --git a/web/pw-server/src/routes/editor.svelte b/web/pw-server/src/routes/editor.svelte index 85c2454..e85f572 100644 --- a/web/pw-server/src/routes/editor.svelte +++ b/web/pw-server/src/routes/editor.svelte @@ -19,7 +19,6 @@ Editor, MatchVisualizer, Rules, - Leaderboard, } let matches = []; @@ -153,13 +152,6 @@ > Rules </div> - <div - class="sidebar-item" - class:selected={viewMode === ViewMode.Leaderboard} - on:click={() => setViewMode(ViewMode.Leaderboard)} - > - Leaderboard - </div> <div class="sidebar-header">match history</div> <ul class="match-list"> {#each matches as match} @@ -184,8 +176,6 @@ <EditorView {editSession} /> {:else if viewMode === ViewMode.Rules} <RulesView /> - {:else if viewMode === ViewMode.Leaderboard} - <Leaderboard /> {/if} </div> <div class="sidebar-right"> diff --git a/web/pw-server/src/routes/leaderboard.svelte b/web/pw-server/src/routes/leaderboard.svelte new file mode 100644 index 0000000..7c4da6e --- /dev/null +++ b/web/pw-server/src/routes/leaderboard.svelte @@ -0,0 +1,28 @@ +<script lang="ts" context="module"> + import { ApiClient } from "$lib/api_client"; + + export async function load({ fetch }) { + try { + const apiClient = new ApiClient(fetch); + const leaderboard = await apiClient.get("/api/leaderboard"); + return { + props: { + leaderboard, + }, + }; + } catch (error) { + return { + status: error.status, + error: error, + }; + } + } +</script> + +<script lang="ts"> + import Leaderboard from "$lib/components/Leaderboard.svelte"; + + export let leaderboard: object[]; +</script> + +<Leaderboard {leaderboard} /> |