I am trying to find a way to disable canvas at a story level in the new storybook 6. I am making a library of components and, depending on the story, some of them will only have canvas, while others will only have docs.
I have tried using
myStory.parameters = {
previewTabs: {
canvas: {
hidden: true,
},
},
};
or
myStory.parameters = {
previewTabs: {
'storybook/docs/panel': {
hidden: false,
},
},
};
depending on the story. However, this leads to no tab name being shown. As a result of this, the following happens:
- I have story 1 - only canvas visible
- I have story 2 - only docs visible
- I click on story 1 - I see the canvas, as expected
- I click on story 2 - I see the canvas also, even though it is hidden (I suppose because the tab has been kept from the previous story). As if this is not bad enough, I cannot even click on docs, since no tab name is visible.
- Same is valid for the reverse (if I start with story 2)
As a workaround for docs, I have found this (thanks to Benjamin, in this post here):
myStory.parameters = {
docs: { page: null },
};
With this, I can still see both canvas and docs tabs, but the docs one is now empty for the story where this parameter has been set.
I am looking to do something similar for canvas, and have tried
myStory.parameters = {
canvas: { page: null },
};
myStory.parameters = {
canvas: { disabled: true },
};
but have not worked.