Storybook: Blank page in Angular storybook

Created on 7 Aug 2019  路  4Comments  路  Source: storybookjs/storybook

Describe the bug
I get blank page in Angular storybook. I'm using Ionic framework.

To Reproduce
Steps to reproduce the behavior:

  1. install Ionic: ionic start myApp blank
  2. install storybook: npx -p @storybook/cli sb init --type angular
  3. run storybook: npm run storybook
  4. canvas tab is empty (see attached screenshot)

blank page

Please specify which version of Storybook and optionally any affected addons that you're running

"@storybook/addon-actions": "^5.1.10",
"@storybook/addon-links": "^5.1.10",
"@storybook/addon-notes": "^5.1.10",
"@storybook/addons": "^5.1.10",
"@storybook/angular": "^5.1.10",
 "@angular/cli": "~8.1.2",
"@angular/compiler": "~8.1.2",
"@angular/compiler-cli": "~8.1.2",
"@angular/language-service": "~8.1.2",
"@babel/core": "^7.5.5",

I found out that components are hidden because of CSS in storybook:

html:not(.hydrated) body {
    display: none;
}

There is no HTML class "hydrated" in html tag in storybook iframe

I get an error in console:
The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type" in iframe.vendors~main.7bfb22a46d79733eaf20.bundle.js:617

angular question / support

Most helpful comment

hi @Alfr3d
I added css to storybook.

in index.stories.ts:

...
import "!style-loader!css-loader!./styles.css";
...

in styles.css:

html:not(.hydrated) body {
  display: block !important;
}

All 4 comments

it was Ionic CSS:

html:not(.hydrated) body {
    display: none;
}

So I need just override this CSS in storybook

Hi @ildar-icoosoft ,

so how should I solve?

hi @Alfr3d
I added css to storybook.

in index.stories.ts:

...
import "!style-loader!css-loader!./styles.css";
...

in styles.css:

html:not(.hydrated) body {
  display: block !important;
}

With newer versions of Storybook I added the import statement in ./storybook/preview.js file instead of index.stories.ts to make it work because with the new configuration it has no more index file but uses a pattern to look for stories.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arunoda picture arunoda  路  3Comments

ZigGreen picture ZigGreen  路  3Comments

levithomason picture levithomason  路  3Comments

dnlsandiego picture dnlsandiego  路  3Comments

wahengchang picture wahengchang  路  3Comments