From 757201fdc5c04a3f15504f74bf8ab85bb6018c2b Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 27 Oct 2023 11:09:38 +0200
Subject: refactor(hooks,provider): move reduce motion setter

Since the local storage key is not meant to change between the
components, it should be set directly inside the app file. So
both the local storage and the data attribute should be handle
in a provider.
I also added a custom document because we need a script to
retrieve the stored value in local storage earlier to avoid
flashing on hydration.
---
 .storybook/preview.tsx | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

(limited to '.storybook/preview.tsx')

diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx
index de6afd3..f3f374f 100644
--- a/.storybook/preview.tsx
+++ b/.storybook/preview.tsx
@@ -3,7 +3,7 @@ import { ThemeProvider, useTheme } from 'next-themes';
 import { useDarkMode } from 'storybook-dark-mode';
 import { FC, ReactNode, useEffect } from 'react';
 import { IntlProvider } from 'react-intl';
-import { AckeeProvider } from '../src/utils/providers';
+import { AckeeProvider, MotionProvider } from '../src/utils/providers';
 import '../src/styles/globals.scss';
 import { DocsContainer } from './overrides/docs-container';
 import dark from './themes/dark';
@@ -33,16 +33,18 @@ const withAllProviders: Decorator = (Story) => {
         enableColorScheme={true}
         enableSystem={true}
       >
-        <AckeeProvider
-          domainId="any"
-          server="https://example.com"
-          storageKey="ackee"
-          tracking="full"
-        >
-          <ThemeWrapper>
-            <Story />
-          </ThemeWrapper>
-        </AckeeProvider>
+        <MotionProvider attribute="reduced-motion" storageKey="reduced-motion">
+          <AckeeProvider
+            domainId="any"
+            server="https://example.com"
+            storageKey="ackee"
+            tracking="full"
+          >
+            <ThemeWrapper>
+              <Story />
+            </ThemeWrapper>
+          </AckeeProvider>
+        </MotionProvider>
       </ThemeProvider>
     </IntlProvider>
   );
-- 
cgit v1.2.3

