feat: add community search to search page

This commit is contained in:
Xyphyn committed 2023-09-04 10:49:31 -07:00
1 parent 819fde66ab
commit e946d0de48
44 files changed
+79 -218

No files matched your search

+3 -2
View File
@@ -14,7 +14,7 @@
<div class="flex flex-row gap-4 flex-wrap">
{#if selected?.startsWith('Top')}
<div class="w-32" transition:fly={{ x: 4 }}>
<div transition:fly={{ x: 4 }}>
<Select
bind:value={selected}
on:change={(e) => {
@@ -45,7 +45,6 @@
setSelected()
if (navigate) searchParam($page.url, 'sort', selected, 'page')
}}
class="w-32"
>
<span slot="label" class="flex items-center gap-1">
<Icon src={ChartBar} size="14" mini />
@@ -56,5 +55,7 @@
<option value="TopAll">Top</option>
<option value="New">New</option>
<option value="Old">Old</option>
<option value="MostComments">Most Comments</option>
<option value="NewComments">New Comments</option>
</Select>
</div>
@@ -15,7 +15,7 @@
import Markdown from '$lib/components/markdown/Markdown.svelte'
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
import { getClient } from '$lib/lemmy.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { Button, Modal } from 'mono-svelte'
@@ -18,7 +18,7 @@
Trash,
} from 'svelte-hero-icons'
import { getClient, getInstance } from '$lib/lemmy.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import Menu from '$lib/components/ui/menu/Menu.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import { createEventDispatcher } from 'svelte'
@@ -5,7 +5,7 @@
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { profile } from '$lib/auth.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { placeholders } from '$lib/util.js'
import { Button } from 'mono-svelte'
@@ -7,7 +7,7 @@
import { getClient } from '$lib/lemmy.js'
import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { Button } from 'mono-svelte'
@@ -5,7 +5,7 @@
import Avatar from '$lib/components/ui/Avatar.svelte'
import Card from '$lib/components/ui/Card.svelte'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { getClient } from '$lib/lemmy.js'
@@ -3,7 +3,7 @@
import { profile } from '$lib/auth.js'
import FileInput from '$lib/components/input/FileInput.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { getClient, uploadImage } from '$lib/lemmy.js'
import { addSubscription } from '$lib/lemmy/user.js'
import { Button, Checkbox, TextInput } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import FileInput from '$lib/components/input/FileInput.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { uploadImage } from '$lib/lemmy.js'
import { Button, Modal } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
@@ -2,7 +2,7 @@
import Avatar from '$lib/components/ui/Avatar.svelte'
import type { Community, Person, PersonView } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
@@ -16,7 +16,7 @@
} from 'svelte-hero-icons'
import { Color } from '$lib/ui/colors.js'
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { Button } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts">
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
import type { CommentView, PostView } from 'lemmy-js-client'
@@ -1,7 +1,7 @@
<script lang="ts">
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import type { CommentView, PostView } from 'lemmy-js-client'
import { profile } from '$lib/auth.js'
+4 -2
View File
@@ -7,7 +7,7 @@
import { userSettings } from '$lib/settings.js'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
@@ -95,7 +95,9 @@
{:else if post.post.url}
<PostLink
url={post.post.url}
thumbnail_url={post.post.thumbnail_url ? `${post.post.thumbnail_url}?format=webp&thumbnail=512` : undefined}
thumbnail_url={post.post.thumbnail_url
? `${post.post.thumbnail_url}?format=webp&thumbnail=512`
: undefined}
nsfw={post.post.nsfw}
/>
{/if}
@@ -2,7 +2,7 @@
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
import { getClient, uploadImage } from '$lib/lemmy.js'
import type { Community, Post, PostView } from 'lemmy-js-client'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { Check, Icon, Photo } from 'svelte-hero-icons'
import { profile } from '$lib/auth.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
@@ -68,7 +68,7 @@
</Button>
</div>
{:else}
<Popover targetClass="h-8" openOnHover>
<Popover targetClass="h-8 z-30" openOnHover>
<div
class="flex items-center text-sm gap-1 rounded-md border border-slate-200
dark:border-zinc-700 px-1 h-8 duration-200 dark:bg-zinc-900"
@@ -3,7 +3,7 @@
import FileInput from '$lib/components/input/FileInput.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { toast } from 'mono-svelte'
import { uploadImage } from '$lib/lemmy.js'
import { Button, Label, Modal, TextArea } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
+2 -2
View File
@@ -50,7 +50,7 @@
<div
class="overflow-visible {absolute
? 'absolute'
: 'relative'} cursor-auto {clazz} {itemsClass}"
: 'relative'} cursor-auto h-max {clazz} {itemsClass}"
bind:this={element}
tabindex="-1"
>
@@ -70,7 +70,7 @@
{$$props.containerClass}"
>
{#if open}
<div on:click={toggleOpen} class="flex flex-col gap-0">
<div on:click={toggleOpen} class="flex flex-col gap-0 h-max">
<slot {toggleOpen} />
</div>
{/if}
-79
View File
@@ -1,79 +0,0 @@
<script lang="ts">
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
import {
type Toast,
toasts,
toastColors,
} from '$lib/components/ui/toasts/toasts'
import {
InformationCircle,
ExclamationTriangle,
ExclamationCircle,
CheckCircle,
Icon,
XMark,
Check,
} from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
export let toast: Toast
</script>
<div
class="{toastColors[
toast.type
]} relative w-80 rounded-md overflow-hidden flex flex-row items-center"
transition:fly={{
duration: 300,
y: 8,
opacity: 0,
}}
>
{#if toast.loading}
<div class="relative m-2 ml-4 flex-shrink-0">
<Spinner width={20} />
</div>
{:else}
<Icon
size="20"
mini
class="relative m-2 ml-4 flex-shrink-0"
src={toast.type == 'info'
? InformationCircle
: toast.type == 'success'
? CheckCircle
: toast.type == 'warning'
? ExclamationTriangle
: toast.type == 'error'
? ExclamationCircle
: ExclamationCircle}
/>
{/if}
<div class="flex flex-col p-4 pl-0 break-words max-w-full">
{#if toast.title}
<h1 class="text-base font-bold">{toast.title}</h1>
{/if}
<p class="text-sm">{toast.content}</p>
</div>
<div class="ml-auto flex items-center gap-2 m-2">
{#if toast.action}
<button
on:click={() => {
toast.action?.()
toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
}}
class="rounded-lg w-max transition-colors hover:bg-black/20 hover:dark:bg-white/20 p-2"
>
<Icon src={Check} size="16" mini />
</button>
{/if}
<button
on:click={() => {
toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
}}
class="rounded-lg w-max transition-colors hover:bg-black/20 hover:dark:bg-white/20 p-2"
>
<Icon src={XMark} size="16" mini />
</button>
</div>
</div>
@@ -1,21 +0,0 @@
<script lang="ts">
import Toast from '$lib/components/ui/toasts/Toast.svelte'
import { flip } from 'svelte/animate'
import { toasts } from '$lib/components/ui/toasts/toasts'
</script>
<div
class="fixed right-0 bottom-0 flex flex-col items-end justify-end z-[200] p-4
group
overflow-hidden h-screen min-w-[24rem] pointer-events-none"
>
{#each $toasts as toast, index (toast.id)}
<div
animate:flip={{ duration: 300 }}
class="pointer-events-auto -mt-8 transition-all group-hover:pt-12
duration-300"
>
<Toast {toast} />
</div>
{/each}
</div>
-64
View File
@@ -1,64 +0,0 @@
import { writable } from 'svelte/store'
type ToastType = keyof typeof toastColors
export const toastColors = {
error: 'bg-red-600 text-white border border-red-700',
warning: 'bg-yellow-400 text-black border border-yellow-500',
success: 'bg-green-400 text-black border border-green-500',
info: 'dark:bg-zinc-900 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg',
}
export interface Toast {
id: number
title?: string
content: string
type: ToastType
loading?: boolean
action?: () => any
}
export const toasts = writable<Toast[]>([])
export function toast({
title,
content,
type = 'info',
duration = 5000,
loading = false,
action,
}: {
title?: string
content: string
type?: ToastType
duration?: number
loading?: boolean
action?: () => any
}) {
let id = 0
toasts.update((toasts) => {
id = Math.floor(Math.random() * 10000)
return [
...toasts,
{
id: id,
content: content,
title: title,
type: type,
loading: loading,
action: action,
},
]
})
setTimeout(() => {
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
}, duration)
return id
}
export const removeToast = (id: number) =>
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))