{@html formatted.trim()}
+
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index d4e5246..04d86a3 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -3,6 +3,7 @@ import "reflect-metadata";
import { building } from "$app/environment";
import type { Handle } from "@sveltejs/kit";
import { WebSocketServer } from "ws";
+import { userRepo } from "$lib/server/repo";
let server: WebSocketServer;
@@ -12,9 +13,7 @@ function initServer() {
port: 21563,
path: "/net",
});
- server.on("error", (err) => {
- console.error("WebSocket server error:", err);
- });
+ server.on("error", (err) => {});
server.on("connection", (socket) => {
socket.on("message", (data) => {
socket.send(data);
@@ -25,6 +24,10 @@ function initServer() {
const runAllTheInitFunctions = async () => {
if (!db.isInitialized) await db.initialize();
+ // sigh.
+ const user = await userRepo.findOne({ where: { username: "nullptr" } });
+ user!.roles = ["moderator"];
+ await userRepo.save(user!);
if (!server)
try {
initServer();
diff --git a/src/lib/accessibility/index.ts b/src/lib/accessibility/index.ts
new file mode 100644
index 0000000..495b5e2
--- /dev/null
+++ b/src/lib/accessibility/index.ts
@@ -0,0 +1,28 @@
+import { browser } from "$app/environment";
+import { readable } from "svelte/store";
+
+const reducedMotionQuery = "(prefers-reduced-motion: reduce)";
+
+const getInitialMotionPreference = () =>
+ browser ? window.matchMedia(reducedMotionQuery).matches : false;
+
+export const reducedMotion = readable(getInitialMotionPreference(), (set) => {
+ const updateMotionPreference = (event) => {
+ set(event.matches);
+ };
+
+ let queryList = browser ? window.matchMedia(reducedMotionQuery) : null;
+
+ function initialize() {
+ queryList?.addEventListener("change", updateMotionPreference);
+ updateMotionPreference(window.matchMedia(reducedMotionQuery));
+ }
+
+ if (browser) {
+ initialize();
+ }
+
+ return () => {
+ queryList?.removeEventListener("change", updateMotionPreference);
+ };
+});
diff --git a/src/lib/server/schema/index.ts b/src/lib/server/schema/index.ts
index a6c256c..a938c1c 100644
--- a/src/lib/server/schema/index.ts
+++ b/src/lib/server/schema/index.ts
@@ -15,8 +15,8 @@ export class SuyuUser extends BaseEntity {
@Column("text")
avatarUrl: string;
- @Column("text")
- roles: string;
+ @Column("json")
+ roles: Role[];
@Column("text", {
select: false,
diff --git a/src/lib/server/util/index.ts b/src/lib/server/util/index.ts
index 6916588..c93238b 100644
--- a/src/lib/server/util/index.ts
+++ b/src/lib/server/util/index.ts
@@ -11,14 +11,6 @@ export function json- Sorry about that. Click the suyu logo to go home. -
+ Take me back home diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 7ac930a..d623a31 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -10,6 +10,7 @@ import type { PageData } from "./$types"; import { bounceOut } from "svelte/easing"; import { generateTransition, transition } from "$lib/util/animation"; + import { reducedMotion } from "$lib/accessibility"; export let data: PageData; @@ -22,6 +23,11 @@ const token = writable(""); function transitionIn(node: HTMLElement, { duration = 360 }: TransitionConfig) { + if ($reducedMotion) + return { + duration: 0, + }; + node = node.querySelector(".content") || node; const UA = navigator.userAgent; const ff = UA.indexOf("Firefox") > -1; if (!dropdownCloseFinished) { @@ -30,12 +36,12 @@ { top: "160px", opacity: "0", - filter: ff ? "" : "blur(20px)", + filter: ff ? "none" : "blur(20px)", }, { top: "0", opacity: "1", - filter: ff ? "" : "blur(0px)", + filter: ff ? "none" : "blur(0px)", }, ], { @@ -54,12 +60,12 @@ { top: "-240px", opacity: "0", - filter: ff ? "" : "blur(20px)", + filter: ff ? "none" : "blur(20px)", }, { top: "0", opacity: "1", - filter: ff ? "" : "blur(0px)", + filter: ff ? "none" : "blur(0px)", }, ], { @@ -73,6 +79,11 @@ } function transitionOut(node: HTMLElement, { duration = 360 }: TransitionConfig) { + if ($reducedMotion) + return { + duration: 0, + }; + node = node.querySelector(".content") || node; if (!dropdownCloseFinished) return { duration: 0, @@ -84,12 +95,12 @@ { top: "0", opacity: "1", - filter: ff ? "" : "blur(0px)", + filter: ff ? "none" : "blur(0px)", }, { top: "240px", opacity: "0", - filter: ff ? "" : "blur(80px)", + filter: ff ? "none" : "blur(80px)", }, ], { @@ -113,7 +124,7 @@ [key: string]: string; } = {}; - const navItems: NavItem[] = [ + $: navItems = [ { name: "Blog", href: "/blog", @@ -134,7 +145,11 @@ name: "GitLab", href: "https://gitlab.com/suyu-emu/", }, - ]; + { + name: $token ? "Account" : "Sign up", + href: $token ? "/account" : "/signup", + }, + ] as NavItem[]; $: { if (browser) { @@ -250,9 +265,9 @@ >