Sfoglia il codice sorgente

Merge pull request #22818 from overleaf/td-storybook-overall-editor-theme

Make theme switcher work in BS5 editor Storybook stories

GitOrigin-RevId: ff9a9a14c2e9bdaccefab2652fbfbd54c544635e
Tim Down 1 anno fa
parent
commit
8f29870334
1 ha cambiato i file con 9 aggiunte e 6 eliminazioni
  1. 9 6
      services/web/.storybook/preview.tsx

+ 9 - 6
services/web/.storybook/preview.tsx

@@ -139,7 +139,6 @@ const preview: Preview = {
         items: [
         items: [
           { value: 'main-', title: 'Default' },
           { value: 'main-', title: 'Default' },
           { value: 'main-light-', title: 'Light' },
           { value: 'main-light-', title: 'Light' },
-          { value: 'main-ieee-', title: 'IEEE' },
         ],
         ],
       },
       },
     },
     },
@@ -154,10 +153,10 @@ const preview: Preview = {
         bootstrap3Style: await import(
         bootstrap3Style: await import(
           `!!to-string-loader!css-loader!less-loader!../../../services/web/frontend/stylesheets/${theme}style.less`
           `!!to-string-loader!css-loader!less-loader!../../../services/web/frontend/stylesheets/${theme}style.less`
         ),
         ),
-        // NOTE: this uses `${theme}style.scss` rather than `${theme}.scss`
-        // so that webpack only bundles files ending with "style.scss"
+        // Themes are applied differently in Bootstrap 5 code
         bootstrap5Style: await import(
         bootstrap5Style: await import(
-          `!!to-string-loader!css-loader!resolve-url-loader!sass-loader!../../../services/web/frontend/stylesheets/bootstrap-5/${theme}style.scss`
+          // @ts-ignore
+          `!!to-string-loader!css-loader!resolve-url-loader!sass-loader!../../../services/web/frontend/stylesheets/bootstrap-5/main-style.scss`
         ),
         ),
       }
       }
     },
     },
@@ -175,14 +174,18 @@ const preview: Preview = {
       resetMeta(bootstrapVersion)
       resetMeta(bootstrapVersion)
 
 
       return (
       return (
-        <>
+        <div
+          data-theme={
+            context.globals.theme === 'main-light-' ? 'light' : 'default'
+          }
+        >
           {activeStyle && <style>{activeStyle.default}</style>}
           {activeStyle && <style>{activeStyle.default}</style>}
           <Story
           <Story
             {...context}
             {...context}
             // force re-renders when switching between Bootstrap versions
             // force re-renders when switching between Bootstrap versions
             key={bootstrapVersion}
             key={bootstrapVersion}
           />
           />
-        </>
+        </div>
       )
       )
     },
     },
   ],
   ],