feat: Make whole app client-only, add noscript fallback

This commit is contained in:
Jesse Wierzbinski 2024-06-15 11:18:58 -10:00
parent 961eccafa0
commit 2266dcd725
No known key found for this signature in database
19 changed files with 597 additions and 604 deletions

View file

@ -4,10 +4,15 @@
<PwaAppleImage image="/logo.webp" /> <PwaAppleImage image="/logo.webp" />
<PwaMaskableImage image="/logo.webp" /> <PwaMaskableImage image="/logo.webp" />
<Loading /> <Loading />
<ClientOnly>
<NuxtLayout> <NuxtLayout>
<NuxtPage /> <NuxtPage />
</NuxtLayout> </NuxtLayout>
</ClientOnly>
<NotificationsRenderer /> <NotificationsRenderer />
<noscript>
<ErrorsNoscript />
</noscript>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">

View file

@ -0,0 +1,23 @@
<template>
<div id="noscript-error"
class="grid min-h-screen place-items-center px-6 py-24 sm:py-32 lg:px-8 fixed inset-0 z-[1000000] bg-dark-900">
<GraphicsSquarePattern />
<div class="prose prose-invert max-w-lg">
<h1 class="mt-4 text-3xl font-bold tracking-tight text-gray-100 sm:text-5xl">JavaScript is disabled
</h1>
<p class="mt-6 text-base leading-7 text-gray-400">
This website requires JavaScript to function properly. Please enable JavaScript in your browser
settings.
</p>
<p class="mt-6 text-base leading-7 text-gray-400">
If you are using a browser that does not support JavaScript, please consider using a modern browser
like <a href="https://www.mozilla.org/firefox/new/" class="underline">Firefox</a> or <a
href="https://www.google.com/chrome/" class="underline">Chrome</a>.
</p>
<p class="mt-6 text-base leading-7 text-gray-400">
This application does not track you, collect user data, use cookies of any kind or send requests to
servers outside of your account's instance.
</p>
</div>
</div>
</template>

View file

@ -0,0 +1,19 @@
<template>
<svg class="absolute inset-0 h-full w-full stroke-white/10 [mask-image:radial-gradient(100%_100%_at_top_right,white,transparent)]"
aria-hidden="true">
<defs>
<pattern id="983e3e4c-de6d-4c3f-8d64-b9761d1534cc" width="200" height="200" x="50%" y="-1"
patternUnits="userSpaceOnUse">
<path d="M.5 200V.5H200" fill="none"></path>
</pattern>
</defs><svg x="50%" y="-1" class="overflow-visible fill-gray-800/20">
<path d="M-200 0h201v201h-201Z M600 0h201v201h-201Z M-400 600h201v201h-201Z M200 800h201v201h-201Z"
stroke-width="0"></path>
</svg>
<rect width="100%" height="100%" stroke-width="0" fill="url(#983e3e4c-de6d-4c3f-8d64-b9761d1534cc)"></rect>
</svg>
</template>
<script lang="ts" setup>
</script>

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div v-if="identity" class="bg-dark-800 z-0 p-6 my-5 relative overflow-hidden rounded ring-1 ring-white/5"> <div v-if="identity" class="bg-dark-800 z-0 p-6 my-5 relative overflow-hidden rounded ring-1 ring-white/5">
<div class="sm:flex sm:items-center sm:justify-between gap-3"> <div class="sm:flex sm:items-center sm:justify-between gap-3">
<div class="sm:flex sm:space-x-5 grow"> <div class="sm:flex sm:space-x-5 grow">
@ -20,7 +19,6 @@
</div> --> </div> -->
</div> </div>
</div> </div>
</ClientOnly>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>

View file

@ -3,7 +3,7 @@
<!-- Progress bar stuck to top --> <!-- Progress bar stuck to top -->
<div class="fixed top-0 left-0 right-0 h-1.5 bg-pink-500" :style="{ width: `${progress}%` }"></div> <div class="fixed top-0 left-0 right-0 h-1.5 bg-pink-500" :style="{ width: `${progress}%` }"></div>
<div class="flex flex-col items-center justify-center gap-8"> <div class="flex flex-col items-center justify-center gap-8">
<img src="/logo.webp" class="size-20 animate-pulse" /> <img src="/logo.webp" class="size-20 animate-pulse" role="presentation" />
</div> </div>
</div> </div>
</template> </template>

