Skip to content

Commit 99533de

Browse files
committed
scroll up button browse, search, history
1 parent 0964f30 commit 99533de

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<template>
2+
<!-- eslint-disable max-len -->
3+
<button v-if="showScroll"
4+
class="z-10 fixed text-2xl text-white-matcha font-bold bottom-0 mx-auto ml-4 sm:ml-8 mb-8 w-12 h-12 rounded-full bg-purple-matcha"
5+
v-on:click="scrollUp()">
6+
↑</button>
7+
</template>
8+
9+
<script>
10+
export default {
11+
data: () => ({
12+
showScroll: false,
13+
}),
14+
methods: {
15+
scrollUp() {
16+
window.scrollTo({
17+
top: 0,
18+
behavior: 'smooth',
19+
});
20+
},
21+
handleScroll() {
22+
this.showScroll = window.scrollY > window.screen.height;
23+
},
24+
},
25+
created() {
26+
window.addEventListener('scroll', this.handleScroll);
27+
},
28+
destroyed() {
29+
window.removeEventListener('scroll', this.handleScroll);
30+
},
31+
};
32+
</script>

frontend/src/views/app/Browse.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
v-bind:recommendationsReceived="recommendations"
1414
v-bind:recommendationsAnalysis="recommendationsAnalysis"></Recommendations>
1515
<div id="invisibleFooter" class="h-4 w-full bg-white"></div>
16+
<ScrollUpButton></ScrollUpButton>
1617
</section>
1718
</div>
1819
</template>
@@ -21,12 +22,14 @@
2122
/* eslint-disable max-len */
2223
2324
import Recommendations from '@/components/app/recommendations/Recommendations.vue';
25+
import ScrollUpButton from '@/components/shared/ScrollUpButton.vue';
2426
2527
export default {
2628
name: 'Browse',
2729
props: ['recommendationsFromSettingUp'],
2830
components: {
2931
Recommendations,
32+
ScrollUpButton,
3033
},
3134
data: () => ({
3235
recommendations: [],

frontend/src/views/app/History.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
v-bind:recommendationsReceived="recommendations"
2626
v-bind:recommendationsAnalysis="recommendationsAnalysis"></HistoryRecommendations>
2727
<div id="invisibleFooterHistory" class="h-4 w-full bg-white"></div>
28+
<ScrollUpButton></ScrollUpButton>
2829
</section>
2930
</div>
3031
</template>
@@ -35,13 +36,15 @@
3536
3637
import HistoryRecommendations from '@/components/app/recommendations/HistoryRecommendations.vue';
3738
import DropdownDisplayChoiceHistory from '@/components/shared/DropdownDisplayChoiceHistory.vue';
39+
import ScrollUpButton from '@/components/shared/ScrollUpButton.vue';
3840
3941
export default {
4042
name: 'History',
4143
props: ['recommendationsFromSettingUp'],
4244
components: {
4345
HistoryRecommendations,
4446
DropdownDisplayChoiceHistory,
47+
ScrollUpButton,
4548
},
4649
data: () => ({
4750
recommendations: [],

frontend/src/views/app/Search.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
v-bind:title="'Potential matches'"
1515
v-bind:recommendationsReceived="recommendations"
1616
v-bind:recommendationsAnalysis="filters"></Recommendations>
17+
<ScrollUpButton></ScrollUpButton>
1718
</section>
1819
<div id="invisibleFooterSearch" class="h-4 w-full bg-white"></div>
1920
<section v-on:click="setError(null)"
@@ -74,13 +75,15 @@
7475
import FilterSlider from '@/components/shared/FilterSlider.vue';
7576
import MultipleFilters from '@/components/shared/MultipleFilters.vue';
7677
import Recommendations from '@/components/app/recommendations/Recommendations.vue';
78+
import ScrollUpButton from '@/components/shared/ScrollUpButton.vue';
7779
7880
export default {
7981
name: 'Search',
8082
components: {
8183
MultipleFilters,
8284
FilterSlider,
8385
Recommendations,
86+
ScrollUpButton,
8487
},
8588
data: () => ({
8689
recommendations: [],

0 commit comments

Comments
 (0)