perf: Performance work, add PWA

This commit is contained in:
Jesse Wierzbinski 2024-05-11 21:30:02 -10:00
parent 7d07e639c8
commit 6e8f4ae8e1
No known key found for this signature in database
19 changed files with 76 additions and 45 deletions

View file

@ -1,4 +1,5 @@
<template> <template>
<NuxtPwaAssets />
<NuxtLayout> <NuxtLayout>
<NuxtPage /> <NuxtPage />
</NuxtLayout> </NuxtLayout>
@ -32,6 +33,7 @@ useSeoMeta({
ogDescription: computed(() => convert(description.value?.content ?? "")), ogDescription: computed(() => convert(description.value?.content ?? "")),
ogSiteName: "Lysand", ogSiteName: "Lysand",
colorScheme: "dark", colorScheme: "dark",
themeColor: "#f9a8d4",
}); });
useHead({ useHead({

BIN
bun.lockb

Binary file not shown.

View file

@ -11,7 +11,7 @@
Quoting Quoting
</span> </span>
<OverlayScrollbarsComponent :defer="true" class="mt-2 max-h-72 overflow-y-auto"> <OverlayScrollbarsComponent :defer="true" class="mt-2 max-h-72 overflow-y-auto">
<SocialElementsNotesNote :note="respondingTo" :small="true" :disabled="true" /> <LazySocialElementsNotesNote :note="respondingTo" :small="true" :disabled="true" />
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
</div> </div>
<textarea :disabled="submitting" ref="textarea" v-model="content" :placeholder="chosenSplash" <textarea :disabled="submitting" ref="textarea" v-model="content" :placeholder="chosenSplash"

View file

@ -53,6 +53,11 @@
<Icon name="tabler:letter-n-small" class="size-4 inline -mr-1" aria-hidden="true" /> <Icon name="tabler:letter-n-small" class="size-4 inline -mr-1" aria-hidden="true" />
</kbd> </kbd>
</ButtonsBase> </ButtonsBase>
<ButtonsBase v-if="$pwa?.needRefresh" @click="$pwa?.updateServiceWorker()" title="Update service worker"
class="flex flex-row text-left items-center justify-start gap-3 text-lg ring-2 ring-pink-600 overflow-hidden h-12 w-full duration-200">
<Icon name="tabler:refresh" class="shrink-0 text-2xl" />
<span class="pr-28 line-clamp-1">Update</span>
</ButtonsBase>
</ClientOnly> </ClientOnly>
</div> </div>
</aside> </aside>
@ -83,7 +88,14 @@
<Icon name="tabler:bell" class="text-2xl" /> <Icon name="tabler:bell" class="text-2xl" />
<span class="text-xs">Notifications</span> <span class="text-xs">Notifications</span>
</NuxtLink> </NuxtLink>
<DropdownsAdaptiveDropdown> <ClientOnly v-if="$pwa?.needRefresh">
<button class="flex flex-col items-center justify-center p-2 rounded ring-2 ring-pink-600"
@click="$pwa?.updateServiceWorker(true)">
<Icon name="tabler:refresh" class="text-2xl" />
<span class="text-xs">Update</span>
</button>
</ClientOnly>
<DropdownsAdaptiveDropdown v-else>
<template #button> <template #button>
<HeadlessMenuButton class="flex flex-col items-center justify-center p-2 rounded"> <HeadlessMenuButton class="flex flex-col items-center justify-center p-2 rounded">
<Icon name="tabler:user" class="text-2xl" /> <Icon name="tabler:user" class="text-2xl" />
@ -124,6 +136,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const { $pwa } = useNuxtApp();
const timelines = ref([ const timelines = ref([
{ {
href: "/home", href: "/home",

View file

@ -14,7 +14,7 @@
:attachment="attachment" /> :attachment="attachment" />
</div> </div>
<div v-if="isQuote && note?.reblog" class="mt-4"> <div v-if="isQuote && note?.reblog" class="mt-4">
<SocialElementsNotesNote :note="note?.reblog" :small="true" /> <LazySocialElementsNotesNote :note="note?.reblog" :small="true" />
</div> </div>
</div> </div>
<div v-else <div v-else

View file

@ -14,8 +14,8 @@
</div> </div>
<SocialElementsNotesReplyHeader v-if="isReply" :account_id="note?.in_reply_to_account_id ?? null" /> <SocialElementsNotesReplyHeader v-if="isReply" :account_id="note?.in_reply_to_account_id ?? null" />
<SocialElementsNotesHeader :note="note" :small="small" /> <SocialElementsNotesHeader :note="note" :small="small" />
<SocialElementsNotesNoteContent :note="note" :loaded="loaded" :url="url" :content="content" :is-quote="isQuote" <LazySocialElementsNotesNoteContent :note="note" :loaded="loaded" :url="url" :content="content"
:should-hide="shouldHide" /> :is-quote="isQuote" :should-hide="shouldHide" />
<Skeleton class="!h-10 w-full mt-6" :enabled="!props.note || !loaded" v-if="!small || !showInteractions"> <Skeleton class="!h-10 w-full mt-6" :enabled="!props.note || !loaded" v-if="!small || !showInteractions">
<div v-if="showInteractions" <div v-if="showInteractions"
class="mt-6 flex flex-row items-stretch disabled:*:opacity-70 [&>button]:max-w-28 disabled:*:cursor-not-allowed relative justify-around text-sm h-10 hover:enabled:[&>button]:bg-dark-800 [&>button]:duration-200 [&>button]:rounded [&>button]:flex [&>button]:flex-1 [&>button]:flex-row [&>button]:items-center [&>button]:justify-center"> class="mt-6 flex flex-row items-stretch disabled:*:opacity-70 [&>button]:max-w-28 disabled:*:cursor-not-allowed relative justify-around text-sm h-10 hover:enabled:[&>button]:bg-dark-800 [&>button]:duration-200 [&>button]:rounded [&>button]:flex [&>button]:flex-1 [&>button]:flex-row [&>button]:items-center [&>button]:justify-center">

View file

@ -12,7 +12,7 @@
</Skeleton> </Skeleton>
</div> </div>
<div> <div>
<SocialElementsNotesNote v-if="notification?.status || !notification" :note="notification?.status" <LazySocialElementsNotesNote v-if="notification?.status || !notification" :note="notification?.status"
:small="true" /> :small="true" />
<div v-else-if="notification.account" class="p-6 ring-1 ring-white/5 bg-dark-800"> <div v-else-if="notification.account" class="p-6 ring-1 ring-white/5 bg-dark-800">
<SocialElementsUsersSmallCard :account="notification.account" /> <SocialElementsUsersSmallCard :account="notification.account" />

View file

@ -5,7 +5,7 @@
<SocialElementsNotesNote v-for="note of timeline" :key="note.id" :note="note" /> <SocialElementsNotesNote v-for="note of timeline" :key="note.id" :note="note" />
</TransitionGroup> </TransitionGroup>
<span ref="skeleton"></span> <span ref="skeleton"></span>
<SocialElementsNotesNote 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">

View file

@ -1,16 +1,16 @@
<template> <template>
<div class="from-dark-600 to-dark-900 bg-gradient-to-tl min-h-dvh"> <div class="from-dark-600 to-dark-900 bg-gradient-to-tl min-h-dvh">
<SidebarsNavigation /> <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"> <OverlayScrollbarsComponent :defer="true" class="w-full max-h-dvh overflow-y-auto">
<slot /> <slot />
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
<ClientOnly> <ClientOnly>
<CollapsibleAside v-if="width > 1280 && tokenData" direction="right" <LazySidebarsCollapsibleAside v-if="width > 1280 && tokenData" 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">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<TimelinesNotifications /> <LazyTimelinesLocal />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
<!-- <div class="mt-auto prose prose-invert prose-sm flex flex-col gap-4 px-10 pb-10" v-if="!tokenData"> <!-- <div class="mt-auto prose prose-invert prose-sm flex flex-col gap-4 px-10 pb-10" v-if="!tokenData">
<div class="text-center"> <div class="text-center">
<strong <strong
@ -33,17 +33,15 @@
</ButtonsSecondary> </ButtonsSecondary>
</NuxtLink> </NuxtLink>
</div> --> </div> -->
</CollapsibleAside> </LazySidebarsCollapsibleAside>
</ClientOnly> </ClientOnly>
</div> </div>
</div> </div>
<ComposerModal /> <LazyComposerModal />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import CollapsibleAside from "~/components/sidebars/collapsible-aside.vue";
import { OverlayScrollbarsComponent } from "#imports"; import { OverlayScrollbarsComponent } from "#imports";
const tokenData = useTokenData(); const tokenData = useTokenData();
const { width } = useWindowSize(); const { width } = useWindowSize();

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="from-dark-600 to-dark-900 bg-gradient-to-tl min-h-dvh pb-20 md:pb-0"> <div class="from-dark-600 to-dark-900 bg-gradient-to-tl min-h-dvh pb-20 md:pb-0">
<SidebarsNavigation /> <LazySidebarsNavigation />
<slot /> <slot />
</div> </div>
</template> </template>

View file

@ -10,7 +10,19 @@ export default defineNuxtConfig({
//"nuxt-shiki", //"nuxt-shiki",
"@vee-validate/nuxt", "@vee-validate/nuxt",
"nuxt-security", "nuxt-security",
"@vite-pwa/nuxt",
], ],
pwa: {
manifest: {
name: "Lysand",
short_name: "Lysand",
description: "Frontend for the Lysand social network",
theme_color: "#f9a8d4",
display: "standalone",
lang: "en",
categories: ["social", "development"],
},
},
security: { security: {
headers: { headers: {
// Nuxt DevTools // Nuxt DevTools
@ -41,6 +53,11 @@ export default defineNuxtConfig({
href: "/favicon.png", href: "/favicon.png",
type: "image/png", type: "image/png",
}, },
{
rel: "apple-touch-icon",
href: "/favicon.png",
type: "image/png",
},
], ],
htmlAttrs: { lang: "en-us" }, htmlAttrs: { lang: "en-us" },
}, },

View file

@ -31,6 +31,7 @@
"@tailwindcss/typography": "^0.5.12", "@tailwindcss/typography": "^0.5.12",
"@vee-validate/nuxt": "^4.12.6", "@vee-validate/nuxt": "^4.12.6",
"@vee-validate/zod": "^4.12.6", "@vee-validate/zod": "^4.12.6",
"@vite-pwa/nuxt": "^0.7.0",
"c12": "^1.10.0", "c12": "^1.10.0",
"html-to-text": "^9.0.5", "html-to-text": "^9.0.5",
"megalodon": "^10.0.0", "megalodon": "^10.0.0",

View file

@ -1,14 +1,14 @@
<template> <template>
<ClientOnly> <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">
<SocialElementsNotesNote 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">
<SocialElementsNotesNote class="!rounded-none border-2 border-pink-500" v-if="note" :note="note" /> <LazySocialElementsNotesNote class="!rounded-none border-2 border-pink-500" v-if="note" :note="note" />
</div> </div>
<SocialElementsNotesNote v-for="note of context?.descendants" :note="note" /> <LazySocialElementsNotesNote v-for="note of context?.descendants" :note="note" />
</div> </div>
<div :defer="true" 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">
<SocialElementsNotesNote v-for="_ of 5" :skeleton="true" /> <LazySocialElementsNotesNote v-for="_ of 5" :skeleton="true" />
</div> </div>
</ClientOnly> </ClientOnly>
</template> </template>

View file

@ -1,9 +1,9 @@
<template> <template>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<SocialElementsUsersAccount :account="account ?? undefined" /> <LazySocialElementsUsersAccount :account="account ?? undefined" />
<TimelinesAccount :id="accountId" :key="accountId" /> <LazyTimelinesAccount :id="accountId" :key="accountId" />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</template> </template>

View file

@ -1,9 +1,9 @@
<template> <template>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<HeadersGreeting /> <LazyHeadersGreeting />
<TimelinesHome /> <LazyTimelinesHome />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</template> </template>

View file

@ -1,9 +1,9 @@
<template> <template>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<HeadersGreeting /> <LazyHeadersGreeting />
<TimelinesPublic /> <LazyTimelinesPublic />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</template> </template>

View file

@ -1,9 +1,9 @@
<template> <template>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<HeadersGreeting /> <LazyHeadersGreeting />
<TimelinesLocal /> <LazyTimelinesLocal />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</template> </template>

View file

@ -12,12 +12,12 @@
sign in</span> sign in</span>
</button> </button>
</div> </div>
<TimelinesTimelineScroller v-else> <LazyTimelinesTimelineScroller v-else>
<HeadersGreeting /> <LazyHeadersGreeting />
<div class="rounded overflow-hidden ring-1 ring-white/10"> <div class="rounded overflow-hidden ring-1 ring-white/10">
<TimelinesNotifications /> <LazyTimelinesNotifications />
</div> </div>
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</ClientOnly> </ClientOnly>
</template> </template>

View file

@ -1,9 +1,9 @@
<template> <template>
<div class="mx-auto max-w-2xl w-full"> <div class="mx-auto max-w-2xl w-full">
<TimelinesTimelineScroller> <LazyTimelinesTimelineScroller>
<HeadersGreeting /> <LazyHeadersGreeting />
<TimelinesPublic /> <TimelinesPublic />
</TimelinesTimelineScroller> </LazyTimelinesTimelineScroller>
</div> </div>
</template> </template>