add favourising and start icon
This commit is contained in:
parent
cdca730448
commit
df992c0c29
@ -22,14 +22,18 @@
|
|||||||
Shake your phone <br />
|
Shake your phone <br />
|
||||||
to get a Cocktail
|
to get a Cocktail
|
||||||
</h1>
|
</h1>
|
||||||
<ion-button color="success" expand="block" @click="doShake()"
|
|
||||||
>Start shaking</ion-button
|
|
||||||
>
|
|
||||||
<ion-img
|
<ion-img
|
||||||
class="image-icon"
|
class="start-icon"
|
||||||
:src="`${publicPath}img/glasses/Martini.svg`"
|
:src="`${publicPath}img/icon.png`"
|
||||||
alt="CocktailShaker"
|
alt="CocktailShaker"
|
||||||
></ion-img>
|
></ion-img>
|
||||||
|
<ion-button
|
||||||
|
size="large"
|
||||||
|
color="success"
|
||||||
|
expand="block"
|
||||||
|
@click="doShake()"
|
||||||
|
>Start shaking</ion-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Show cocktail -->
|
<!-- Show cocktail -->
|
||||||
@ -80,10 +84,28 @@
|
|||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
<!--Take Photo -->
|
<!--Take Photo -->
|
||||||
<ion-button color="secondary" @click="takePhoto(chosenCocktail)">
|
<ion-button color="secondary" @click="takePhoto(chosenCocktail)">
|
||||||
<ion-icon :icon="camera"></ion-icon>
|
<ion-icon :icon="camera" slot="icon-only"></ion-icon>
|
||||||
|
</ion-button>
|
||||||
|
<!--Favourise Cocktail -->
|
||||||
|
<ion-button
|
||||||
|
color="success"
|
||||||
|
@click="doFavouriseCocktail(chosenCocktail)"
|
||||||
|
>
|
||||||
|
<ion-icon
|
||||||
|
v-if="chosenCocktail.favourite == true"
|
||||||
|
slot="icon-only"
|
||||||
|
:icon="star"
|
||||||
|
class="icon-star-true"
|
||||||
|
></ion-icon>
|
||||||
|
<ion-icon
|
||||||
|
v-else
|
||||||
|
slot="icon-only"
|
||||||
|
:icon="star"
|
||||||
|
class="icon-star-false"
|
||||||
|
></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
<!--Next Cocktail-->
|
<!--Next Cocktail-->
|
||||||
<ion-button color="success" @click="doShake()"
|
<ion-button color="primary" @click="doShake()"
|
||||||
>Shake again</ion-button
|
>Shake again</ion-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
@ -109,7 +131,7 @@ import {
|
|||||||
IonButton,
|
IonButton,
|
||||||
IonImg,
|
IonImg,
|
||||||
} from "@ionic/vue";
|
} from "@ionic/vue";
|
||||||
import { camera } from "ionicons/icons";
|
import { camera, star } from "ionicons/icons";
|
||||||
export default {
|
export default {
|
||||||
name: "Shake",
|
name: "Shake",
|
||||||
components: {
|
components: {
|
||||||
@ -137,10 +159,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
doShake: function () {
|
doShake: function () {
|
||||||
const {fetchRandomCocktail} = useStorage();
|
const { fetchRandomCocktail } = useStorage();
|
||||||
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
||||||
if(Math.random() > 0.8){
|
if (Math.random() > 0.8) {
|
||||||
fetchRandomCocktail();
|
fetchRandomCocktail();
|
||||||
}
|
}
|
||||||
this.chosenCocktail =
|
this.chosenCocktail =
|
||||||
this.cocktails[Math.floor(Math.random() * this.cocktails.length)];
|
this.cocktails[Math.floor(Math.random() * this.cocktails.length)];
|
||||||
@ -148,11 +170,17 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const { takePhoto } = useStorage();
|
const { takePhoto, favouriseCocktail } = useStorage();
|
||||||
|
|
||||||
|
const doFavouriseCocktail = async (cocktail) => {
|
||||||
|
favouriseCocktail(cocktail);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
camera,
|
doFavouriseCocktail,
|
||||||
takePhoto,
|
takePhoto,
|
||||||
|
camera,
|
||||||
|
star,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -203,4 +231,16 @@ ion-img.bigimage {
|
|||||||
ion-button {
|
ion-button {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
.icon-star-false {
|
||||||
|
color: rgb(0, 0, 0);
|
||||||
|
}
|
||||||
|
.icon-star-true {
|
||||||
|
color: rgb(255, 238, 0);
|
||||||
|
}
|
||||||
|
.start-icon{
|
||||||
|
margin: auto;
|
||||||
|
max-width: 80%;
|
||||||
|
height: auto;
|
||||||
|
border-radius: 5%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user