add explicit ViewMode enum
This commit is contained in:
parent
ae2a9f1eb1
commit
6929a803da
1 changed files with 15 additions and 6 deletions
|
@ -14,8 +14,14 @@
|
||||||
import SubmitPane from "$lib/components/SubmitPane.svelte";
|
import SubmitPane from "$lib/components/SubmitPane.svelte";
|
||||||
import OutputPane from "$lib/components/OutputPane.svelte";
|
import OutputPane from "$lib/components/OutputPane.svelte";
|
||||||
|
|
||||||
|
enum ViewMode {
|
||||||
|
Editor,
|
||||||
|
MatchVisualizer,
|
||||||
|
}
|
||||||
|
|
||||||
let matches = [];
|
let matches = [];
|
||||||
|
|
||||||
|
let viewMode = ViewMode.Editor;
|
||||||
let selectedMatchId: string | undefined = undefined;
|
let selectedMatchId: string | undefined = undefined;
|
||||||
let selectedMatchLog: string | undefined = undefined;
|
let selectedMatchLog: string | undefined = undefined;
|
||||||
|
|
||||||
|
@ -49,6 +55,8 @@
|
||||||
selectedMatchId = matchId;
|
selectedMatchId = matchId;
|
||||||
selectedMatchLog = null;
|
selectedMatchLog = null;
|
||||||
fetchSelectedMatchLog(matchId);
|
fetchSelectedMatchLog(matchId);
|
||||||
|
|
||||||
|
viewMode = ViewMode.MatchVisualizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSelectedMatchLog(matchId: string) {
|
async function fetchSelectedMatchLog(matchId: string) {
|
||||||
|
@ -102,10 +110,11 @@
|
||||||
function selectEditor() {
|
function selectEditor() {
|
||||||
selectedMatchId = undefined;
|
selectedMatchId = undefined;
|
||||||
selectedMatchLog = undefined;
|
selectedMatchLog = undefined;
|
||||||
|
viewMode = ViewMode.Editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatMatchTimestamp(timestampString: string): string {
|
function formatMatchTimestamp(timestampString: string): string {
|
||||||
let timestamp = DateTime.fromISO(timestampString, { zone: 'utc' }).toLocal();
|
let timestamp = DateTime.fromISO(timestampString, { zone: "utc" }).toLocal();
|
||||||
if (timestamp.startOf("day").equals(DateTime.now().startOf("day"))) {
|
if (timestamp.startOf("day").equals(DateTime.now().startOf("day"))) {
|
||||||
return timestamp.toFormat("HH:mm");
|
return timestamp.toFormat("HH:mm");
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,7 +129,7 @@
|
||||||
<div class="sidebar-left">
|
<div class="sidebar-left">
|
||||||
<div
|
<div
|
||||||
class="editor-button sidebar-item"
|
class="editor-button sidebar-item"
|
||||||
class:selected={selectedMatchId === undefined}
|
class:selected={viewMode === ViewMode.Editor}
|
||||||
on:click={selectEditor}
|
on:click={selectEditor}
|
||||||
>
|
>
|
||||||
Editor
|
Editor
|
||||||
|
@ -143,16 +152,16 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="editor-container">
|
<div class="editor-container">
|
||||||
{#if selectedMatchId}
|
{#if viewMode === ViewMode.MatchVisualizer}
|
||||||
<Visualizer matchLog={selectedMatchLog} />
|
<Visualizer matchLog={selectedMatchLog} />
|
||||||
{:else}
|
{:else if viewMode === ViewMode.Editor}
|
||||||
<EditorView {editSession} />
|
<EditorView {editSession} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-right">
|
<div class="sidebar-right">
|
||||||
{#if selectedMatchId}
|
{#if viewMode === ViewMode.MatchVisualizer}
|
||||||
<OutputPane matchLog={selectedMatchLog} />
|
<OutputPane matchLog={selectedMatchLog} />
|
||||||
{:else}
|
{:else if viewMode === ViewMode.Editor}
|
||||||
<SubmitPane {editSession} on:matchCreated={onMatchCreated} />
|
<SubmitPane {editSession} on:matchCreated={onMatchCreated} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue