feat(client): Card

parent 0eb3d339
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<HelloWorld /> <HelloWorld />
<Sockets/> <Sockets/>
<div id="game"> <div id="game">
<Card value="ace" color="hearts"/>
<label for="messages"> Choose a message:</label> <label for="messages"> Choose a message:</label>
<select v-model="message" name="message" id="messages"> <select v-model="message" name="message" id="messages">
<option value="WAITING">J'attends</option> <option value="WAITING">J'attends</option>
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
import VueSocketIO from 'vue-socket.io' import VueSocketIO from 'vue-socket.io'
import Vuex, {mapGetters, mapMutations} from 'vuex'; import Vuex, {mapGetters, mapMutations} from 'vuex';
import HelloWorld from "./components/HelloWorld"; import HelloWorld from "./components/HelloWorld";
import Card from "./components/Card";
import Sockets from "./Sockets"; import Sockets from "./Sockets";
import {store} from './vuex-store' import {store} from './vuex-store'
...@@ -44,7 +46,8 @@ ...@@ -44,7 +46,8 @@
store: store, store: store,
components: { components: {
HelloWorld, HelloWorld,
Sockets Sockets,
Card
}, },
data: function () { data: function () {
return { return {
......
<template>
<div class="card">
<img class="card-pic" v-bind:src="imageSrc()">
<p>{{ text() }}</p>
</div>
</template>
<script>
export default {
name: "Card",
props: {
value: String,
color: String,
},
methods: {
imageSrc() {
return `/img/${this.value}_of_${this.color}.png`
},
text: function () {
// Translate
let valueText = {
"2": "Deux",
"3": "Trois",
"4": "Quatre",
"5": "Cinq",
"6": "Six",
"7": "Sept",
"8": "Huit",
"9": "Neuf",
"10": "Dix",
"jack": "Valet",
"queen": "Dame",
"king": "Roi",
"ace": "As"
}[this.value];
let colorText = {
"hearts": "Coeur",
"spades": "Pique",
"clubs": "Trèfle",
"diamonds": "Carreau"
}[this.color];
// Capitalize
valueText = valueText.charAt(0).toUpperCase() + valueText.slice(1);
colorText = colorText.charAt(0).toUpperCase() + colorText.slice(1);
return `${valueText} de ${colorText}`
}
}
}
</script>
<style scoped>
.card-pic {
max-width: 150px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment