1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-14 17:37:27 +00:00

fix: only animate login background on initial page load

This commit is contained in:
Elias Schneider
2025-10-24 10:39:52 +02:00
parent 9fc45930a8
commit b356cef766
7 changed files with 16 additions and 15 deletions

View File

@@ -1,23 +1,29 @@
<script lang="ts"> <script lang="ts">
import { afterNavigate } from '$app/navigation';
import { page } from '$app/state'; import { page } from '$app/state';
import { m } from '$lib/paraglide/messages'; import { m } from '$lib/paraglide/messages';
import appConfigStore from '$lib/stores/application-configuration-store'; import appConfigStore from '$lib/stores/application-configuration-store';
import { cachedBackgroundImage } from '$lib/utils/cached-image-util'; import { cachedBackgroundImage } from '$lib/utils/cached-image-util';
import { cn } from '$lib/utils/style'; import { cn } from '$lib/utils/style';
import type { Snippet } from 'svelte'; import { type Snippet } from 'svelte';
import { MediaQuery } from 'svelte/reactivity'; import { MediaQuery } from 'svelte/reactivity';
import * as Card from './ui/card'; import * as Card from './ui/card';
let { let {
children, children,
showAlternativeSignInMethodButton = false, showAlternativeSignInMethodButton = false
animate = false
}: { }: {
children: Snippet; children: Snippet;
showAlternativeSignInMethodButton?: boolean; showAlternativeSignInMethodButton?: boolean;
animate?: boolean;
} = $props(); } = $props();
let isInitialLoad = $state(false);
let animate = $derived(isInitialLoad && !$appConfigStore.disableAnimations);
afterNavigate((e) => {
isInitialLoad = !e?.from?.url;
});
const isDesktop = new MediaQuery('min-width: 1024px'); const isDesktop = new MediaQuery('min-width: 1024px');
let alternativeSignInButton = $state({ let alternativeSignInButton = $state({
href: '/login/alternative', href: '/login/alternative',

View File

@@ -8,7 +8,6 @@
import { m } from '$lib/paraglide/messages'; import { m } from '$lib/paraglide/messages';
import OIDCService from '$lib/services/oidc-service'; import OIDCService from '$lib/services/oidc-service';
import WebAuthnService from '$lib/services/webauthn-service'; import WebAuthnService from '$lib/services/webauthn-service';
import appConfigStore from '$lib/stores/application-configuration-store';
import userStore from '$lib/stores/user-store'; import userStore from '$lib/stores/user-store';
import type { OidcDeviceCodeInfo } from '$lib/types/oidc.type'; import type { OidcDeviceCodeInfo } from '$lib/types/oidc.type';
import { getAxiosErrorMessage } from '$lib/utils/error-util'; import { getAxiosErrorMessage } from '$lib/utils/error-util';
@@ -72,10 +71,7 @@
<title>{m.authorize_device()}</title> <title>{m.authorize_device()}</title>
</svelte:head> </svelte:head>
<SignInWrapper <SignInWrapper showAlternativeSignInMethodButton={$userStore == null}>
animate={!$appConfigStore.disableAnimations}
showAlternativeSignInMethodButton={$userStore == null}
>
<div class="flex justify-center"> <div class="flex justify-center">
{#if deviceInfo?.client} {#if deviceInfo?.client}
<ClientProviderImages client={deviceInfo.client} {success} error={!!errorMessage} /> <ClientProviderImages client={deviceInfo.client} {success} error={!!errorMessage} />

View File

@@ -39,7 +39,7 @@
<title>{m.sign_in()}</title> <title>{m.sign_in()}</title>
</svelte:head> </svelte:head>
<SignInWrapper animate={!$appConfigStore.disableAnimations} showAlternativeSignInMethodButton> <SignInWrapper showAlternativeSignInMethodButton>
<div class="flex justify-center"> <div class="flex justify-center">
<LoginLogoErrorSuccessIndicator error={!!error} /> <LoginLogoErrorSuccessIndicator error={!!error} />
</div> </div>

View File

@@ -28,7 +28,7 @@
<title>{m.logout()}</title> <title>{m.logout()}</title>
</svelte:head> </svelte:head>
<SignInWrapper animate={!$appConfigStore.disableAnimations}> <SignInWrapper>
<div class="flex justify-center"> <div class="flex justify-center">
<div class="bg-muted rounded-2xl p-3"> <div class="bg-muted rounded-2xl p-3">
<Logo class="size-10" /> <Logo class="size-10" />

View File

@@ -56,7 +56,7 @@
<title>{m.signup()}</title> <title>{m.signup()}</title>
</svelte:head> </svelte:head>
<SignInWrapper animate={!$appConfigStore.disableAnimations}> <SignInWrapper>
<div class="flex justify-center"> <div class="flex justify-center">
<LoginLogoErrorSuccessIndicator error={!!error} /> <LoginLogoErrorSuccessIndicator error={!!error} />
</div> </div>

View File

@@ -5,7 +5,6 @@
import { Button } from '$lib/components/ui/button'; import { Button } from '$lib/components/ui/button';
import { m } from '$lib/paraglide/messages'; import { m } from '$lib/paraglide/messages';
import WebAuthnService from '$lib/services/webauthn-service'; import WebAuthnService from '$lib/services/webauthn-service';
import appConfigStore from '$lib/stores/application-configuration-store';
import { getWebauthnErrorMessage } from '$lib/utils/error-util'; import { getWebauthnErrorMessage } from '$lib/utils/error-util';
import { tryCatch } from '$lib/utils/try-catch-util'; import { tryCatch } from '$lib/utils/try-catch-util';
import { startRegistration } from '@simplewebauthn/browser'; import { startRegistration } from '@simplewebauthn/browser';
@@ -65,7 +64,7 @@
<title>{m.add_passkey()}</title> <title>{m.add_passkey()}</title>
</svelte:head> </svelte:head>
<SignInWrapper animate={!$appConfigStore.disableAnimations}> <SignInWrapper>
<div class="w-full text-center"> <div class="w-full text-center">
<div class="flex justify-center"> <div class="flex justify-center">
<LoginLogoErrorSuccessIndicator error={!!error} /> <LoginLogoErrorSuccessIndicator error={!!error} />

View File

@@ -42,7 +42,7 @@
<title>{m.signup()}</title> <title>{m.signup()}</title>
</svelte:head> </svelte:head>
<SignInWrapper animate={!$appConfigStore.disableAnimations}> <SignInWrapper>
<div class="flex justify-center"> <div class="flex justify-center">
<LoginLogoErrorSuccessIndicator error={!!error} /> <LoginLogoErrorSuccessIndicator error={!!error} />
</div> </div>