Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Display food information in the new meal page 🚀
Browse files Browse the repository at this point in the history
Display the information about a food
  • Loading branch information
Kayoshi-dev authored May 16, 2020
2 parents 8f518b6 + 5b1f71b commit 6c8bba4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
Binary file added assets/fonts/Gilroy-Light.woff
Binary file not shown.
20 changes: 18 additions & 2 deletions assets/scss/newMeal.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@import "variables";

@font-face {
font-family: Gilroy-Light;
src: url("../fonts/Gilroy-Light.woff");
}

.food-card {
.img-thumb {
position: relative;
Expand Down Expand Up @@ -139,12 +144,23 @@
}

.modal-container {
width: 300px;
position: relative;
width: 500px;
margin: 0 auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
transition: all 0.3s ease;
font-family: Helvetica, Arial, sans-serif;

.modal-close {
position: absolute;
right: -20px;
top: -20px;
font-size: 30px;
}
}

.modal-main {
font-family: Gilroy-Light, serif;
}
19 changes: 12 additions & 7 deletions assets/vue/views/newMeal/Food.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<template>
<div class="col-md-3 food-card">
<div class="img-thumb">
<img class="img-fluid" v-bind:src="path + data.picture" v-bind:alt="data.title" :class="{'selected': this.$parent.activeChoice === data.id}" @click="setActive(data.id, data.title, data.picture)">
<span @click="showInformation(data.id)"><i class="fas fa-info"></i></span>
<FoodInfoModal :id="data.id" v-if="showModal === true"/>
<transition name="modal">
<div class="col-md-3 food-card">
<div class="img-thumb">
<img class="img-fluid" v-bind:src="path + data.picture" v-bind:alt="data.title" :class="{'selected': this.$parent.activeChoice === data.id}" @click="setActive(data.id, data.title, data.picture)">
<span @click="showInformation(data.id)"><i class="fas fa-info"></i></span>
<FoodInfoModal :showModal="showModal" :food="data" v-if="showModal"/>
</div>
<h5>{{data.title}}</h5>
</div>
<h5>{{data.title}}</h5>
</div>
</transition>
</template>

<script>
Expand All @@ -31,6 +33,9 @@
// Appel le composant parent, nous avons besoin que l'aliment selectionné soit lié au nouveau repas, pas à lui même
this.$parent.setActive(index);
this.$parent.setTemporaryData(title, picture);
},
hideInformation() {
this.showModal = false;
}
}
}
Expand Down
30 changes: 11 additions & 19 deletions assets/vue/views/newMeal/FoodInfoModal.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
<template>
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container" v-if="info">
// TODO
<div class="modal-container">
<div class="modal-head border-bottom mb-2">
<h5>{{food.title}}</h5>
<span @click="hideModal" class="modal-close">&times;</span>
</div>
<div class="modal-main">
{{food.information ? food.information : "Il n'y a pas d'informations concernant cet aliment"}}
</div>
</div>
</div>
</div>
</template>

<script>
import axios from "axios";
export default {
name: "FoodInfoModal",
props: ['id'],
mounted() {
this.fetchInfo(this.id);
},
data: function() {
return {
info: {}
}
},
props: ['food'],
methods: {
fetchInfo: function (id) {
axios.get(`/api/food/${id}`)
.then(response => this.info = response.data['hydra:member'])
.catch(function() {
console.log('Erreur dans le chargement!');
});
hideModal() {
this.$parent.hideInformation();
}
}
}
Expand Down

0 comments on commit 6c8bba4

Please sign in to comment.