adds simple global state, adds dropdown to switch players

This commit is contained in:
2019-06-11 22:08:53 +02:00
parent 4454bd245c
commit feef8146d2
3 changed files with 84 additions and 31 deletions

View File

@@ -3,19 +3,7 @@
<section id="content" class="columns is-desktop"> <section id="content" class="columns is-desktop">
<Player></Player> <Player></Player>
<div class="column"> <div class="column">
<section id="main" class="columns"> <GroupChest></GroupChest>
<div class="column">
<div id="main-heading" class="columns is-mobile is-vcentered">
<div class="column is-narrow">
<span class="icon is-large"><i class="fas fa-3x fa-gem"></i></span>
</div>
<div class="column has-text-left">
<h1 class="title">Coffre de groupe</h1>
</div>
</div>
<Chest player_id="0"></Chest>
</div>
</section>
</div> </div>
</section> </section>
</main> </main>
@@ -23,14 +11,30 @@
<script> <script>
import Player from './components/Player.vue' import Player from './components/Player.vue'
import Chest from './components/Chest.vue' import GroupChest from './components/GroupChest.vue'
import 'bulma/css/bulma.css' import 'bulma/css/bulma.css'
export const store = {
debug: true,
state: {
player_id: 0,
show_player_chest: false,
},
setActivePlayer (newPlayerId) {
if (this.debug) console.log('setActivePlayer to ', newPlayerId)
this.state.player_id = newPlayerId
},
switchPlayerChestVisibility () {
if (this.debug) console.log('switchPlayerChestVisibility', !this.state.show_player_chest)
this.state.show_player_chest = !this.state.show_player_chest
}
}
export default { export default {
name: 'app', name: 'app',
components: { components: {
Player, Player,
Chest GroupChest
} }
} }
</script> </script>

View File

@@ -0,0 +1,22 @@
<template>
<section id="main" class="section">
<div id="main-heading" class="columns is-mobile is-vcentered">
<div class="column is-narrow">
<span class="icon is-large"><i class="fas fa-3x fa-gem"></i></span>
</div>
<div class="column has-text-left">
<h1 class="title">Coffre de groupe</h1>
</div>
</div>
<Chest player_id="0"></Chest>
</section>
</template>
<script>
import Chest from './Chest.vue'
export default {
components: { Chest },
data () { return {}; }
}
</script>

View File

@@ -2,12 +2,26 @@
<div class="column is-one-third-desktop"> <div class="column is-one-third-desktop">
<div id="sidebar" class="card"> <div id="sidebar" class="card">
<header id="sidebar-heading" class="card-header"> <header id="sidebar-heading" class="card-header">
<a id="change_player" class="card-header-icon is-dark"> <p class="card-header-title">{{ player.name }}</p>
<div class="dropdown is-right"
:class="{ 'is-active': show_dropdown }">
<div class="dropdown-trigger">
<a id="change_player" class="button is-outlined is-primary"
@click="show_dropdown = !show_dropdown"
aria-haspopup="true" aria-controls="dropdown-menu">
<span class="icon is-small"> <span class="icon is-small">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
</span> </span>
</a> </a>
<p id="active_player" class="card-header-title">{{ name }}</p> </div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a href="#" class="dropdown-item">Féfi</a>
<a href="#" class="dropdown-item">Lomion</a>
<a href="#" class="dropdown-item">Oilossë</a>
</div>
</div>
</div>
</header> </header>
<div class="card-content"> <div class="card-content">
<span class="icon is-large"> <span class="icon is-large">
@@ -15,25 +29,26 @@
</span> </span>
<nav class="level is-mobile"> <nav class="level is-mobile">
<div class="level-item"> <div class="level-item">
<div><p class="heading">CP</p><p class="subtitle">{{ wealth[0] }}</p></div> <div><p class="heading">CP</p><p class="subtitle">{{ player.wealth[0] }}</p></div>
</div> </div>
<div class="level-item"> <div class="level-item">
<div><p class="heading">SP</p><p class="subtitle">{{ wealth[1] }}</p></div> <div><p class="heading">SP</p><p class="subtitle">{{ player.wealth[1] }}</p></div>
</div> </div>
<div class="level-item"> <div class="level-item">
<div><p class="heading">GP</p><p class="subtitle">{{ wealth[2] }}</p></div> <div><p class="heading">GP</p><p class="subtitle">{{ player.wealth[2] }}</p></div>
</div> </div>
<div class="level-item"> <div class="level-item">
<div><p class="heading">PP</p><p class="subtitle">{{ wealth[3] }}</p></div> <div><p class="heading">PP</p><p class="subtitle">{{ player.wealth[3] }}</p></div>
</div> </div>
</nav> </nav>
</div> </div>
<footer class="card-footer"> <footer class="card-footer">
<a @click="showChest = !showChest" href="#" class="card-footer-item is-dark">Coffre</a> <a @click="switchPlayerChestVisibility" href="#" class="card-footer-item is-dark">Coffre</a>
<a href="#" class="card-footer-item">Argent</a> <a href="#" class="card-footer-item">Argent</a>
<a href="#" class="card-footer-item disabled">Historique</a>
</footer> </footer>
</div> </div>
<div class="card" v-show="showChest" style="margin-top: 1em;"> <div class="card" v-show="app_state.show_player_chest" style="margin-top: 1em;">
<div class="card-content"> <div class="card-content">
<Chest player_id="0"></Chest> <Chest player_id="0"></Chest>
</div> </div>
@@ -42,6 +57,7 @@
</template> </template>
<script> <script>
import { store } from '../App.vue'
import Chest from './Chest.vue' import Chest from './Chest.vue'
/* /*
@@ -54,11 +70,22 @@
components: { Chest }, components: { Chest },
data () { data () {
return { return {
app_state: store.state,
player: {
name: "Player name", name: "Player name",
wealth: [1000,100,10,1], wealth: [1000,100,10,1],
showChest: false, },
show_dropdown: false,
}; };
},
methods: {
switchPlayerChestVisibility () {
store.switchPlayerChestVisibility()
},
closeDropdown () {
this.show_dropdown = false
} }
},
} }
</script> </script>