misc: basic functionality

This commit is contained in:
Xyphyn committed 2023-06-24 14:27:20 -07:00
1 parent c9fc488ef2
commit 83608fdaa6
12 files changed
+147 -36

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
<nav
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
max-w-7xl mx-auto px-6"
max-w-5xl mx-auto px-6"
>
<div class="flex flex-row gap-2 items-center mr-auto">
<a href="/">
+2 -2
View File
@@ -21,7 +21,7 @@
}
</script>
<Navbar routes={$page.url.pathname.split('/').slice(2)} />
<div class="mx-auto max-w-7xl p-4">
<Navbar routes={$page.url.pathname.split('/').slice(1)} />
<div class="mx-auto max-w-5xl p-4">
<slot />
</div>
-1
View File
@@ -1,5 +1,4 @@
import { lemmy } from '$lib/lemmy.js';
import { error } from '@sveltejs/kit';
export function load({ params }) {
return lemmy.getCommunity({ name: params.name })
+15 -17
View File
@@ -1,23 +1,21 @@
<script lang="ts">
import type { GetCommunityResponse } from 'lemmy-js-client'
export let data: Promise<GetCommunityResponse>
export let data: GetCommunityResponse
</script>
{#await data then data}
<div class="flex flex-col gap-4">
<div class="flex flex-row gap-4 items-center">
<img
src={data.community_view.community.icon}
alt="test"
class="rounded-full bg-white border-slate-200 border p-2"
width={64}
height={64}
/>
<h1 class="font-bold text-xl">
{data.community_view.community.name}
</h1>
</div>
<slot />
<div class="flex flex-col gap-4">
<div class="flex flex-row gap-4 items-center">
<img
src={data.community_view.community.icon}
alt="test"
class="rounded-full bg-white border-slate-200 border p-2"
width={64}
height={64}
/>
<h1 class="font-bold text-xl">
{data.community_view.community.name}
</h1>
</div>
{/await}
<slot />
</div>
+5
View File
@@ -0,0 +1,5 @@
import { redirect } from '@sveltejs/kit';
export function load({ params }) {
throw redirect(300, `/c/${params.name}/posts`)
}
+5 -9
View File
@@ -1,18 +1,14 @@
<script lang="ts">
import MultiSelect from '$lib/components/MultiSelect.svelte'
import type { PostResponse } from 'lemmy-js-client'
import Post from './Post.svelte'
import Post from '../../../post/[id]/Post.svelte'
export let data: any
export let data
</script>
<MultiSelect options={['Community', 'idk']} selected="Community" />
<div class="flex flex-col gap-4">
{#await data then data}
<pre>{JSON.stringify(data, undefined, 2)}</pre>
{#each data?.posts as post}
<Post {post} />
{/each}
{/await}
{#each data.posts as post}
<Post {post} />
{/each}
</div>
-5
View File
@@ -1,5 +0,0 @@
<script lang="ts">
export let post: Post
</script>
<p>{post.post.name}</p>
+16
View File
@@ -0,0 +1,16 @@
import { lemmy } from '$lib/lemmy.js'
export async function load({ params }) {
return {
post: await lemmy.getPost({ id: Number(params.id) }),
comments: await lemmy.getComments({
post_id: Number(params.id),
type_: 'All',
limit: 20,
page: 1,
max_depth: 3,
saved_only: false,
sort: 'Hot',
}),
}
}
+36
View File
@@ -0,0 +1,36 @@
<script lang="ts">
import MultiSelect from '$lib/components/MultiSelect.svelte'
import type { GetCommentsResponse, GetPostResponse } from 'lemmy-js-client'
export let data: { post: GetPostResponse; comments: GetCommentsResponse }
const postData = data.post.post_view
const post = postData.post
const comments = data.comments.comments
</script>
<div class="flex flex-col gap-2">
<span class="flex flex-row gap-2 text-sm opacity-70">
<a href="/">c/{postData.community.name}</a>
<span class="opacity-50">{postData.creator.name}</span>
</span>
<h1 class="font-bold text-lg">{post.name}</h1>
{#if post.thumbnail_url}
<img src={post.thumbnail_url} alt={post.name} />
{/if}
{#if post.body}
<p>{post.body}</p>
{/if}
</div>
<div class="mt-4 flex flex-col gap-2">
<div class="font-bold text-lg">Comments</div>
<MultiSelect
options={['hot', 'new', 'top']}
optionNames={['Hot', 'New', 'Top']}
selected="hot"
/>
</div>
{#each comments as comment}
{comment.comment.content}
{/each}
File renamed without changes.
+66
View File
@@ -0,0 +1,66 @@
<script lang="ts">
import type { GetPostResponse, PostView } from 'lemmy-js-client'
import {
ArrowDown,
ArrowUp,
ChatBubbleLeft,
ChevronDown,
ChevronUp,
Icon,
} from 'svelte-hero-icons'
let postRes: PostView
export { postRes as post }
const post = postRes.post
</script>
<div
class="bg-white dark:bg-zinc-900 border dark:border-zinc-800 border-slate-200
rounded-md flex flex-col overflow-hidden max-w-xl"
>
<div class="flex flex-col gap-2 bg-white p-4 rounded-md">
<span class="flex flex-row gap-2 text-sm opacity-70">
<a href="/">c/{postRes.community.name}</a>
<span class="opacity-50">{postRes.creator.name}</span>
</span>
<h1 class="font-bold text-lg">{post.name}</h1>
{#if post.url}
<a
href={post.url}
class="text-sky-400 max-w-[24ch] overflow-hidden
whitespace-nowrap text-ellipsis text-xs hover:underline"
>
{post.url}
</a>
{/if}
{#if post.body}
<p class="text-sm max-h-24 line-clamp-3">
{post.body}
</p>
{/if}
</div>
<div class="flex flex-row gap-2 p-2">
<div
class="flex flex-row items-center gap-1 rounded-md
bg-slate-100"
>
<button aria-label="Upvote" class="p-1 px-1.5">
<Icon src={ChevronUp} mini width={20} height={20} />
</button>
<span class="text-sm">{postRes.counts.score}</span>
<button aria-label="Downvote" class="p-1 px-1.5">
<Icon src={ChevronDown} mini width={20} height="20}" />
</button>
</div>
<a
class="flex flex-row items-center gap-2.5 p-1 px-2 rounded-md
bg-slate-100"
href="/post/{post.id}"
>
<Icon src={ChatBubbleLeft} width={16} height={16} />
<span class="text-sm">{postRes.counts.comments}</span>
</a>
</div>
</div>