Storybook: apply global css to storybook

Created on 10 Oct 2018  路  5Comments  路  Source: storybookjs/storybook

Custom style

Steps to reproduce

I would like to apply my own style for the notes addon panel, i would like to appy some css in order to make the notes code markdown looks like GitHub markdown for example.
when i import style from the strorybook config file it is injected into the main iframe and i do not have access to override the addons pane dom.
please advice if there is a correct way to inject global style to storybook

I use: storybook/angular version 4.0.0-alpha.24

  • @storybook/angular version 4.0.0-alpha.24
  • @storybook/addon-notes 4.0.0-alpha.24
notes inactive question / support

Most helpful comment

Can you include these CSS rules into the manager-head.html hook?

All 5 comments

Can you include these CSS rules into the manager-head.html hook?

We'll be expanding the theming support slowly, this is coming.

Right now as @igor-dv says you can add global stylesheets to the manager. Long term we're going to embed this this into themes.

thanks @igor-dv , adding style to the manager-head.html worked.
I used it to apply a better markdown style for the notes addon, it would be cool if the notes addon style applied Github markdown css by default.

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!

Just a quick add. This is how your manager-head.html has to look like to style your markdown:

<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function(){
        var iframe = document.getElementById('storybook-preview-iframe');
        iframe.onload = function() {
            var style = document.createElement('style');
            style.textContent =
              '#root div:nth-child(2) div div > *, #root div:nth-child(2) div div > * > * {' +
              '  font-family: monospace !important;' +
              '  font-size: 18px !important;' +
              '}' +
              '#root div:nth-child(2) div div h1, #root div:nth-child(2) div div h2, #root div:nth-child(2) div div h3, #root div:nth-child(2) div div h4{' +
              '  text-transform: none !important;' +
              '  padding: 0 !important;' +
              '  margin: 18px 0 !important;' +
              '}'           ;
            iframe.contentDocument.head.appendChild(style);
        }
    }, false);
</script>

screenshot from 2018-12-11 11-36-57

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZigGreen picture ZigGreen  路  3Comments

wahengchang picture wahengchang  路  3Comments

xogeny picture xogeny  路  3Comments

arunoda picture arunoda  路  3Comments

rpersaud picture rpersaud  路  3Comments