Skip to content

Commit

Permalink
feat: scroll to top (elk-zone#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Nov 29, 2022
1 parent cf225e2 commit 0e7076b
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 15 deletions.
12 changes: 6 additions & 6 deletions components/nav/NavBottom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/nav/NavSideItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
5 changes: 4 additions & 1 deletion pages/bookmarks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion pages/conversations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion pages/explore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion pages/favourites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
5 changes: 4 additions & 1 deletion pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
5 changes: 4 additions & 1 deletion pages/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion pages/public/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion pages/public/local.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 9 additions & 0 deletions plugins/scroll-to-top.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default defineNuxtPlugin(() => {
return {
provide: {
scrollToTop: () => {
document.body.scrollTo(0, 0)
},
},
}
})

0 comments on commit 0e7076b

Please sign in to comment.