Storybook: Addon-docs: Make syntax-highlighter theme configurable

Created on 26 Jan 2020  路  6Comments  路  Source: storybookjs/storybook

Is your feature request related to a problem? Please describe.

React-Syntaxt-Highlighter support a lot of Prism themes. It would be nice if Storybook provide a way for the user to pick the theme of is choice.

Describe the solution you'd like

One solution would be to make it configurable through SB theme system.

Something like:

// my-custom-sb-theme.js

import { create } from '@storybook/theming/create';
import { darcula } from 'react-syntax-highlighter/dist/esm/styles/prism';

export default create({
  base: 'light',

  ....

  prismTheme: darcula
});
import { addons } from '@storybook/addons';
import myCustomTheme from './my-custom-sb-theme';

addons.setConfig({
  theme: myCustomTheme
});

Additional context

https://github.com/storybookjs/storybook/issues/9640 could be tackled with this story

docs feature request todo

Most helpful comment

@Smolations i think that's a CSS collision between the prism theme and your CSS. Here's how it should look:

Design_System___Badge_-_All_鈰卂Storybook

So in my estimation there are two separate issues:

  1. Figuring out how to scope the prism themes (see #9718)
  2. Adding configuration support (this issue)

Help wanted on either issue!

All 6 comments

@shilman Is there any workaround for this currently? I am not theming storybook at all and the default syntax highlighting is basically unusable. I have no idea who designed this particular theme, but it is _bad_:
Screen Shot 2020-02-11 at 6 11 40 PM

@Smolations i think that's a CSS collision between the prism theme and your CSS. Here's how it should look:

Design_System___Badge_-_All_鈰卂Storybook

So in my estimation there are two separate issues:

  1. Figuring out how to scope the prism themes (see #9718)
  2. Adding configuration support (this issue)

Help wanted on either issue!

Well I'll be a monkey's uncle...shame on me for not checking that in the first place! 馃檲

Sorry for wasting your time on this. Keep up the good work! 馃榿

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!

@shilman I tried to add this in https://github.com/storybookjs/storybook/blob/c7479f6e513a7d279a24e5d2e5235c6e32068921/lib/components/src/blocks/Source.tsx#L44-L69
but I couldn't figure out how to get a theme var.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexanbj picture alexanbj  路  3Comments

levithomason picture levithomason  路  3Comments

zvictor picture zvictor  路  3Comments

purplecones picture purplecones  路  3Comments

tomitrescak picture tomitrescak  路  3Comments