refactor: NavSideItem

zio/stable
Anthony Fu 2022-11-27 10:35:26 +08:00
parent 3cd8fb54dd
commit cd4658506d
4 changed files with 37 additions and 78 deletions

View File

@ -4,12 +4,14 @@ import type { Account } from 'masto'
defineProps<{ defineProps<{
account: Account account: Account
}>() }>()
defineOptions({
inheritAttrs: false,
})
</script> </script>
<template> <template>
<AccountAvatarImage :account="account" v-bind="$attrs" /> <img
:src="account.avatar"
:alt="account.username"
loading="lazy"
rounded-full bg-gray:10
v-bind="$attrs"
>
</template> </template>

View File

@ -1,17 +0,0 @@
<script setup lang="ts">
import type { Account } from 'masto'
defineProps<{
account: Account
}>()
</script>
<template>
<img
:src="account.avatar"
:alt="account.username"
loading="lazy"
rounded-full bg-gray:10
v-bind="$attrs"
>
</template>

View File

@ -1,65 +1,21 @@
<script setup lang="ts">
</script>
<template> <template>
<div px3 py4 flex="~ col gap2" text-lg> <div px3 py4 flex="~ col gap2" text-lg>
<template v-if="currentUser"> <template v-if="currentUser">
<NuxtLink to="/home" active-class="text-primary" group focus:outline-none> <NavSideItem text="Home" to="/home" icon="i-ri:home-5-line" />
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current"> <NavSideItem text="Notifications" to="/notifications" icon="i-ri:notification-4-line" />
<div i-ri:home-5-line />
<span>Home</span>
</div>
</NuxtLink>
<NuxtLink to="/notifications" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<div i-ri:notification-4-line />
<span>Notifications</span>
</div>
</NuxtLink>
</template> </template>
<NuxtLink to="/explore" active-class="text-primary" group focus:outline-none> <NavSideItem text="Explore" to="/explore" icon="i-ri:hashtag" />
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current"> <NavSideItem text="Local" to="/public/local" icon="i-ri:group-2-line " />
<div i-ri:hashtag /> <NavSideItem text="Federated" to="/public" icon="i-ri:earth-line" />
<span>Explore</span>
</div>
</NuxtLink>
<NuxtLink to="/public/local" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<div i-ri:group-2-line />
<span>Local</span>
</div>
</NuxtLink>
<NuxtLink to="/public" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<div i-ri:earth-line />
<span>Federated</span>
</div>
</NuxtLink>
<template v-if="currentUser"> <template v-if="currentUser">
<NuxtLink to="/conversations" active-class="text-primary" group focus:outline-none> <NavSideItem text="Conversations" to="/conversations" icon="i-ri:at-line" />
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current"> <NavSideItem text="Favourites" to="/favourites" icon="i-ri:heart-3-line" />
<div i-ri:at-line /> <NavSideItem text="Bookmarks" to="/bookmarks" icon="i-ri:bookmark-line " />
<span>Conversations</span> <NavSideItem text="Lists" :to="getAccountPath(currentUser.account)" icon="i-ri:list-check-2-line">
</div> <template #icon>
</NuxtLink>
<NuxtLink to="/favourites" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<div i-ri:heart-3-line />
<span>Favorites</span>
</div>
</NuxtLink>
<NuxtLink to="/bookmarks" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<div i-ri:bookmark-line />
<span>Bookmarks</span>
</div>
</NuxtLink>
<NuxtLink :to="getAccountPath(currentUser.account)" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<AccountAvatar :account="currentUser.account" h="1.2em" /> <AccountAvatar :account="currentUser.account" h="1.2em" />
<span>Profile</span> </template>
</div> </NavSideItem>
</NuxtLink>
</template> </template>
</div> </div>
</template> </template>

View File

@ -0,0 +1,18 @@
<script setup lang="ts">
defineProps<{
text: string
icon: string
to: string
}>()
</script>
<template>
<NuxtLink :to="to" active-class="text-primary" group focus:outline-none>
<div flex w-fit px5 py2 gap2 items-center transition-100 rounded-10 group-hover:bg-active group-focus-visible:ring="2 current">
<slot name="icon">
<div :class="icon" />
</slot>
<span>{{ text }}</span>
</div>
</NuxtLink>
</template>