-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Minor refactor and add more placeholder announcements
- Loading branch information
Showing
4 changed files
with
150 additions
and
100 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,40 @@ | ||
<script lang="ts"> | ||
import CardsList from '$layout/Announcements/CardsList.svelte'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { derived, readable, type Readable } from 'svelte/store'; | ||
import { building } from '$app/environment'; | ||
import { page } from '$app/stores'; | ||
import Query from '$lib/components/Query.svelte'; | ||
import AnnouncementCard from './AnnouncementCard.svelte'; | ||
import { queries } from '$data/api'; | ||
import ChannelChip from './ChannelChip.svelte'; | ||
import Masonry from 'svelte-bricks'; | ||
let searchParams: Readable<URLSearchParams>; | ||
if (building) searchParams = readable(new URLSearchParams()); | ||
else searchParams = derived(page, ($page) => $page.url.searchParams); | ||
$: query = createQuery(queries.announcements()); | ||
$: channel = $searchParams.get('channel'); | ||
function uniqueObjArrayByKey<T extends object>(array: T[], key: keyof T) { | ||
return array.filter((obj, index, self) => index === self.findIndex((t) => t[key] === obj[key])); | ||
} | ||
</script> | ||
|
||
<main class="wrapper"> | ||
<CardsList /> | ||
</main> | ||
<div class="announcements-list"> | ||
<Query {query} let:data> | ||
<div class="channels-selection"> | ||
{#each uniqueObjArrayByKey(data.announcements, 'channel') as ann (ann.id)} | ||
<ChannelChip channel={ann.channel} /> | ||
{/each} | ||
</div> | ||
|
||
<style> | ||
</style> | ||
<Masonry items={data.announcements.filter((a) => a.channel === channel)} let:item> | ||
<AnnouncementCard {item} /> | ||
</Masonry> | ||
</Query> | ||
</div> | ||
</main> |
Oops, something went wrong.