feat: Add user pages

This commit is contained in:
Xyphyn committed 2023-07-04 19:39:27 -07:00
1 parent 04704749b7
commit 9efe1df0c2
12 files changed
+222 -29

No files matched your search

@@ -5,19 +5,15 @@
export let avatar: boolean = false
function linkFromCommunity(community: Community) {
const local = community.local
// if (local) {
// return `/c/${community.name}`
// } else {
const domain = new URL(community.actor_id).hostname
return `/c/${community.name}@${domain}`
// }
}
</script>
<a class="items-center flex flex-row gap-2" href={linkFromCommunity(community)}>
<a
class="items-center flex flex-row gap-2 hover:underline"
href={linkFromCommunity(community)}
>
{#if avatar}
<img
src={community.icon ??
+2 -1
View File
@@ -21,6 +21,7 @@
import { authData, getClient } from '$lib/lemmy.js'
import PostVote from '$lib/components/lemmy/PostVote.svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import UserLink from '$lib/components/user/UserLink.svelte'
let postRes: PostView
export { postRes as post }
@@ -64,7 +65,7 @@
<span class="flex flex-row gap-2 text-sm opacity-80 items-center">
<CommunityLink avatar community={postRes.community} />
<div class="ml-auto" />
<span class="opacity-50">{postRes.creator.name}</span>
<UserLink user={postRes.creator} />
<span class="opacity-50">
<RelativeDate date={new Date(postRes.post.published)} />
</span>
@@ -15,6 +15,7 @@
import { Color } from '$lib/ui/colors.js'
import CommentForm from './CommentForm.svelte'
import { page } from '$app/stores'
import UserLink from '$lib/components/user/UserLink.svelte'
export let node: CommentNodeI
@@ -66,12 +67,9 @@
<summary
class="flex flex-row cursor-pointer arrow gap-2 items-center group"
>
<Avatar
url={node.comment_view.creator.avatar ??
`https://api.dicebear.com/6.x/initials/svg?seed=${node.comment_view.creator.name}`}
width={24}
/>
<span class="text-sm">{node.comment_view.creator.name}</span>
<span class="text-sm">
<UserLink avatar user={node.comment_view.creator} />
</span>
<span class="text-sm opacity-60 md:inline hidden">
{node.comment_view.counts.score} point{node.comment_view.counts.score ==
1
+4
View File
@@ -17,6 +17,7 @@
Cog6Tooth,
Icon,
Inbox,
UserCircle,
} from 'svelte-hero-icons'
</script>
@@ -65,6 +66,9 @@
<Icon src={ArrowLeftOnRectangle} mini width={16} /> Log in
</MenuButton>
{:else}
<MenuButton link href="/u/{$user.person_view.person.name}">
<Icon src={UserCircle} mini width={16} /> Profile
</MenuButton>
<MenuButton link href="/inbox">
<Icon src={Inbox} mini width={16} /> Inbox
</MenuButton>
+29
View File
@@ -0,0 +1,29 @@
<script lang="ts">
import type { Person } from 'lemmy-js-client'
export let user: Person
export let avatar: boolean = false
function linkFromCommunity(user: Person) {
const domain = new URL(user.actor_id).hostname
return `/u/${user.name}@${domain}`
}
</script>
<a
class="items-center flex flex-row gap-2 hover:underline"
href={linkFromCommunity(user)}
>
{#if avatar}
<img
src={user.avatar ??
`https://api.dicebear.com/6.x/initials/svg?seed=${user.name}`}
alt=""
width={24}
height={24}
class="rounded-full aspect-square object-cover"
loading="lazy"
/>
{/if}
{user.name}
</a>