Skip to content

Commit 89b7ec3

Browse files
committed
disable snow for reduced-motion users
1 parent 6f59736 commit 89b7ec3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/layout.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import Snowfall from 'react-snowfall';
55
import Header from 'components/header';
66
import useDarkMode from 'hooks/useDarkMode';
77
import { getDate, getMonth } from 'date-fns';
8+
import usePrefersReducedMotion from 'src/hooks/usePrefersReducedMotion';
89

910
export default function Layout({ children }) {
1011
useDarkMode();
1112

13+
const disableMotion = usePrefersReducedMotion();
1214
const isChristmas =
1315
getMonth(Date.now()) === 11 && [24, 25, 26].includes(getDate(Date.now()));
1416

1517
return (
1618
<Fragment>
17-
{isChristmas && <Snowfall />}
19+
{!disableMotion && isChristmas && <Snowfall />}
1820
<Header />
1921
<main className="mt-3 mb-2">{children}</main>
2022
</Fragment>

0 commit comments

Comments
 (0)