webcompile/src/routes/pubnix/+page.svelte

59 lines
1.2 KiB
Svelte
Raw Permalink Normal View History

2023-01-07 22:59:58 +05:30
<script lang="ts">
import type { PageData } from "./$types";
export let data: PageData;
2023-01-25 22:41:11 +05:30
import User, { type UserType } from "./User.svelte";
2023-02-03 23:25:33 +05:30
const isOnline = (user: UserType) => user.online;
const onlineUserCount = data.users.users.filter(isOnline).length;
const userCount = data.users.users.length;
2023-01-25 22:41:11 +05:30
</script>
2023-01-07 22:59:58 +05:30
2023-01-25 22:41:11 +05:30
<div class="h1-no-lg flex flex-col sm:(flex-row items-center) gap-4">
<span class="text-4xl font-bold">Pubnix</span>
2023-02-03 23:25:33 +05:30
<a
href="/pubnix/register"
class="button sm:w-fit"
><div class="i-ic:outline-plus" />
2023-03-30 12:30:36 +05:30
Register</a
2023-02-03 23:25:33 +05:30
>
<a
href="/pubnix/users"
class="button sm:w-fit"
><div class="i-ic:outline-people" />
2023-03-30 12:30:36 +05:30
Users</a
2023-02-03 23:25:33 +05:30
>
<a
href="/pubnix/faq"
class="button sm:w-fit"
><div class="i-ic:outline-question-mark" />
2023-03-30 12:30:36 +05:30
FAQ</a
2023-02-03 23:25:33 +05:30
>
2023-01-25 22:41:11 +05:30
</div>
2023-01-07 22:59:58 +05:30
2023-01-25 22:41:11 +05:30
<h2>Online users</h2>
2023-01-07 22:59:58 +05:30
2023-02-18 22:12:23 +05:30
{#if !data.users.error}
2023-02-26 12:11:21 +05:30
{#if data.users.users.some(isOnline)}
2023-03-30 12:30:36 +05:30
<p class="my-4">
There {onlineUserCount === 1 ? "is" : "are"}
{onlineUserCount}
{onlineUserCount === 1 ? "user" : "users"} online out of {userCount}
users.
</p>
2023-01-25 22:41:11 +05:30
<div class="flex flex-row flex-wrap gap-4">
{#each data.users.users as user}
{#if user.online}
<User {user} />
{/if}
{/each}
</div>
2023-01-07 22:59:58 +05:30
{:else}
2023-02-26 12:11:21 +05:30
<p>No users online</p>
2023-01-07 22:59:58 +05:30
{/if}
2023-01-25 22:41:11 +05:30
{:else}
2023-02-18 22:12:23 +05:30
<p>{data.users.message}</p>
2023-02-03 23:25:33 +05:30
{/if}