add bot selection on demo page

This commit is contained in:
Ilion Beyst 2022-03-03 21:38:49 +01:00
parent b70328227e
commit a8986d7a28
2 changed files with 41 additions and 5 deletions

View file

@ -1,5 +1,25 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher } from "svelte"; import { createEventDispatcher, onMount } from "svelte";
import Select from "svelte-select";
let availableBots: object[] = [];
let selectedOpponent = "simplebot";
const optionIdentifier = "name";
const labelIdentifier = "name";
onMount(async () => {
const res = await fetch("/api/bots", {
headers: {
"Content-Type": "application/json",
},
});
if (res.ok) {
availableBots = await res.json();
console.log(availableBots);
}
});
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -9,13 +29,28 @@
</script> </script>
<div class="submit-pane"> <div class="submit-pane">
Submit your bot to play a match <div class="match-form">
<button class="play-button" on:click={submit}>Submit</button> <div class="play-text">Select an opponent to test your bot</div>
<div class="opponentSelect">
<Select
optionIdentifier="name"
labelIdentifier="name"
items={availableBots}
bind:value={selectedOpponent}
/>
</div>
<button class="play-button" on:click={submit}>Play</button>
</div>
</div> </div>
<style lang="scss"> <style lang="scss">
.submit-pane { .submit-pane {
margin: 20px auto; margin: 20px;
flex: 1;
}
.opponentSelect {
margin: 20px 0;
} }
.play-button { .play-button {
@ -24,7 +59,7 @@
border: 0; border: 0;
font-size: 18pt; font-size: 18pt;
display: block; display: block;
margin: 20px auto; margin: 10px auto;
background-color: lightgreen; background-color: lightgreen;
cursor: pointer; cursor: pointer;
} }

View file

@ -207,6 +207,7 @@
border-left: 1px solid; border-left: 1px solid;
padding: 0; padding: 0;
display: flex; display: flex;
overflow: hidden;
} }
.editor-container { .editor-container {
flex-grow: 1; flex-grow: 1;