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

+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))