workadventure/front/src/Components/Menu/MenuIcon.svelte
2021-12-04 15:36:11 +01:00

60 lines
1.5 KiB
Svelte

<script lang="typescript">
import logoWA from "../images/logo-WA-pixel.png"
import logoTalk from "../images/logo-message-pixel.png"
import {menuVisiblilityStore} from "../../Stores/MenuStore";
import {chatVisibilityStore} from "../../Stores/ChatStore";
import {userWokaPictureStore} from "../../Stores/UserWokaPictureStore";
import {get} from "svelte/store";
import {onDestroy} from "svelte";
function showMenu(){
menuVisiblilityStore.set(!get(menuVisiblilityStore))
}
function showChat(){
chatVisibilityStore.set(true);
}
let heroWokaPictureSrc = logoWA;
const unsubscribeFromUserWokaPictureStore = userWokaPictureStore.subscribe(playersAvatars => {
heroWokaPictureSrc = playersAvatars.get(-1) ?? logoWA;
});
onDestroy(unsubscribeFromUserWokaPictureStore);
</script>
<svelte:window/>
<main class="menuIcon">
<img src={heroWokaPictureSrc} alt="open menu" class="nes-pointer" on:click|preventDefault={showMenu}>
<img src={logoTalk} alt="open menu" class="nes-pointer" on:click|preventDefault={showChat}>
</main>
<style lang="scss">
.menuIcon {
display: inline-grid;
z-index: 90;
position: relative;
margin: 25px;
img {
pointer-events: auto;
width: 60px;
padding-top: 0;
margin: 3px
}
}
.menuIcon img:hover{
transform: scale(1.2);
}
@media only screen and (max-width: 800px), only screen and (max-height: 800px) {
.menuIcon {
margin: 3px;
img {
width: 50px;
}
}
}
</style>