From 60c49f18389ff625177a57277ef8f292a31097bf Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Sat, 28 Oct 2023 17:12:58 +0200
Subject: refactor(providers,hooks): rewrite PrismThemeProvider & usePrismTheme

* reuse Theme provider logic
* move DOM mutation from provider to hook
* add a script to init theme before page load
---
 .storybook/preview.tsx | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

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

diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx
index d5cc8cc..f36013c 100644
--- a/.storybook/preview.tsx
+++ b/.storybook/preview.tsx
@@ -5,6 +5,7 @@ import { IntlProvider } from 'react-intl';
 import {
   AckeeProvider,
   MotionProvider,
+  PrismThemeProvider,
   ThemeProvider,
 } from '../src/utils/providers';
 import '../src/styles/globals.scss';
@@ -33,18 +34,26 @@ const withAllProviders: Decorator = (Story) => {
   return (
     <IntlProvider locale="en">
       <ThemeProvider attribute="theme" storageKey="theme">
-        <MotionProvider attribute="reduced-motion" storageKey="reduced-motion">
-          <AckeeProvider
-            domainId="any"
-            server="https://example.com"
-            storageKey="ackee"
-            tracking="full"
+        <PrismThemeProvider
+          attribute="data-prismjs-color-scheme-current"
+          storageKey="prismjs-color-scheme"
+        >
+          <MotionProvider
+            attribute="reduced-motion"
+            storageKey="reduced-motion"
           >
-            <ThemeWrapper>
-              <Story />
-            </ThemeWrapper>
-          </AckeeProvider>
-        </MotionProvider>
+            <AckeeProvider
+              domainId="any"
+              server="https://example.com"
+              storageKey="ackee"
+              tracking="full"
+            >
+              <ThemeWrapper>
+                <Story />
+              </ThemeWrapper>
+            </AckeeProvider>
+          </MotionProvider>
+        </PrismThemeProvider>
       </ThemeProvider>
     </IntlProvider>
   );
-- 
cgit v1.2.3

