Skip to content

Commit

Permalink
fix: correct copy pasta (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ipso authored Mar 14, 2022
1 parent 5978950 commit 68d261a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/withDrupalTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ import {
useGlobals,
} from '@storybook/addons';

export const withDrupalTheme = (StoryFn: StoryFunction, context: StoryContext) => {
const [{drupalTheme}] = useGlobals();
export const withDrupalTheme = (
StoryFn: StoryFunction,
context: StoryContext,
) => {
const [{ drupalTheme }] = useGlobals();
if (drupalTheme) {
console.log(`Rendering component using: ${drupalTheme}`)
console.log(`Rendering component using Drupal theme: ${drupalTheme}`);
}

const [globals, updateGlobals] = useGlobals();
useEffect(() => {
const {
parameters: {drupalTheme, supportedDrupalThemes},
parameters: { drupalTheme, supportedDrupalThemes },
} = context;
if (supportedDrupalThemes && !globals.locales) {
if (drupalTheme && !globals.locale) {
updateGlobals({drupalTheme, supportedDrupalThemes});
if (supportedDrupalThemes && !globals.supportedDrupalThemes) {
if (drupalTheme && !globals.drupalTheme) {
updateGlobals({ drupalTheme, supportedDrupalThemes });
} else {
updateGlobals({supportedDrupalThemes});
updateGlobals({ supportedDrupalThemes });
}
}
}, []);
return StoryFn(undefined, undefined);
};

0 comments on commit 68d261a

Please sign in to comment.