From 67c800ee6a58169690c755226fc8b64a19bc9c60 Mon Sep 17 00:00:00 2001 From: Mihira Jayasekera Date: Wed, 11 Mar 2020 11:39:33 -0700 Subject: [PATCH] Docs: add detail to addon-contexts per-story settings Clarify that you can create per-story contexts or disable default (global) contexts defined in contexts.js, and provide sample code for the latter. --- addons/contexts/README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/contexts/README.md b/addons/contexts/README.md index a1345de3e90e..b8984367959c 100644 --- a/addons/contexts/README.md +++ b/addons/contexts/README.md @@ -78,17 +78,36 @@ export default { }; ``` -Finally, you may want to modify the default setups at per story level. Here is how you can do this: +Finally, you may want to create new contextual environments or disable default setups at the story level. To create a new contextual environment at the story level: + +```js +export const defaultView = () =>
; // sample story in CSF format +defaultView.story = { + parameters: { + contexts: [{ /* contextual environment defined using the API below */ }] + } +}; +``` + +To disable a default setup at the story level: ```js export const defaultView = () =>
; defaultView.story = { parameters: { - contexts: [{}] + contexts: [ + { + title: '[title of contextual environment defined in contexts.js]' + options: { disable: true } + } + ] } }; ``` +To override the default option for a default setup at the story level, see [this suggestion](https://discordapp.com/channels/486522875931656193/501692020226654208/687359410577604732). + + ## ⚙️ Setups ### Overview