Repository navigation
Replies: 2 comments 4 replies
|
As I started populating my storybook with more chromatic stories, it became apparent that something like this was needed to allow me to develop the chromatic stories locally and see them, but not have them visible on my published storybook. A similar use case was QA wanting obscure stories for edge cases that were only relevant to them. The quick and dirty solution I had to this was something like this: // .storybook/manager.ts
import { GLOBALS_UPDATED } from "storybook/internal/core-events";
import type { Globals, API_FilterFunction } from "storybook/internal/types";
import { addons } from "storybook/manager-api";
function filter(persona: Globals["persona"]): API_FilterFunction {
return function (item) {
switch (item.type) {
case "docs":
return true;
case "story":
if (persona === "dev") {
return !item.importPath.includes("chromatic");
}
return persona === "QA";
default:
return true;
}
};
}
addons.register("shenanigans", (api) => {
void api.experimental_setFilter("shenanigans", filter("standard"));
api.on(GLOBALS_UPDATED, ({ globals: { persona } }: { globals: Globals }) => {
void api.experimental_setFilter("shenanigans", filter(persona));
});
});So - by default, only docs are visible. Devs can see full stories, QA can also see chromatic. The implementation of this should be left very much up to the user - I haven't made extensive use of tags, in part because I'm still waiting for a |
|
@unional some of the things on this RFC are possible, but documentation for them is very difficult to stumble into. See below for applicable solutions. Enhance Filter capabilities ✔️Tip A Storybook instance can be focused on documentation via the Support Initial Filter values ✔️Tip This is a well hidden feature, but it exists. You can configure the filter UI to include or exclude some tags by default. See examples in https://storybook.js.org/docs/writing-stories/tags#custom-tags. tags: {
haha: {
defaultFilterSelection: 'include',
},
hoho: {
defaultFilterSelection: 'exclude',
},
'some-tag': {
excludeFromSidebar: true,
},
},I think we should look at this RFC from two perspectives:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Introduce a way to define a default filter when the Storybook starts.
This idea can be extended to a Persona/Profile concept to quickly change the filter selection based on the current audience.
Problem Statement
Storybook can contain stories created for different reasons.
Filter by tags is a good way to quickly reduce the number of stories shown to de-clutter the Storybook, especially for designers and managers who may not be tech savvy.
Showing all stories and ask them to filter to a set of tags is still quite daunting to them.
At the same time, it is still beneficial to include all stories in the production Storybook so the engineers and package/app authors can rely on Storybook as the holy place to gather or validate information.
Non-goals
No response
Implementation
There are a few things can be done:
Enhance Filter capabilities
Select All/Clear Alltag filtersSupport Initial Filter values
For example:
(or) Support Persona/Profiles
Prior Art
No response
Deliverables
No response
Risks
No response
Unresolved Questions
Alternatives considered / Abandoned Ideas
No response
All reactions