Skip to content

Commit

Permalink
chore(nx-dev): honor prefers-reduced-motion (nrwl#27976)
Browse files Browse the repository at this point in the history
Fixes nrwl#27114 (again)
  • Loading branch information
isaacplmann authored Sep 18, 2024
1 parent 50927c2 commit 24ddbe7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nx-dev/ui-home/src/lib/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import { ButtonLink, SectionHeading, Strong } from '@nx/nx-dev/ui-common';
import { ShaderGradient, ShaderGradientCanvas } from 'shadergradient';
import { BlurFade } from '@nx/nx-dev/ui-animations';
import { BlurFade, usePrefersReducedMotion } from '@nx/nx-dev/ui-animations';
import { Theme, useTheme } from '@nx/nx-dev/ui-theme';
import { useState } from 'react';
import Link from 'next/link';
Expand Down Expand Up @@ -141,6 +141,8 @@ export function Hero(): JSX.Element {
function ShaderGradientElement() {
const [theme] = useTheme();
const [displayTheme, setDisplayTheme] = useState<Theme>('system');
const prefersReducedMotion = usePrefersReducedMotion();

useIsomorphicLayoutEffect(() => {
const matchMedia: any = window.matchMedia('(prefers-color-scheme: dark)');

Expand Down Expand Up @@ -170,6 +172,10 @@ function ShaderGradientElement() {
};
}, [theme]);

if (prefersReducedMotion) {
return;
}

if (displayTheme === 'dark')
return (
<BlurFade
Expand Down

0 comments on commit 24ddbe7

Please sign in to comment.