feat: Added scroll to top on all pages that have recipeCardSection (#7384)

This commit is contained in:
Brian Choromanski
2026-04-03 00:11:16 -04:00
committed by GitHub
parent 4ee97e5348
commit bb278aac35
3 changed files with 41 additions and 0 deletions

View File

@@ -167,6 +167,7 @@
:loading="loading"
/>
</v-fade-transition>
<AppScrollToTop />
</div>
</template>

View File

@@ -0,0 +1,38 @@
<template>
<v-fade-transition>
<v-btn
v-if="showButton"
icon
position="fixed"
location="bottom right"
class="ma-4"
color="primary"
elevation="4"
style="z-index: 999;"
@click="scrollToTop"
>
<v-icon>{{ $globals.icons.arrowUp }}</v-icon>
</v-btn>
</v-fade-transition>
</template>
<script setup lang="ts">
const showButton = ref(false);
const threshold = 400;
function onScroll() {
showButton.value = document.documentElement.scrollTop > threshold;
}
function scrollToTop() {
document.documentElement.scrollTop = 0;
}
onMounted(() => {
window.addEventListener("scroll", onScroll);
});
onUnmounted(() => {
window.removeEventListener("scroll", onScroll);
});
</script>

View File

@@ -11,6 +11,7 @@ import {
mdiArrowLeftBoldOutline,
mdiArrowRightBold,
mdiArrowRightBoldOutline,
mdiArrowUp,
mdiBackupRestore,
mdiBeakerOutline,
mdiBellAlert,
@@ -177,6 +178,7 @@ export const icons = {
api: mdiApi,
arrowLeftBold: mdiArrowLeftBold,
arrowRightBold: mdiArrowRightBold,
arrowUp: mdiArrowUp,
arrowUpDown: mdiDrag,
backupRestore: mdiBackupRestore,
bellAlert: mdiBellAlert,