chore: switch to use of svelte native prefersReducedMotion media

This commit is contained in:
Ilia Mashkov
2026-01-22 15:33:38 +03:00
parent b41c48da67
commit e4970e43ba
4 changed files with 7 additions and 39 deletions

View File

@@ -6,9 +6,9 @@
- Adds smooth transition when font appears
-->
<script lang="ts">
import { motion } from '$shared/lib';
import { cn } from '$shared/shadcn/utils/shadcn-utils';
import type { Snippet } from 'svelte';
import { prefersReducedMotion } from 'svelte/motion';
import { appliedFontsManager } from '../../model';
interface Props {
@@ -59,7 +59,7 @@ const status = $derived(appliedFontsManager.getFontStatus(id, weight, false));
const shouldReveal = $derived(hasEnteredViewport && (status === 'loaded' || status === 'error'));
const transitionClasses = $derived(
motion.reduced
prefersReducedMotion.current
? 'transition-none' // Disable CSS transitions if motion is reduced
: 'transition-all duration-700 ease-[cubic-bezier(0.22,1,0.36,1)]',
);
@@ -71,8 +71,9 @@ const transitionClasses = $derived(
class={cn(
transitionClasses,
// If reduced motion is on, we skip the transform/blur entirely
!shouldReveal && !motion.reduced && 'opacity-0 translate-y-8 scale-[0.98] blur-sm',
!shouldReveal && motion.reduced && 'opacity-0', // Still hide until font is ready, but no movement
!shouldReveal && !prefersReducedMotion.current
&& 'opacity-0 translate-y-8 scale-[0.98] blur-sm',
!shouldReveal && prefersReducedMotion.current && 'opacity-0', // Still hide until font is ready, but no movement
shouldReveal && 'opacity-100 translate-y-0 scale-100 blur-0',
className,
)}