diff --git a/addons/backgrounds/README.md b/addons/backgrounds/README.md index 93dbda859c2a..fe7f2dcf46e4 100644 --- a/addons/backgrounds/README.md +++ b/addons/backgrounds/README.md @@ -81,3 +81,5 @@ storiesOf('Button', module).add('with text', () => , { backgrounds: { disable: true }, }); ``` + +You can choose your background in a running storybook instance with the `background` query param and either set the background value or the name as the parameter value. E.g. `?background=twitter` or `?background=#00aced`. diff --git a/addons/backgrounds/src/BackgroundPanel.js b/addons/backgrounds/src/BackgroundPanel.js index ea1e9bcd53a7..cf56703b5e25 100644 --- a/addons/backgrounds/src/BackgroundPanel.js +++ b/addons/backgrounds/src/BackgroundPanel.js @@ -99,8 +99,11 @@ export default class BackgroundPanel extends Component { // debugger; - if (current && backgrounds.find(bg => bg.value === current)) { - this.updateIframe(current); + const foundBackground = + current && backgrounds.find(bg => bg.name === decodeURI(current) || bg.value === current); + + if (foundBackground) { + this.updateIframe(foundBackground.value); } else if (defaultOrFirst) { this.updateIframe(defaultOrFirst.value); api.setQueryParams({ background: defaultOrFirst.value });