-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from vachmara/design
feat: add recipes design
- Loading branch information
Showing
6 changed files
with
229 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"title": "Exemple de recette", | ||
"preparation_time": "15 minutes", | ||
"cooking_time": "30 minutes", | ||
"people_quantity": "4 personnes", | ||
"stars": "4", | ||
"ingredients": [ | ||
{ | ||
"name": "Ingrédient 1", | ||
"quantity": "100g" | ||
}, | ||
{ | ||
"name": "Ingrédient 2", | ||
"quantity": "2 pièces" | ||
} | ||
], | ||
"instructions": [ | ||
"Préchauffez votre four à 180°C.", | ||
"Mélangez les ingrédients dans un saladier." | ||
], | ||
"notes": "Vous pouvez ajouter un assaisonnement de votre choix pour personnaliser la recette." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<div | ||
v-show="visible" | ||
class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-60" | ||
> | ||
<div class=" bg-white rounded p-4 space-y-4 overflow-auto"> | ||
<header class="border-b"> | ||
<slot name="header"></slot> | ||
</header> | ||
|
||
<main class="mb-4"> | ||
<slot name="body"></slot> | ||
</main> | ||
|
||
<footer> | ||
<button | ||
@click="close" | ||
class="py-1 px-3 text-white bg-blue-500 rounded-md hover:bg-blue-400" | ||
> | ||
Fermer | ||
</button> | ||
</footer> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
visible: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
methods: { | ||
close() { | ||
this.$emit("close"); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<template> | ||
<div class="p-3"> | ||
<div v-if="isSkeleton" class="animate-pulse p-4 border border-gray-300 rounded-lg cursor-pointer hover:border-primary"> | ||
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div> | ||
<ul> | ||
<li | ||
v-for="(ingredient, index) in recipe.ingredients" | ||
:key="index" | ||
class="list-disc list-inside" | ||
> | ||
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-4 w-1/2"></div> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<div | ||
v-else | ||
class="p-4 border border-gray-300 rounded-lg cursor-pointer hover:border-primary" | ||
:class="isDisabled ? 'opacity-50 cursor-default' : ''" | ||
@click="isDisabled ? null : openModal()" | ||
> | ||
<h2 class="text-xl font-bold">{{ recipe.title }}</h2> | ||
<ul> | ||
<li | ||
v-for="(ingredient, index) in recipe.ingredients" | ||
:key="index" | ||
class="list-disc list-inside" | ||
> | ||
{{ ingredient.name }} | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<transition name="modal-transition"> | ||
<Modal v-show="showModal" @close="closeModal"> | ||
<template v-slot:header> | ||
<h2 class="text-2xl font-bold"> | ||
{{ recipe.title }} | ||
<button | ||
type="button" | ||
class="float-right font-bold text-xl hover:text-blue-500" | ||
@click="closeModal" | ||
> | ||
× | ||
</button> | ||
</h2> | ||
</template> | ||
|
||
<template v-slot:body> | ||
<div> | ||
<h3 class="font-bold"> | ||
Préparation estimée: {{ recipe.preparation_time }} | ||
</h3> | ||
<h3 class="font-bold"> | ||
Cuisson estimée: {{ recipe.cooking_time }} | ||
</h3> | ||
<h3 class="font-bold"> | ||
Nombre de personnes: {{ recipe.people_quantity }} | ||
</h3> | ||
</div> | ||
<h3 class="font-bold">Ingrédients:</h3> | ||
<ul> | ||
<li | ||
v-for="(ingredient, index) in recipe.ingredients" | ||
:key="index" | ||
class="list-disc list-inside" | ||
> | ||
{{ ingredient.name }} - {{ ingredient.quantity }} | ||
</li> | ||
</ul> | ||
<h3 class="font-bold">Instructions:</h3> | ||
<ol> | ||
<li | ||
v-for="(instruction, index) in recipe.instructions" | ||
:key="index" | ||
class="list-decimal list-inside" | ||
> | ||
{{ instruction }} | ||
</li> | ||
</ol> | ||
<p>{{ recipe.notes }}</p> | ||
</template> | ||
</Modal> | ||
</transition> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Modal from "./Modal.vue"; | ||
export default { | ||
components: { | ||
Modal, | ||
}, | ||
props: { | ||
recipe: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
isDisabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
isSkeleton: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
showModal: false, | ||
}; | ||
}, | ||
methods: { | ||
openModal() { | ||
this.showModal = true; | ||
}, | ||
closeModal() { | ||
this.showModal = false; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.modal-transition-enter-active, | ||
.modal-transition-leave-active { | ||
transition: all 0.3s; | ||
} | ||
.modal-transition-enter-from, | ||
.modal-transition-leave-to { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
} | ||
h3 { | ||
padding: 10px 0px 10px 0px; | ||
} | ||
li::marker{ | ||
width: 15px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ export default { | |
theme: { | ||
extend: { | ||
colors: { | ||
test: "#5ce1e6", | ||
primary: "#5ce1e6", | ||
} | ||
} | ||
} | ||
|