View file

@ -4,13 +4,13 @@
aria-label="Navigation" role="complementary"> aria-label="Navigation" role="complementary">
<NuxtLink href="/"> <NuxtLink href="/">
<img crossorigin="anonymous" class="size-11 rounded ring-1 ring-white/10 hover:scale-105 duration-200" <img crossorigin="anonymous" class="size-11 rounded ring-1 ring-white/10 hover:scale-105 duration-200"
src="/logo.webp" alt="Lysand logo" /> :src="instance?.thumbnail.url ?? '/logo.webp'" alt="Logo of your instance" />
</NuxtLink> </NuxtLink>
<div class="flex flex-col gap-3"> <div class="flex flex-col gap-3">
<h3 class="font-semibold text-gray-300 text-xs uppercase opacity-0 group-hover:opacity-100 duration-200"> <h3 class="font-semibold text-gray-300 text-xs uppercase opacity-0 group-hover:opacity-100 duration-200">
Timelines</h3> Timelines</h3>
<ClientOnly>
<NuxtLink v-for="timeline in visibleTimelines" :key="timeline.href" :to="timeline.href"> <NuxtLink v-for="timeline in visibleTimelines" :key="timeline.href" :to="timeline.href">
<ButtonsBase <ButtonsBase
class="flex flex-row text-left items-center justify-start gap-3 text-lg hover:ring-1 ring-white/10 overflow-hidden h-12 w-full duration-200"> class="flex flex-row text-left items-center justify-start gap-3 text-lg hover:ring-1 ring-white/10 overflow-hidden h-12 w-full duration-200">
@ -18,13 +18,13 @@
<span class="pr-28 line-clamp-1">{{ timeline.name }}</span> <span class="pr-28 line-clamp-1">{{ timeline.name }}</span>
</ButtonsBase> </ButtonsBase>
</NuxtLink> </NuxtLink>
</ClientOnly>
</div> </div>
<div class="flex flex-col gap-3 mt-auto"> <div class="flex flex-col gap-3 mt-auto">
<h3 class="font-semibold text-gray-300 text-xs uppercase opacity-0 group-hover:opacity-100 duration-200"> <h3 class="font-semibold text-gray-300 text-xs uppercase opacity-0 group-hover:opacity-100 duration-200">
Account</h3> Account</h3>
<ClientOnly>
<SidebarsAccountPicker @sign-in="signIn().finally(() => loadingAuth = false)" <SidebarsAccountPicker @sign-in="signIn().finally(() => loadingAuth = false)"
@sign-out="id => signOut(id).finally(() => loadingAuth = false)" /> @sign-out="id => signOut(id).finally(() => loadingAuth = false)" />
<NuxtLink href="/register" v-if="!identity"> <NuxtLink href="/register" v-if="!identity">
@ -42,8 +42,7 @@
<iconify-icon icon="tabler:writing" class="shrink-0 text-2xl" /> <iconify-icon icon="tabler:writing" class="shrink-0 text-2xl" />
<span class="pr-28 line-clamp-1">Compose</span> <span class="pr-28 line-clamp-1">Compose</span>
<kbd class="text-xs font-semibold rounded bg-dark-500 font-mono px-1 flex flex-row"> <kbd class="text-xs font-semibold rounded bg-dark-500 font-mono px-1 flex flex-row">
<iconify-icon icon="tabler:keyboard" height="1rem" width="1rem" class="inline" <iconify-icon icon="tabler:keyboard" height="1rem" width="1rem" class="inline" aria-hidden="true" />
aria-hidden="true" />
<iconify-icon icon="tabler:letter-n-small" height="1rem" width="1rem" class="inline -mr-1" <iconify-icon icon="tabler:letter-n-small" height="1rem" width="1rem" class="inline -mr-1"
aria-hidden="true" /> aria-hidden="true" />
</kbd> </kbd>
@ -53,13 +52,13 @@
<iconify-icon icon="tabler:refresh" class="shrink-0 text-2xl" /> <iconify-icon icon="tabler:refresh" class="shrink-0 text-2xl" />
<span class="pr-28 line-clamp-1">Update</span> <span class="pr-28 line-clamp-1">Update</span>
</ButtonsBase> </ButtonsBase>
</ClientOnly>
</div> </div>
</aside> </aside>
<!-- Mobile bottom navbar --> <!-- Mobile bottom navbar -->
<nav <nav
class="fixed bottom-0 left-0 right-0 z-20 md:hidden flex justify-around p-2 *:shadow-xl bg-dark-900 ring-1 ring-white/10 text-gray-200"> class="fixed bottom-0 left-0 right-0 z-20 md:hidden flex justify-around p-2 *:shadow-xl bg-dark-900 ring-1 ring-white/10 text-gray-200">
<ClientOnly>
<DropdownsAdaptiveDropdown> <DropdownsAdaptiveDropdown>
<template #button> <template #button>
<button class="flex flex-col items-center justify-center p-2 rounded"> <button class="flex flex-col items-center justify-center p-2 rounded">
@ -82,13 +81,13 @@
<iconify-icon icon="tabler:bell" class="text-2xl" /> <iconify-icon icon="tabler:bell" class="text-2xl" />
<span class="text-xs">Notifications</span> <span class="text-xs">Notifications</span>
</NuxtLink> </NuxtLink>
<ClientOnly v-if="$pwa?.needRefresh"> <button v-if="$pwa?.needRefresh"
<button class="flex flex-col items-center justify-center p-2 rounded ring-2 ring-pink-600" class="flex flex-col items-center justify-center p-2 rounded ring-2 ring-pink-600"
@click="$pwa?.updateServiceWorker(true)"> @click="$pwa?.updateServiceWorker(true)">
<iconify-icon icon="tabler:refresh" class="text-2xl" /> <iconify-icon icon="tabler:refresh" class="text-2xl" />
<span class="text-xs">Update</span> <span class="text-xs">Update</span>
</button> </button>
</ClientOnly>
<SidebarsAccountPicker v-else @sign-in="signIn().finally(() => loadingAuth = false)" <SidebarsAccountPicker v-else @sign-in="signIn().finally(() => loadingAuth = false)"
@sign-out="id => signOut(id).finally(() => loadingAuth = false)"> @sign-out="id => signOut(id).finally(() => loadingAuth = false)">
<button class="flex flex-col items-center justify-center p-2 rounded"> <button class="flex flex-col items-center justify-center p-2 rounded">
@ -101,7 +100,6 @@
<iconify-icon icon="tabler:writing" class="text-2xl" /> <iconify-icon icon="tabler:writing" class="text-2xl" />
<span class="text-xs">Compose</span> <span class="text-xs">Compose</span>
</button> </button>
</ClientOnly>
</nav> </nav>
</template> </template>
@ -145,6 +143,7 @@ const appData = useAppData();
const identity = useCurrentIdentity(); const identity = useCurrentIdentity();
const identities = useIdentities(); const identities = useIdentities();
const client = useClient(); const client = useClient();
const instance = useInstance();
const compose = () => { const compose = () => {
useEvent("composer:open"); useEvent("composer:open");

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div class="w-full ring-1 ring-inset ring-white/5 pb-10 bg-dark-800"> <div class="w-full ring-1 ring-inset ring-white/5 pb-10 bg-dark-800">
<AvatarsCentered :src="account?.header" :alt="`${account?.acct}'s header image'`" <AvatarsCentered :src="account?.header" :alt="`${account?.acct}'s header image'`"
class="w-full aspect-[8/3] border-b border-white/10 bg-dark-700 !rounded-none" /> class="w-full aspect-[8/3] border-b border-white/10 bg-dark-700 !rounded-none" />
@ -8,7 +7,6 @@
<AvatarsCentered :src="account?.avatar" :alt="`${account?.acct}'s avatar'`" <AvatarsCentered :src="account?.avatar" :alt="`${account?.acct}'s avatar'`"
class="h-32 w-32 -mt-[4.5rem] z-10 shrink-0 rounded ring-2 ring-dark-800" /> class="h-32 w-32 -mt-[4.5rem] z-10 shrink-0 rounded ring-2 ring-dark-800" />
<ClientOnly>
<ButtonsSecondary v-if="account && account?.id === identity?.account?.id">Edit Profile <ButtonsSecondary v-if="account && account?.id === identity?.account?.id">Edit Profile
</ButtonsSecondary> </ButtonsSecondary>
<ButtonsSecondary :loading="isLoading" @click="follow()" <ButtonsSecondary :loading="isLoading" @click="follow()"
@ -23,7 +21,6 @@
v-if="account && account?.id !== identity?.account?.id && relationship && !relationship.following && relationship.requested"> v-if="account && account?.id !== identity?.account?.id && relationship && !relationship.following && relationship.requested">
<span>Requested</span> <span>Requested</span>
</ButtonsSecondary> </ButtonsSecondary>
</ClientOnly>
</div> </div>
<div class="mt-2 px-4"> <div class="mt-2 px-4">
@ -98,7 +95,6 @@
</div> </div>
</div> </div>
</div> </div>
</ClientOnly>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>

View file

@ -1,16 +1,12 @@
<template> <template>
<ClientOnly>
<SocialElementsNotificationsNotif v-for="notif of timeline" :key="notif.id" :notification="notif" /> <SocialElementsNotificationsNotif v-for="notif of timeline" :key="notif.id" :notification="notif" />
<span ref="skeleton"></span> <span ref="skeleton"></span>
<SocialElementsNotificationsNotif v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" /> <SocialElementsNotificationsNotif v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" />
<div v-if="hasReachedEnd" <div v-if="hasReachedEnd" class="text-center flex flex-row justify-center items-center py-10 text-gray-400 gap-3">
class="text-center flex flex-row justify-center items-center py-10 text-gray-400 gap-3">
<iconify-icon name="tabler:message-off" width="1.5rem" height="1.5rem" /> <iconify-icon name="tabler:message-off" width="1.5rem" height="1.5rem" />
<span>No more notifications, you've seen them all</span> <span>No more notifications, you've seen them all</span>
</div> </div>
</ClientOnly>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -29,7 +25,7 @@ const skeleton = ref<HTMLSpanElement | null>(null);
onMounted(() => { onMounted(() => {
useIntersectionObserver(skeleton, async (entries) => { useIntersectionObserver(skeleton, async (entries) => {
if ( if (
entries[0].isIntersecting && entries[0]?.isIntersecting &&
!hasReachedEnd.value && !hasReachedEnd.value &&
!isLoading.value !isLoading.value
) { ) {

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<TransitionGroup leave-active-class="ease-in duration-200" leave-from-class="scale-100 opacity-100" <TransitionGroup leave-active-class="ease-in duration-200" leave-from-class="scale-100 opacity-100"
leave-to-class="opacity-0 scale-90"> leave-to-class="opacity-0 scale-90">
<SocialElementsNotesNote v-for="note of timeline" :key="note.id" :note="note" /> <SocialElementsNotesNote v-for="note of timeline" :key="note.id" :note="note" />
@ -7,12 +6,10 @@
<span ref="skeleton"></span> <span ref="skeleton"></span>
<LazySocialElementsNotesNote v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" /> <LazySocialElementsNotesNote v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" />
<div v-if="hasReachedEnd" <div v-if="hasReachedEnd" class="text-center flex flex-row justify-center items-center py-10 text-gray-400 gap-3">
class="text-center flex flex-row justify-center items-center py-10 text-gray-400 gap-3">
<iconify-icon icon="tabler:message-off" width="1.5rem" height="1.5rem" /> <iconify-icon icon="tabler:message-off" width="1.5rem" height="1.5rem" />
<span>No more posts, you've seen them all</span> <span>No more posts, you've seen them all</span>
</div> </div>
</ClientOnly>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -32,7 +29,7 @@ const skeleton = ref<HTMLSpanElement | null>(null);
onMounted(() => { onMounted(() => {
useIntersectionObserver(skeleton, async (entries) => { useIntersectionObserver(skeleton, async (entries) => {
if ( if (
entries[0].isIntersecting && entries[0]?.isIntersecting &&
!hasReachedEnd.value && !hasReachedEnd.value &&
!isLoading.value !isLoading.value
) { ) {

View file

@ -2,10 +2,9 @@ import type { LysandClient } from "@lysand-org/client";
import { type RolePermissions, useCurrentIdentity } from "./Identities"; import { type RolePermissions, useCurrentIdentity } from "./Identities";
export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => { export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
if (process.server) return; if (import.meta.server) return;
const identity = useCurrentIdentity(); const identity = useCurrentIdentity();
const instance = useInstance();
// Refresh custom emojis and instance data and me on every reload // Refresh custom emojis and instance data and me on every reload
watchEffect(async () => { watchEffect(async () => {
@ -56,7 +55,7 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
toValue(client) toValue(client)
?.getInstance() ?.getInstance()
.then((res) => { .then((res) => {
instance.value = res.data; if (identity.value) identity.value.instance = res.data;
}); });
}); });
}; };

View file

@ -1,15 +1,10 @@
import type { LysandClient } from "@lysand-org/client"; import type { LysandClient } from "@lysand-org/client";
import { StorageSerializers } from "@vueuse/core";
// Return type of LysandClient.getInstance // Return type of LysandClient.getInstance
export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"]; export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"];
export const useInstance = () => { export const useInstance = () => {
if (process.server) { const identity = useCurrentIdentity();
return ref(null);
}
return useLocalStorage<Instance | null>("lysand:instance", null, { return computed(() => identity.value?.instance);
serializer: StorageSerializers.object,
});
}; };

View file

@ -1,25 +1,12 @@
<template> <template>
<div class="from-dark-600 to-dark-900 bg-gradient-to-tl relative min-h-dvh"> <div class="from-dark-600 to-dark-900 bg-gradient-to-tl relative min-h-dvh">
<svg class="absolute inset-0 h-full w-full stroke-white/10 [mask-image:radial-gradient(100%_100%_at_top_right,white,transparent)]" <GraphicsSquarePattern />
aria-hidden="true">
<defs>
<pattern id="983e3e4c-de6d-4c3f-8d64-b9761d1534cc" width="200" height="200" x="50%" y="-1"
patternUnits="userSpaceOnUse">
<path d="M.5 200V.5H200" fill="none"></path>
</pattern>
</defs><svg x="50%" y="-1" class="overflow-visible fill-gray-800/20">
<path d="M-200 0h201v201h-201Z M600 0h201v201h-201Z M-400 600h201v201h-201Z M200 800h201v201h-201Z"
stroke-width="0"></path>
</svg>
<rect width="100%" height="100%" stroke-width="0" fill="url(#983e3e4c-de6d-4c3f-8d64-b9761d1534cc)"></rect>
</svg>
<LazySidebarsNavigation /> <LazySidebarsNavigation />
<div class="relative md:pl-20 min-h-dvh flex flex-row overflow-hidden justify-center xl:justify-between"> <div class="relative md:pl-20 min-h-dvh flex flex-row overflow-hidden justify-center xl:justify-between">
<OverlayScrollbarsComponent :defer="true" class="w-full max-h-dvh overflow-y-auto" :element="'main'"> <OverlayScrollbarsComponent :defer="true" class="w-full max-h-dvh overflow-y-auto" :element="'main'">
<slot /> <slot />
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
<ClientOnly>
<LazySidebarsCollapsibleAside v-if="width > 1280 && identity" direction="right" <LazySidebarsCollapsibleAside v-if="width > 1280 && identity" direction="right"
class="max-w-md max-h-dvh overflow-y-auto w-full hidden absolute inset-y-0 xl:flex"> class="max-w-md max-h-dvh overflow-y-auto w-full hidden absolute inset-y-0 xl:flex">
<LazyTimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
@ -48,7 +35,6 @@
</NuxtLink> </NuxtLink>
</div> --> </div> -->
</LazySidebarsCollapsibleAside> </LazySidebarsCollapsibleAside>
</ClientOnly>
</div> </div>
</div> </div>
<LazyComposerModal /> <LazyComposerModal />

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div v-if="loaded" :defer="true" class="mx-auto max-w-2xl w-full pb-72"> <div v-if="loaded" :defer="true" class="mx-auto max-w-2xl w-full pb-72">
<LazySocialElementsNotesNote v-for="note of context?.ancestors" :note="note" /> <LazySocialElementsNotesNote v-for="note of context?.ancestors" :note="note" />
<div ref="element" class="first:rounded-t last:rounded-b overflow-hidden"> <div ref="element" class="first:rounded-t last:rounded-b overflow-hidden">
@ -10,7 +9,6 @@
<div v-else class="mx-auto max-w-2xl w-full overflow-y-auto"> <div v-else class="mx-auto max-w-2xl w-full overflow-y-auto">
<LazySocialElementsNotesNote v-for="_ of 5" :skeleton="true" /> <LazySocialElementsNotesNote v-for="_ of 5" :skeleton="true" />
</div> </div>
</ClientOnly>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<div class="shrink-0 p-10 h-dvh" v-if="!identity"> <div class="shrink-0 p-10 h-dvh" v-if="!identity">
<button type="button" <button type="button"
@ -19,7 +18,6 @@
</div> </div>
</LazyTimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</ClientOnly>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>

View file

@ -2,7 +2,6 @@
<div class="flex min-h-screen relative flex-col justify-center py-12 px-8"> <div class="flex min-h-screen relative flex-col justify-center py-12 px-8">
<img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo" <img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo"
class="mx-auto h-24 hidden md:block mb-10" /> class="mx-auto h-24 hidden md:block mb-10" />
<ClientOnly>
<div v-if="validUrlParameters" <div v-if="validUrlParameters"
class="sm:mx-auto w-full sm:max-w-md px-10 py-10 rounded md:ring-1 md:ring-white/10"> class="sm:mx-auto w-full sm:max-w-md px-10 py-10 rounded md:ring-1 md:ring-white/10">
<div v-if="error" class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10"> <div v-if="error" class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10">
@ -16,8 +15,7 @@
<VeeField name="identifier" as="div" v-slot="{ errors, field }" validate-on-change> <VeeField name="identifier" as="div" v-slot="{ errors, field }" validate-on-change>
<LoginInput label="Username or Email" placeholder="joemama" autocomplete="email" required <LoginInput label="Username or Email" placeholder="joemama" autocomplete="email" required
:is-invalid="errors.length > 0" v-bind="field" /> :is-invalid="errors.length > 0" v-bind="field" />
<VeeErrorMessage name="identifier" as="p" class="mt-2 text-sm text-red-600" <VeeErrorMessage name="identifier" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }">
v-slot="{ message }">
{{ message }} {{ message }}
</VeeErrorMessage> </VeeErrorMessage>
</VeeField> </VeeField>
@ -81,7 +79,6 @@
target="_blank" class="underline text-pink-700">the issue tracker</a>. target="_blank" class="underline text-pink-700">the issue tracker</a>.
</p> </p>
</div> </div>
</ClientOnly>
</div> </div>
</template> </template>

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div class="flex min-h-screen relative flex-col justify-center px-6 py-12 lg:px-8"> <div class="flex min-h-screen relative flex-col justify-center px-6 py-12 lg:px-8">
<div class="mx-auto max-w-md mt-10"> <div class="mx-auto max-w-md mt-10">
@ -21,7 +20,6 @@
</p> </p>
</div> </div>
</div> </div>
</ClientOnly>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">

View file

@ -1,11 +1,8 @@
<template> <template>
<ClientOnly>
<div class="flex min-h-screen relative flex-col justify-center px-6 py-12 lg:px-8"> <div class="flex min-h-screen relative flex-col justify-center px-6 py-12 lg:px-8">
<div v-if="validUrlParameters" class="sm:mx-auto sm:w-full sm:max-w-sm"> <div v-if="validUrlParameters" class="sm:mx-auto sm:w-full sm:max-w-sm">
<form class="space-y-6" method="POST" <form class="space-y-6" method="POST" :action="url.pathname.replace('/oauth/consent', '/oauth/authorize')">
:action="url.pathname.replace('/oauth/consent', '/oauth/authorize')"> <input type="hidden" v-for="([key, value]) in url.searchParams" :key="key" :name="key" :value="value" />
<input type="hidden" v-for="([key, value]) in url.searchParams" :key="key" :name="key"
:value="value" />
<div class="flex flex-col items-center gap-y-5"> <div class="flex flex-col items-center gap-y-5">
<h1 class="font-bold text-2xl text-gray-50 text-center tracking-tight">Allow this application to <h1 class="font-bold text-2xl text-gray-50 text-center tracking-tight">Allow this application to
access your access your
@ -83,7 +80,6 @@
</p> </p>
</div> </div>
</div> </div>
</ClientOnly>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -136,43 +132,43 @@ const getScopeText = (fullScopes: string[]) => {
const [scopeAction, scopeName] = possibleScope.split(":"); const [scopeAction, scopeName] = possibleScope.split(":");
if ( if (
scopeAction.includes("rw") && scopeAction?.includes("rw") &&
(readScopes.includes(`read:${scopeName}`) || (readScopes.includes(`read:${scopeName}`) ||
readScopes.find((scope) => scope === "read")) && readScopes.find((scope) => scope === "read")) &&
(writeScopes.includes(`write:${scopeName}`) || (writeScopes.includes(`write:${scopeName}`) ||
writeScopes.find((scope) => scope === "write")) writeScopes.find((scope) => scope === "write"))
) { ) {
if (oauthScopeText[possibleScope].includes("$VERB")) if (oauthScopeText[possibleScope]?.includes("$VERB"))
scopeTexts.push([ scopeTexts.push([
"Read and write", "Read and write",
oauthScopeText[possibleScope].replace("$VERB", ""), oauthScopeText[possibleScope]?.replace("$VERB", ""),
]); ]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]); else scopeTexts.push(["", oauthScopeText[possibleScope]]);
continue; continue;
} }
if ( if (
scopeAction.includes("r") && scopeAction?.includes("r") &&
(readScopes.includes(`read:${scopeName}`) || (readScopes.includes(`read:${scopeName}`) ||
readScopes.find((scope) => scope === "read")) readScopes.find((scope) => scope === "read"))
) { ) {
if (oauthScopeText[possibleScope].includes("$VERB")) if (oauthScopeText[possibleScope]?.includes("$VERB"))
scopeTexts.push([ scopeTexts.push([
"Read", "Read",
oauthScopeText[possibleScope].replace("$VERB", ""), oauthScopeText[possibleScope]?.replace("$VERB", ""),
]); ]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]); else scopeTexts.push(["", oauthScopeText[possibleScope]]);
} }
if ( if (
scopeAction.includes("w") && scopeAction?.includes("w") &&
(writeScopes.includes(`write:${scopeName}`) || (writeScopes.includes(`write:${scopeName}`) ||
writeScopes.find((scope) => scope === "write")) writeScopes.find((scope) => scope === "write"))
) { ) {
if (oauthScopeText[possibleScope].includes("$VERB")) if (oauthScopeText[possibleScope]?.includes("$VERB"))
scopeTexts.push([ scopeTexts.push([
"Write", "Write",
oauthScopeText[possibleScope].replace("$VERB", ""), oauthScopeText[possibleScope]?.replace("$VERB", ""),
]); ]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]); else scopeTexts.push(["", oauthScopeText[possibleScope]]);
} }

View file

@ -2,7 +2,6 @@
<div class="flex min-h-screen relative flex-col justify-center py-12 px-8"> <div class="flex min-h-screen relative flex-col justify-center py-12 px-8">
<img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo" <img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo"
class="mx-auto h-24 hidden md:block mb-10" /> class="mx-auto h-24 hidden md:block mb-10" />
<ClientOnly>
<div v-if="validUrlParameters" <div v-if="validUrlParameters"
class="sm:mx-auto w-full sm:max-w-md px-10 py-10 rounded md:ring-1 md:ring-white/10"> class="sm:mx-auto w-full sm:max-w-md px-10 py-10 rounded md:ring-1 md:ring-white/10">
<div v-if="error" class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10"> <div v-if="error" class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10">
@ -58,7 +57,6 @@
target="_blank" class="underline text-pink-700">the issue tracker</a>. target="_blank" class="underline text-pink-700">the issue tracker</a>.
</p> </p>
</div> </div>
</ClientOnly>
</div> </div>
</template> </template>

View file

@ -1,5 +1,4 @@
<template> <template>
<ClientOnly>
<div class="flex min-h-screen flex-col justify-center px-6 py-12 gap-10 lg:px-8 relative"> <div class="flex min-h-screen flex-col justify-center px-6 py-12 gap-10 lg:px-8 relative">
<img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo" <img crossorigin="anonymous" src="https://cdn.lysand.org/logo-long-dark.webp" alt="Lysand logo"
class="mx-auto h-24 hidden md:block" /> class="mx-auto h-24 hidden md:block" />
@ -21,17 +20,16 @@
</VeeField> </VeeField>
<VeeField name="username" as="div" v-slot="{ errors, field }" validate-on-change> <VeeField name="username" as="div" v-slot="{ errors, field }" validate-on-change>
<LoginInput label="Username" placeholder="thespeedy" type="text" autocomplete="username" <LoginInput label="Username" placeholder="thespeedy" type="text" autocomplete="username" required
required :is-invalid="errors.length > 0" v-bind="field" :disabled="isLoading" /> :is-invalid="errors.length > 0" v-bind="field" :disabled="isLoading" />
<VeeErrorMessage name="username" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }"> <VeeErrorMessage name="username" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }">
{{ message }} (must only contain lowercase letters, numbers and underscores) {{ message }} (must only contain lowercase letters, numbers and underscores)
</VeeErrorMessage> </VeeErrorMessage>
</VeeField> </VeeField>
<VeeField name="password" as="div" v-slot="{ errors, field }" validate-on-change> <VeeField name="password" as="div" v-slot="{ errors, field }" validate-on-change>
<LoginInput label="Password" placeholder="hunter2" type="password" <LoginInput label="Password" placeholder="hunter2" type="password" autocomplete="current-password"
autocomplete="current-password" required :is-invalid="errors.length > 0" v-bind="field" required :is-invalid="errors.length > 0" v-bind="field" :disabled="isLoading" />
:disabled="isLoading" />
<VeeErrorMessage name="password" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }"> <VeeErrorMessage name="password" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }">
{{ message }} {{ message }}
</VeeErrorMessage> </VeeErrorMessage>
@ -50,8 +48,8 @@
<label for="reason" class="block text-sm font-medium leading-6 text-gray-50">Why do you want to <label for="reason" class="block text-sm font-medium leading-6 text-gray-50">Why do you want to
join?</label> join?</label>
<div class="mt-2"> <div class="mt-2">
<textarea rows="4" required :is-invalid="errors.length > 0" name="reason" <textarea rows="4" required :is-invalid="errors.length > 0" name="reason" :disabled="isLoading"
:disabled="isLoading" placeholder="Brief text (optional)" placeholder="Brief text (optional)"
class="block w-full disabled:opacity-70 disabled:hover:cursor-wait bg-dark-500 rounded-md border-0 py-1.5 text-gray-50 shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-pink-600 sm:text-sm sm:leading-6" /> class="block w-full disabled:opacity-70 disabled:hover:cursor-wait bg-dark-500 rounded-md border-0 py-1.5 text-gray-50 shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-pink-600 sm:text-sm sm:leading-6" />
</div> </div>
<VeeErrorMessage name="reason" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }"> <VeeErrorMessage name="reason" as="p" class="mt-2 text-sm text-red-600" v-slot="{ message }">
@ -83,12 +81,10 @@
</p> </p>
</div> </div>
</div> </div>
</ClientOnly>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { toTypedSchema } from "@vee-validate/zod"; import { toTypedSchema } from "@vee-validate/zod";
import type { AxiosError } from "axios";
import { z } from "zod"; import { z } from "zod";
import LoginInput from "../../components/LoginInput.vue"; import LoginInput from "../../components/LoginInput.vue";
// TODO: Add instance TOS link // TODO: Add instance TOS link
@ -150,7 +146,6 @@ const register = (result: {
navigateTo("/register/success"); navigateTo("/register/success");
}) })
.catch(async (err) => { .catch(async (err) => {
const error = err as AxiosError;
// @ts-ignore // @ts-ignore
errors.value = error.response?.data || {}; errors.value = error.response?.data || {};
console.error(err); console.error(err);