Icons and more displaying.

This commit is contained in:
aminecmi
2021-10-30 21:31:14 +02:00
parent 0f2f09d530
commit 08b3cd4056
6 changed files with 87 additions and 7 deletions

View File

@@ -1,10 +1,17 @@
<template>
<div class="card" v-bind:class="{ red: isRed }">{{card.number}} of {{card.shape}}</div>
<div class="card" v-bind:class="{ red: isRed }">
<div class="icon">
<Shape v-bind:shape="card.shape"/>
</div>
<span> {{card.number}}</span>
</div>
</template>
<script>
import Shape from "@/components/Shape";
export default {
name: "Card",
components: {Shape},
props: ['card'],
computed: {
isRed: function () {
@@ -24,6 +31,7 @@ export default {
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.card.red {
@@ -36,4 +44,10 @@ export default {
color: #FCFBFB;
}
.icon {
position: absolute;
top: 10px;
right: 10px;
}
</style>

26
src/components/Shape.vue Normal file
View File

@@ -0,0 +1,26 @@
<template>
<span v-bind:class="{ red: isRed }">
<font-awesome-icon v-if="shape == 'DIAMONDS'" icon="gem" size="lg" />
<font-awesome-icon v-if="shape == 'CLUBS'" icon="spa" size="lg" />
<font-awesome-icon v-if="shape == 'HEARTS'" icon="heartbeat" size="lg" />
<font-awesome-icon v-if="shape == 'SPADES'" icon="leaf" size="lg" />
</span>
</template>
<script>
export default {
name: "Shape",
props: ['shape'],
computed: {
isRed: function () {
return this.shape == "DIAMONDS" || this.shape === "HEARTS";
}
}
}
</script>
<style scoped>
.red {
color: #FF7474;
}
</style>

View File

@@ -1,7 +1,7 @@
<template>
<div>
<h1>Table</h1>
<button v-on:click="reset()">RESET</button>
<h1>Table <button v-on:click="reset()">Reset</button></h1>
<button v-on:click="initHand()">Tirer des cartes</button>
<div v-if="cards != null && cards.length > 0">
<h2>Cartes</h2>
@@ -10,8 +10,8 @@
</div>
<div v-if="sortResult != null">
<h2>Cartes Triées</h2>
<h3><em>Shape order : {{sortResult.shapeOrder}}</em></h3>
<h3><em>Number order : {{sortResult.numberOrder}}</em></h3>
<h3><em>Shape order : <Shape class="shape" v-bind:shape="shape" v-for="shape in sortResult.shapeOrder" v-bind:key="shape"/></em></h3>
<h3><em>Number order : <span class="number" v-for="n in sortResult.numberOrder" v-bind:key="n">{{n}}</span></em></h3>
<Deck v-bind:cards="sortResult.sortedCards"></Deck>
</div>
</div>
@@ -20,11 +20,12 @@
<script>
import {getHand, sortHand, resetDeck} from '../services/DeckService'
import Deck from "@/components/Deck";
import Shape from "@/components/Shape";
export default {
name: "Table",
components: {Deck},
components: {Shape, Deck},
data() {
return {
cards: [],
@@ -58,5 +59,7 @@ export default {
</script>
<style scoped>
.shape, .number {
margin-right: 10px;
}
</style>

View File

@@ -1,5 +1,15 @@
import Vue from 'vue'
import App from './App.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faGem, faSpa, faHeartbeat, faLeaf } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faGem)
library.add(faSpa)
library.add(faHeartbeat)
library.add(faLeaf)
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.config.productionTip = false