Skip to content

Commit

Permalink
Added unique id to stories
Browse files Browse the repository at this point in the history
  • Loading branch information
dexster committed Jul 7, 2021
1 parent cbbef5b commit 9db2e2b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"js-string-escape": "^1.0.1",
"loader-utils": "^2.0.0",
"lodash": "^4.17.20",
"nanoid": "^3.1.23",
"p-limit": "^3.1.0",
"prettier": "~2.2.1",
"prop-types": "^15.7.2",
Expand Down
3 changes: 2 additions & 1 deletion addons/docs/src/frameworks/angular/prepareForInline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import pLimit from 'p-limit';
import { nanoid } from 'nanoid';

import { IStory, StoryContext } from '@storybook/angular';
import { rendererFactory } from '@storybook/angular/renderer';
Expand All @@ -18,7 +19,7 @@ export const prepareForInline = (storyFn: StoryFn<IStory>, { id, parameters }: S
}

return limit(async () => {
const renderer = await rendererFactory.getRendererInstance(id, node);
const renderer = await rendererFactory.getRendererInstance(`${id}-${nanoid(10)}`, node);
await renderer.render({
forced: false,
parameters,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Addons/Docs/DuplicateStories Basic 1`] = `
<storybook-wrapper>
<my-button
ng-reflect-is-disabled="false"
ng-reflect-label="Args test"
>
<button
class="btn-secondary btn-medium"
ng-reflect-ng-class="btn-secondary,btn-medium"
>
<img
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBp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0 deletions examples/angular-cli/src/stories/addons/docs/duplicate.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Story, Meta, Canvas} from '@storybook/addon-docs';
import {DocButtonComponent} from "./doc-button/doc-button.component";
import * as stories from './doc-button/doc-button.stories';

<Meta title="Addons/Docs/DuplicateStories" component={DocButtonComponent} />

# Duplicate stories

Using the same component more than once. Note the imported story can only be used once and thereafter the links have to be used

<Canvas>
<Story story={stories.Basic}/>
</Canvas>

<Canvas>
<Story id="addons-docs-duplicatestories--basic" />
</Canvas>

<Canvas>
<Story id="addons-docs-duplicatestories--basic" />
</Canvas>
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5707,6 +5707,7 @@ __metadata:
lit-html: ^2.0.0-rc.3
loader-utils: ^2.0.0
lodash: ^4.17.20
nanoid: ^3.1.23
p-limit: ^3.1.0
prettier: ~2.2.1
prop-types: ^15.7.2
Expand Down Expand Up @@ -30639,6 +30640,15 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"nanoid@npm:^3.1.23":
version: 3.1.23
resolution: "nanoid@npm:3.1.23"
bin:
nanoid: bin/nanoid.cjs
checksum: a3207f946e2db59f8095118d5c57615f217e7f8a743bdb83212e222bd263516dbd83db226675d9b8634ed928ff2019db96ca06825a391af4256b02f7bec4b443
languageName: node
linkType: hard

"nanomatch@npm:^1.2.9":
version: 1.2.13
resolution: "nanomatch@npm:1.2.13"
Expand Down

0 comments on commit 9db2e2b

Please sign in to comment.