-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon-centered breaks layout in addon-docs #8128
Comments
When disabling addon-centered it still says So the only real problem is that addon-centered is still active while in the |
Can confirm, seeing this exact issue |
Seeing same thing.
^ this should say:
|
Same issue here.
|
Same here. |
If anyone needs a quick fix, I've created a copy of this addon with a crude (but working) fix. import React from 'react';
import { makeDecorator } from '@storybook/addons';
import parameters from '@storybook/addon-centered/dist/parameters';
import styles from '@storybook/addon-centered/dist/styles';
function centered(storyFn) {
const params = (new URL(document.location)).searchParams;
const isInDockView = params.get('viewMode') === 'docs';
if (isInDockView) {
return storyFn();
}
return (
<div style={styles.style}>
<div style={styles.innerStyle}>
{storyFn()}
</div>
</div>
);
}
export default makeDecorator({
...parameters,
wrapper: (getStory) => centered(getStory),
});
if (module && module.hot && module.hot.decline) {
module.hot.decline();
} You can import it and use like standard centered addon. |
This seems like a good opportunity for a pull request @UlanaXY if you don't want to get the ball rolling, I can. |
@hipstersmoothie I already cloned the repo to open a PR, unfortunately I was not able to install dependencies on any of my machines (Win10, OSX) - and I do not want to open an untested PR. So if You'd have the time to test the code and open a PR, that would be great. |
The centered addon was clashing when used in combination with the docs addon. When on the docs page, the centered style should not be applied. Note that this commit only fixes it for React.
I have just been putting a CSS grid inside a flexbox and aligning/justifying everything to center. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Here's a similar, but different, temp fix that @UlanaXY posted. This can be applied globally in // .storybook/config.js
import { addDecorator } from '@storybook/react';
import centered from '@storybook/addon-centered/react';
// Centered addon causes layout issues on docs page.
// This is a weird hack to fix the layout issues.
addDecorator((...args) => {
const params = (new URL(document.location)).searchParams;
const isInDockView = params.get('viewMode') === 'docs';
if (isInDockView) {
return args[0]();
}
return centered(...args);
}); |
Ive just replaced it with a full width flexbox with justify center. Lacks the vertical centering, but frankly thats desirable |
Should make all stories be centered in the preview 👍 This doesn't work in docs, yet. but we could build it? Would anyone be interested in taking that on? |
Same problem is also in Vue stories. |
Describe the bug
When using addon-centered together with addon-docs it creates two problems:
addon-docs suddenly says that it no longer finds a componentTo Reproduce
Setup addon-centered together with addon-docs.
Expected behavior
I expect addons-centered not to affect addon-docs.
Screenshots
System:
The text was updated successfully, but these errors were encountered: