Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #8128: addon-centered clashing with addon-docs for react #8388

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions addons/centered/src/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import parameters from './parameters';
import styles from './styles';

function centered(storyFn: () => ReactNode) {
/* eslint-disable no-undef */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a useViewmode hook would be a good idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen I think that would be very useful, independent of this PR

if (window) {
const params = new URL(window.location.href).search;
const isInDocsView = params.includes('viewMode=docs');

if (isInDocsView) {
return storyFn();
}
}
/* eslint-enable no-undef */

return (
<div style={styles.style}>
<div style={styles.innerStyle}>{storyFn()}</div>
Expand Down