Skip to content

Commit

Permalink
Add parameter to control when stories are wrapped with main (adobe#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowystinger authored Apr 7, 2022
1 parent 2da97bc commit 29a6cb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 22 additions & 6 deletions .storybook/custom-addons/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,25 @@ function ProviderUpdater(props) {
};
}, []);

return (
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue} toastPlacement={toastPositionValue}>
<main>
if (props.options.mainElement == null) {
return (
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue} toastPlacement={toastPositionValue}>
<main>
<div style={{position: 'absolute', paddingTop: '20px', paddingLeft: '20px', paddingRight: '20px'}}>
{props.context.parameters.note && (<DialogTrigger type="popover">
<ActionButton>Note</ActionButton>
<Dialog>
<Content><Text>{props.context.parameters.note}</Text></Content>
</Dialog>
</DialogTrigger>)}
</div>
{storyReady && props.children}
</main>
</Provider>
);
} else {
return (
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue} toastPlacement={toastPositionValue}>
<div style={{position: 'absolute', paddingTop: '20px', paddingLeft: '20px', paddingRight: '20px'}}>
{props.context.parameters.note && (<DialogTrigger type="popover">
<ActionButton>Note</ActionButton>
Expand All @@ -56,9 +72,9 @@ function ProviderUpdater(props) {
</DialogTrigger>)}
</div>
{storyReady && props.children}
</main>
</Provider>
);
</Provider>
);
}
}

export const withProviderSwitcher = makeDecorator({
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-aria/landmark/stories/Landmark.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {useLandmark} from '../';
interface StoryProps {}

const meta: Meta<StoryProps> = {
title: 'Landmark'
title: 'Landmark',
parameters: {providerSwitcher: {mainElement: false}}
};

export default meta;
Expand Down

0 comments on commit 29a6cb1

Please sign in to comment.