-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelList.svelte
More file actions
54 lines (48 loc) · 1.61 KB
/
ChannelList.svelte
File metadata and controls
54 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script lang="ts">
import { api, type Id } from "@packages/convex";
import { useQuery } from "convex-svelte";
import CreateChannelButton from "./CreateChannelButton.svelte";
interface Props {
organizationId: Id<"organizations">;
selectedChannelId?: Id<"channels">;
}
let { organizationId, selectedChannelId = $bindable() }: Props = $props();
const channels = useQuery(api.channels.list, () => ({
organizationId,
}));
</script>
<div class="flex h-full flex-col">
<div class="border-base-300 border-b p-4">
<h3 class="text-base font-semibold">チャンネル</h3>
<CreateChannelButton {organizationId} />
</div>
<div class="flex-1 overflow-y-auto">
{#if channels.data}
{#each channels.data as channel (channel._id)}
<button
class={[
"border-base-300 w-full border-b p-3 text-left",
selectedChannelId === channel._id
? "bg-primary text-primary-content"
: "hover:bg-base-300",
].join(" ")}
onclick={() => (selectedChannelId = channel._id)}
>
<div class="font-medium"># {channel.name}</div>
{#if channel.description}
<div class="text-sm opacity-70">{channel.description}</div>
{/if}
</button>
{/each}
{:else}
<div class="text-base-content/60 p-4 text-center">
チャンネルを読み込み中...
</div>
{/if}
{#if channels.data && channels.data.length === 0}
<div class="text-base-content/60 p-4 text-center text-sm">
まだチャンネルがありません
</div>
{/if}
</div>
</div>