switch to another frontend framework wheeeeeeeeeeee
This commit is contained in:
parent
fa3c1ccaa7
commit
c4adf6918c
58 changed files with 6246 additions and 1703 deletions
|
@ -1,18 +0,0 @@
|
|||
import type { User } from "./user";
|
||||
|
||||
export type CallbackRequest = {
|
||||
code: string;
|
||||
state: string;
|
||||
};
|
||||
|
||||
export type CallbackResponse = {
|
||||
has_account: boolean;
|
||||
ticket: string;
|
||||
remote_username: string | null;
|
||||
};
|
||||
|
||||
export type AuthResponse = {
|
||||
user: User;
|
||||
token: string;
|
||||
expires_at: string;
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
export default interface Meta {
|
||||
version: string;
|
||||
hash: string;
|
||||
users: {
|
||||
total: number;
|
||||
active_month: number;
|
||||
active_week: number;
|
||||
active_day: number;
|
||||
};
|
||||
members: number;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
export type User = {
|
||||
id: string;
|
||||
username: string;
|
||||
display_name: string | null;
|
||||
bio: string | null;
|
||||
member_title: string | null;
|
||||
avatar_url: string | null;
|
||||
links: string[];
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
// place files you want to import through the `$lib` alias in this folder.
|
|
@ -1,11 +0,0 @@
|
|||
<script lang="ts">
|
||||
let isOpen = false;
|
||||
export let right = false;
|
||||
</script>
|
||||
|
||||
<div class={"navbar-item has-dropdown" + (isOpen ? " is-active" : "") + (right ? " is-right" : "")}>
|
||||
<button class="navbar-link" on:click={() => (isOpen = !isOpen)}><slot name="label" /></button>
|
||||
<div class="navbar-dropdown">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
|
@ -1,10 +0,0 @@
|
|||
<script lang="ts">
|
||||
export let divider = false;
|
||||
export let href: string | undefined = undefined;
|
||||
</script>
|
||||
|
||||
{#if divider}
|
||||
<hr class="navbar-divider" />
|
||||
{:else}
|
||||
<a {href} class="navbar-item"><slot /></a>
|
||||
{/if}
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 7.9 KiB |
|
@ -1,66 +0,0 @@
|
|||
<script lang="ts">
|
||||
import { IconSun, IconMoon } from "@tabler/icons-svelte";
|
||||
import { onMount } from "svelte";
|
||||
import Dropdown from "./Dropdown.svelte";
|
||||
import DropdownItem from "./DropdownItem.svelte";
|
||||
import Logo from "./Logo.svelte";
|
||||
import type { User } from "$lib/api/user";
|
||||
import { themeStore } from "$lib/store";
|
||||
|
||||
export let user: User | undefined;
|
||||
let navIsOpen = false;
|
||||
|
||||
onMount(() => {
|
||||
let theme = localStorage.getItem("pronounscc-theme");
|
||||
if (!theme)
|
||||
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
themeStore.set(theme);
|
||||
});
|
||||
|
||||
const toggleTheme = () => {
|
||||
themeStore.set($themeStore === "dark" ? "light" : "dark");
|
||||
document.documentElement.setAttribute("data-theme", $themeStore);
|
||||
localStorage.setItem("pronounscc-theme", $themeStore);
|
||||
};
|
||||
</script>
|
||||
|
||||
<nav class="navbar" aria-label="Main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a href="/" class="navbar-item">
|
||||
<Logo />
|
||||
</a>
|
||||
<button
|
||||
class={"navbar-burger" + (navIsOpen ? " is-active" : "")}
|
||||
aria-label="menu"
|
||||
aria-expanded="false"
|
||||
on:click={() => (navIsOpen = !navIsOpen)}
|
||||
>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class={"navbar-menu" + (navIsOpen ? " is-active" : "")}>
|
||||
<div class="navbar-end">
|
||||
{#if user}
|
||||
<Dropdown>
|
||||
<span slot="label">@{user.username}</span>
|
||||
<DropdownItem href="/@{user.username}">View profile</DropdownItem>
|
||||
<DropdownItem href="/settings">Settings</DropdownItem>
|
||||
<DropdownItem divider />
|
||||
<DropdownItem href="/auth/logout">Log out</DropdownItem>
|
||||
</Dropdown>
|
||||
{:else}
|
||||
<a href="/auth/login" class="navbar-item">Log in or sign up</a>
|
||||
{/if}
|
||||
<button class="navbar-item" on:click={() => toggleTheme()}>
|
||||
{#if $themeStore === "dark"}
|
||||
<IconSun size={20} /> Light theme
|
||||
{:else}
|
||||
<IconMoon size={20} /> Dark theme
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
|
@ -1,72 +0,0 @@
|
|||
import { PUBLIC_API_BASE } from "$env/static/public";
|
||||
|
||||
export type RequestParams = {
|
||||
token?: string;
|
||||
body?: any;
|
||||
headers?: Record<string, string>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch a path from the API and parse the response.
|
||||
* To make sure the request is authenticated in load functions,
|
||||
* pass `fetch` from the request object into opts.
|
||||
*
|
||||
* @param fetchFn A function like `fetch`, such as from the `load` function
|
||||
* @param method The HTTP method, i.e. GET, POST, PATCH
|
||||
* @param path The path to request, minus the leading `/api/v2`
|
||||
* @param params Extra options for this request
|
||||
* @returns T
|
||||
* @throws APIError
|
||||
*/
|
||||
export default async function request<T>(
|
||||
fetchFn: typeof fetch,
|
||||
method: string,
|
||||
path: string,
|
||||
params: RequestParams = {},
|
||||
) {
|
||||
const url = `${PUBLIC_API_BASE}/v2${path}`;
|
||||
const resp = await fetchFn(url, {
|
||||
method,
|
||||
body: params.body ? JSON.stringify(params.body) : undefined,
|
||||
headers: {
|
||||
...params.headers,
|
||||
...(params.token ? { Authorization: params.token } : {}),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (resp.status < 200 || resp.status >= 400) throw await resp.json();
|
||||
return (await resp.json()) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a path from the API and discard the response.
|
||||
* To make sure the request is authenticated in load functions,
|
||||
* pass `fetch` from the request object into opts.
|
||||
*
|
||||
* @param fetchFn A function like `fetch`, such as from the `load` function
|
||||
* @param method The HTTP method, i.e. GET, POST, PATCH
|
||||
* @param path The path to request, minus the leading `/api/v2`
|
||||
* @param params Extra options for this request
|
||||
* @returns T
|
||||
* @throws APIError
|
||||
*/
|
||||
export async function fastRequest(
|
||||
fetchFn: typeof fetch,
|
||||
method: string,
|
||||
path: string,
|
||||
params: RequestParams = {},
|
||||
): Promise<void> {
|
||||
const url = `${PUBLIC_API_BASE}/v2${path}`;
|
||||
const resp = await fetchFn(url, {
|
||||
method,
|
||||
body: params.body ? JSON.stringify(params.body) : undefined,
|
||||
headers: {
|
||||
...params.headers,
|
||||
...(params.token ? { Authorization: params.token } : {}),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (resp.status < 200 || resp.status >= 400) throw await resp.json();
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
import { writable } from "svelte/store";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
const defaultThemeValue = "light";
|
||||
const initialThemeValue = browser
|
||||
? window.localStorage.getItem("pronouns-theme") ?? defaultThemeValue
|
||||
: defaultThemeValue;
|
||||
|
||||
export const themeStore = writable<string>(initialThemeValue);
|
Loading…
Add table
Add a link
Reference in a new issue