Skip to content

Commit

Permalink
Merge branch '10_win_display' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomaht committed Dec 19, 2023
2 parents 6a26a1a + 808d25a commit 64eaf95
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 5 deletions.
6 changes: 6 additions & 0 deletions frontend-vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"axios": "^1.6.0",
"bootstrap": "^5.3.2",
"core-js": "^3.8.3",
"gsap": "^3.12.4",
"vue": "^3.2.13",
"vue-autocomplete": "^0.0.2",
"vuetify": "^3.4.7"
Expand Down
16 changes: 12 additions & 4 deletions frontend-vue/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<h1 class="montserrat">Swissdle</h1>
<p class="lato guess-text">Guess the City!</p>
<DailyCity />
<SearchInput />
<HintsDisplay/>
<SearchInput v-show="!win" />
<WinText v-show="win" />
<HintsDisplay />
</div>
</template>

Expand All @@ -15,6 +16,7 @@ import CityService from "./services/CityService";
import DailyCity from './components/DailyCity.vue'
import SearchInput from './components/SearchInput.vue';
import HintsDisplay from './components/HintsDisplay.vue';
import WinText from './components/WinText.vue';
export default {
name: 'App',
Expand All @@ -28,7 +30,8 @@ export default {
components: {
DailyCity,
SearchInput,
HintsDisplay
HintsDisplay,
WinText
},
methods: {
setDailyCity() {
Expand All @@ -52,7 +55,13 @@ export default {
}
}
},
computed: {
win() {
return CityService.getWin() ? CityService.getWin() : false;
},
},
mounted() {
CityService.setWin(false);
this.setDailyCity();
this.setCities();
}
Expand All @@ -78,5 +87,4 @@ h1 {
.guess-text {
font-style: italic;
}
</style>
5 changes: 4 additions & 1 deletion frontend-vue/src/components/SearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export default {
try {
axios.get(this.apiBaseUrl + this.apiGetGuess + cityId).then((response) => {
(CityService.addGuesses(response.data))
(
CityService.addGuesses(response.data),
CityService.getDailyCity().id == response.data.city.id ? CityService.setWin(true) : ""
)
})
} catch (err) {
alert(err);
Expand Down
43 changes: 43 additions & 0 deletions frontend-vue/src/components/WinText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<div id="win-text-container">
<p class="montserrat" ref="winText">Good guess ! Well Done !</p>
</div>
</template>
<script>
import { TweenMax, Power1 } from "gsap";
export default {
name: "WinText",
data() {
return {
winText: null,
};
},
methods: {
animateText() {
TweenMax.to(this.winText, 1, {
y: 10,
ease: Power1.easeInOut,
yoyo: true,
repeat: -1,
});
},
},
mounted() {
this.winText = this.$refs.winText;
this.animateText();
}
}
</script>
<style scoped>
#win-text-container {
padding-top: 20px;
}
p {
margin: 0;
font-size: 24px;
color: #83D881;
}
</style>
9 changes: 9 additions & 0 deletions frontend-vue/src/services/CityService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const CityService = {
dailyCity: ref(null),
cities: ref(null),
guesses: ref([]),
win: ref(Boolean),

setDailyCity(city) {
this.dailyCity.value = city;
},

setWin(win) {
this.win.value = win;
},

setCities(cities) {
this.cities.value = cities;
},
Expand All @@ -33,6 +38,10 @@ const CityService = {
return this.dailyCity.value;
},

getWin() {
return this.win.value;
},

getCities() {
return this.cities.value;
},
Expand Down

0 comments on commit 64eaf95

Please sign in to comment.