Add follow button to ui, improved flow

This commit is contained in:
Lurkars
2021-12-19 12:51:19 +01:00
committed by PizZaKatZe
parent 2cd088c049
commit 3916d9c58e
5 changed files with 51 additions and 2 deletions
@@ -6,6 +6,7 @@ vim: ft=typescript
import type { Unsubscriber } from "svelte/store";
import { get } from "svelte/store";
import { gameManager } from "../../Phaser/Game/GameManager";
import followImg from "../images/follow.svg";
import {
followStateStore,
@@ -76,6 +77,11 @@ vim: ft=typescript
followUsersStore.set([]);
}
function request() {
followStateStore.set(followStates.requesting);
followRoleStore.set(followRoles.leader);
}
function onKeyDown(e: KeyboardEvent) {
if (e.key === "Escape") {
reset();
@@ -152,6 +158,33 @@ vim: ft=typescript
</div>
{/if}
{#if followRole === followRoles.open}
<button
type="button"
class="nes-btn is-primary follow-menu-button"
on:click|preventDefault={request}
title="Ask others to follow"><img class="background-img" src={followImg} alt="" /></button
>
{/if}
{#if followState === followStates.active || followState === followStates.ending}
{#if followRole === followRoles.follower}
<button
type="button"
class="nes-btn is-error follow-menu-button"
on:click|preventDefault={reset}
title="Stop following"><img class="background-img" src={followImg} alt="" /></button
>
{:else if followUsers.length > 0}
<button
type="button"
class="nes-btn is-error follow-menu-button"
on:click|preventDefault={reset}
title="Stop leading the way"><img class="background-img" src={followImg} alt="" /></button
>
{/if}
{/if}
<style lang="scss">
.nes-container {
padding: 5px;
@@ -212,6 +245,13 @@ vim: ft=typescript
}
}
.follow-menu-button {
position: absolute;
bottom: 10px;
left: 10px;
pointer-events: all;
}
@media only screen and (max-width: 800px) {
div.interact-status {
width: 100vw;