Skip to content

Commit 4023367

Browse files
committed
browsing page
1 parent 77b7a34 commit 4023367

File tree

10 files changed

+138
-2
lines changed

10 files changed

+138
-2
lines changed
130 KB
Loading
128 KB
Loading
147 KB
Loading
142 KB
Loading
104 KB
Loading
11.4 KB
Loading
4.71 KB
Loading
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<template>
2+
<!-- eslint-disable max-len -->
3+
<div v-bind:class="{
4+
'card': true,
5+
'flex w-full': true,
6+
'ml-1': true,
7+
'flex-col': true,
8+
'justify-end items-start': true,
9+
'shadow-inner': true,
10+
'recommendation-card': true,
11+
'rounded-md': true,
12+
'mb-2': true,
13+
'ml-2': index % 2 === 0}"
14+
v-bind:style="{
15+
'background-repeat': 'no-repeat',
16+
'background-position': 'center center',
17+
'background-size' :'cover',
18+
'background-image': 'url(' + getPrimaryImage() + ')'}">
19+
<div class="p-8 text-white">
20+
<div class="flex items-center">
21+
<img v-if="this.recommendation.is_online" class="w-3 h-3" src="../../../assets/recommendations/online.png">
22+
<img v-else class="w-3 h-3" src="../../../assets/recommendations/offline.png">
23+
<h1 v-if="this.recommendation.is_online" class="text-lg ml-2 leading-none">online</h1>
24+
<h1 v-else class="text-lg ml-2 leading-none">offline</h1>
25+
</div>
26+
<div class="flex items-end my-2">
27+
<h1 class="text-4xl font-bold leading-none">{{this.recommendation.first_name}}</h1>
28+
<h1 class="text-2xl ml-2 leading-none mb-1">24</h1>
29+
</div>
30+
<h1 class="text-lg">{{getDistance()}}km away</h1>
31+
</div>
32+
</div>
33+
</template>
34+
35+
<script>
36+
/* eslint-disable no-else-return */
37+
38+
export default {
39+
props: ['recommendation', 'index'],
40+
methods: {
41+
getPrimaryImage() {
42+
const userImages = this.recommendation.images;
43+
let imageForShowcase;
44+
for (let i = 0; i < userImages.length; i += 1) {
45+
if (userImages[i].is_primary) {
46+
imageForShowcase = userImages[i].link;
47+
} else if (!userImages[i].is_primary && !imageForShowcase) {
48+
imageForShowcase = userImages[i].link;
49+
}
50+
}
51+
console.log(imageForShowcase);
52+
if (imageForShowcase) {
53+
return imageForShowcase;
54+
}
55+
if (this.recommendation.gender === 'male') {
56+
const number = Math.floor(Math.random() * 11);
57+
if (number % 2 === 0) {
58+
return '../../../assets/recommendations/avatars/man1.png';
59+
}
60+
return '../../../assets/recommendations/avatars/man2.png';
61+
} else if (this.recommendation.gender === 'female') {
62+
const number = Math.floor(Math.random() * 11);
63+
if (number % 2 === 0) {
64+
return '../../../assets/recommendations/avatars/woman1.png';
65+
}
66+
return '../../../assets/recommendations/avatars/woman2.png';
67+
}
68+
return '../../../assets/recommendations/avatars/other.png';
69+
},
70+
getDistance() {
71+
return Math.floor(this.recommendation.distance);
72+
},
73+
},
74+
created() {
75+
console.log(this.index);
76+
},
77+
};
78+
</script>
79+
80+
<style scoped>
81+
.recommendation-card {
82+
/*width: 24rem;*/
83+
height: 32rem;
84+
box-shadow: inset 0 -8rem 1rem rgba(0, 0, 0, 0.3);
85+
}
86+
@screen md {
87+
.card {
88+
width: 48%;
89+
}
90+
}
91+
</style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<!-- eslint-disable max-len -->
3+
<section>
4+
<h1 class="text-5xl mb-4 text-center sm:text-left onboarding-sub-container-content-heading">{{title}}</h1>
5+
<div class="flex flex-wrap items-center justify-start">
6+
<RecommendationCard
7+
v-for="(recommendation, index) in recommendations" :key="index"
8+
v-bind:recommendation="recommendation" v-bind:index="index + 1"></RecommendationCard>
9+
</div>
10+
</section>
11+
</template>
12+
13+
<script>
14+
import RecommendationCard from '@/components/app/recommendations/RecommendationCard.vue';
15+
16+
export default {
17+
components: {
18+
RecommendationCard,
19+
},
20+
props: ['title', 'recommendations'],
21+
};
22+
</script>

frontend/src/views/app/Browse.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
<template>
22
<!-- eslint-disable max-len -->
3-
<div>
4-
<h1>browse</h1>
3+
<div class="mx-4 sm:mx-32">
4+
<NavBar v-bind:currentRoute="'Browse'"></NavBar>
5+
<section class="mx-auto">
6+
<Recommendations
7+
v-bind:title="'Potential matches'"
8+
v-bind:recommendations="recommendations"></Recommendations>
9+
</section>
510
</div>
611
</template>
712

813
<script>
14+
import NavBar from '@/components/shared/NavBar.vue';
15+
import Recommendations from '@/components/app/recommendations/Recommendations.vue';
916
1017
export default {
18+
props: ['recommendationsFromSettingUp'],
19+
components: {
20+
NavBar,
21+
Recommendations,
22+
},
23+
data: () => ({
24+
recommendations: [],
25+
}),
26+
async created() {
27+
if (this.recommendationsFromSettingUp) {
28+
this.recommendations = this.recommendationsFromSettingUp;
29+
} else {
30+
const recommendationsRequest = await this.$http.get('/recommendations');
31+
this.recommendations = recommendationsRequest.data.recommendations;
32+
}
33+
},
1134
};
1235
1336
</script>

0 commit comments

Comments
 (0)