1
0

feat: scroll to top (#237)

This commit is contained in:
Shinigami 2022-11-29 21:15:53 +01:00 committed by GitHub
parent cf225e2005
commit 0e7076b991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 48 additions and 15 deletions

View File

@ -5,24 +5,24 @@
<template>
<nav h-14 fixed bottom-0 left-0 right-0 z-10 border="t base" bg-base flex flex-row>
<template v-if="currentUser">
<NuxtLink to="/home" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink to="/home" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:home-5-line />
</NuxtLink>
<NuxtLink to="/notifications" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink to="/notifications" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:notification-4-line />
</NuxtLink>
</template>
<NuxtLink to="/explore" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink to="/explore" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:hashtag />
</NuxtLink>
<NuxtLink group to="/public/local" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink group to="/public/local" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:group-2-line />
</NuxtLink>
<NuxtLink to="/public" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink to="/public" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:earth-line />
</NuxtLink>
<template v-if="currentUser">
<NuxtLink to="/conversations" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1>
<NuxtLink to="/conversations" active-class="text-primary" flex flex-row items-center place-content-center h-full flex-1 @click="$scrollToTop">
<div i-ri:at-line />
</NuxtLink>
</template>

View File

@ -25,7 +25,7 @@ useCommand({
</script>
<template>
<NuxtLink :to="to" active-class="text-primary" group focus:outline-none>
<NuxtLink :to="to" active-class="text-primary" group focus:outline-none @click="$scrollToTop">
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-full group-hover:bg-active group-focus-visible:ring="2 current">
<slot name="icon">
<div :class="icon" />

View File

@ -15,7 +15,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('nav_side.bookmarks') }}</span>
<NuxtLink to="/bookmarks" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:bookmark-line />
<span>{{ t('nav_side.bookmarks') }}</span>
</NuxtLink>
</template>
<slot>

View File

@ -15,7 +15,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('nav_side.conversations') }}</span>
<NuxtLink to="/conversations" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:at-line />
<span>{{ t('nav_side.conversations') }}</span>
</NuxtLink>
</template>
<slot>

View File

@ -11,7 +11,10 @@ useHead({
<template>
<MainContent>
<template #title>
<div i-ri:hashtag h-6 mr-1 /><span>{{ t('nav_side.explore') }}</span>
<NuxtLink to="/explore" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:hashtag />
<span>{{ t('nav_side.explore') }}</span>
</NuxtLink>
</template>
<slot>

View File

@ -14,7 +14,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('nav_side.favourites') }}</span>
<NuxtLink to="/favourites" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:heart-3-line />
<span>{{ t('nav_side.favourites') }}</span>
</NuxtLink>
</template>
<slot>
<TimelinePaginator :paginator="paginator" />

View File

@ -24,7 +24,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ $t('nav_side.home') }}</span>
<NuxtLink to="/home" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:home-5-line />
<span>{{ $t('nav_side.home') }}</span>
</NuxtLink>
</template>
<slot>
<PublishWidget draft-key="home" border="b base" />

View File

@ -22,7 +22,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('nav_side.notifications') }}</span>
<NuxtLink to="/notifications" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:notification-4-line />
<span>{{ t('nav_side.notifications') }}</span>
</NuxtLink>
</template>
<template #header>

View File

@ -13,7 +13,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('title.federated_timeline') }}</span>
<NuxtLink to="/public" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:group-2-line />
<span>{{ t('title.federated_timeline') }}</span>
</NuxtLink>
</template>
<slot>

View File

@ -13,7 +13,10 @@ useHead({
<template>
<MainContent>
<template #title>
<span text-lg font-bold>{{ t('title.local_timeline') }}</span>
<NuxtLink to="/public/local" text-lg font-bold flex items-center gap-2 @click="$scrollToTop">
<div i-ri:group-2-line />
<span>{{ t('title.local_timeline') }}</span>
</NuxtLink>
</template>
<slot>

9
plugins/scroll-to-top.ts Normal file
View File

@ -0,0 +1,9 @@
export default defineNuxtPlugin(() => {
return {
provide: {
scrollToTop: () => {
document.body.scrollTo(0, 0)
},
},
}
})