-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom screenshot file name #42
Comments
So - storybook provides a fileName in context for each story (currently broken in storybook4), and one could use it to generate a file name. Pattern is a bit more common approach, and allow you do to a lot, but most complex cases are undoable. Meanwhile, function is much harder to use. Pattern could look like const DEFAULT_FILE_PATTERN = '{kind}-{story}{knobs}{ns}{vp}';
export const story2filename = (params: Story2FilenameParams) => {
const ns = params.namespace ? `_${params.namespace}` : '';
const vp = params.viewport ? `-${viewport2string(params.viewport)}` : '';
const knobs = params.knobs ? `-${knobs2string(params.knobs)}` : '';
const replacements = {
kind: params.kind,
story:params.story,
knobs,
ns,
vp
};
const filename =
(params.filePattern || DEFAULT_FILE_PATTERN)
.replace(/\{\w+\}/g, key => replacements[key])
return `${filenamify(filename)}.png`;
}; It could be useful, but it will not solve my task - place a storyshots next to storyfile, while function could. Any thoughts? |
I agree with the generation of file names using patterns 👍
In order to satisfy your task, you need to know the file path of each story. Hmm... |
You could have it, it is a part of storyContext. see https://github.com/theKashey/storybook/blob/bdc9bed648a3316ece83764cbf8e800c0b4d6fc3/lib/core/src/client/preview/client_api.js#L91 If you like patterns - I could open a PR, it's ready already. I just found that I have no filename, and first have to fix storybook(v4). |
OMG ... How amazing !!
Thanks 🙏 |
@tsuyoshiwada - done, but it is not complete - I dont touch CLI interface, and still looking forward to access fileName somehow. |
Is this still possible nowadays? I had a look and couldn't find the |
I would like to have customizable
story2filename
, to land target images, for example, next to .story file, not all in one directory.The text was updated successfully, but these errors were encountered: