14
14
</v-card >
15
15
</v-col >
16
16
17
- <v-dialog class =" popup" v-model =" dialog" >
17
+ <v-dialog id =" popup" v-model =" dialog" >
18
18
<v-card >
19
- <v-card-title >
19
+ <v-card-title id = " dishTitle " >
20
20
<span class =" headline" >{{selectedDish.title}}</span >
21
21
</v-card-title >
22
22
23
- <v-card-text >
23
+ <v-avatar size =" 200" >
24
+ <v-img :src =" recipeURL" />
25
+ </v-avatar >
26
+
27
+ <v-card-text >
24
28
<span class =" headline" >Time Cook: {{timeCook}} minutes</span >
25
29
</v-card-text >
26
30
27
- <v-btn class =" btn mb-4" raised color =" purple lighten-4" >Ingredients</v-btn >
28
- <v-spacer ></v-spacer >
29
- <v-btn raised color =" purple lighten-4" >Direction</v-btn >
30
-
31
- <v-card-text >
31
+ <v-btn class =" btn mb-4" raised color =" purple lighten-4" @click =" showIngredient=!showIngredient" >Ingredients</v-btn >
32
+ <v-card-text v-if =" showIngredient" >
32
33
<ul >
33
34
<li v-for =" item in ingredients" :key =" item.index" >{{item}}</li >
34
35
</ul >
35
36
</v-card-text >
36
37
37
- <v-card-text v-if =" instructions.length" >
38
- <p >Steps: </p >
38
+ <v-spacer ></v-spacer >
39
+ <v-btn raised color =" purple lighten-4" @click =" showInstruction=!showInstruction" >Direction</v-btn >
40
+
41
+
42
+ <v-card-text v-if =" showInstruction" >
39
43
<ol >
40
44
<li v-for =" steps in instructions" :key =" steps.number" >{{steps.step}}</li >
41
45
</ol >
42
46
</v-card-text >
43
47
44
- <v-card-text v-if =" instructionURL" >
48
+ <v-card-text v-if =" showInstruction && instructionURL" >
45
49
<a :href =" instructionURL" target =" _blank" >Recipe URL</a >
46
50
<p ></p >
47
51
</v-card-text >
54
58
</v-card-actions >
55
59
</v-card >
56
60
</v-dialog >
61
+
57
62
</v-row >
58
63
</template >
59
64
@@ -72,16 +77,15 @@ export default {
72
77
selectedDish: {},
73
78
ingredients: [],
74
79
instructionURL: " " ,
75
- timeCook: " "
80
+ timeCook: " " ,
81
+ recipeURL: " " ,
82
+ showIngredient: false ,
83
+ showInstruction: false
76
84
};
77
85
},
78
86
methods: {
79
87
getRecipeIngredients : function (id ) {
80
- this .ingredients .length = 0 ;
81
- this .instructions .length = 0 ;
82
- this .instructionURL = " " ;
83
- this .timeCook = " " ;
84
-
88
+ this .resetState ();
85
89
const url = ` ${ this .url_base } /${ id} /information?&apiKey=${ this .api_key } ` ;
86
90
fetch (url)
87
91
.then (res => res .json ())
@@ -90,15 +94,25 @@ export default {
90
94
this .ingredients .push (element .name );
91
95
});
92
96
this .timeCook = result .readyInMinutes ;
97
+ this .recipeURL = result .image ;
93
98
if (result .analyzedInstructions .length === 0 ) {
94
99
this .instructionURL = result .sourceUrl ;
95
100
} else {
96
101
this .instructions = result .analyzedInstructions [0 ].steps ;
97
102
}
98
103
});
99
104
},
105
+ resetState : function (){
106
+ this .ingredients .length = 0 ;
107
+ this .instructions .length = 0 ;
108
+ this .instructionURL = " " ;
109
+ this .timeCook = " " ;
110
+ this .showIngredient = false ;
111
+ this .showInstruction = false
112
+ },
113
+
100
114
scrollToTop () {
101
- document .getElementById (" popup " ).scrollIntoView ({
115
+ document .getElementById (" dishTitle " ).scrollIntoView ({
102
116
behavior: " smooth"
103
117
});
104
118
}
@@ -113,9 +127,11 @@ html {
113
127
.title {
114
128
align-self : start ;
115
129
text-align : center ;
116
- }
130
+ };
131
+ .dishTitle {
132
+ align-self : start ;
133
+ text-align : center ;
134
+ font-size : small ;
135
+ }
117
136
118
- .popup {
119
-
120
- }
121
137
</style >
0 commit comments