Skip to content

Commit

Permalink
Merge pull request #19124 from storybookjs/norbert/sb-577-addon-links
Browse files Browse the repository at this point in the history
Addon-links: Move stories into addon
  • Loading branch information
ndelangen authored Sep 12, 2022
2 parents c00654b + 657dd49 commit 19d75f0
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 196 deletions.
38 changes: 38 additions & 0 deletions code/addons/links/template/stories/decorator.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import globalThis from 'global';
import { withLinks } from '@storybook/addon-links';

export default {
component: globalThis.Components.Html,
parameters: {
chromatic: { disable: true },
},
decorators: [withLinks],
};

export const Basic = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="basic">go to basic</a>
</div>
`,
},
};
export const Other = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="basic">to to basic</a>
</div>
`,
},
};
export const Third = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="other">go to other</a>
</div>
`,
},
};
44 changes: 44 additions & 0 deletions code/addons/links/template/stories/linkto.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import globalThis from 'global';
import { linkTo } from '@storybook/addon-links';

export default {
component: globalThis.Components.Button,
args: {
children: 'Click Me!',
},
parameters: {
chromatic: { disable: true },
},
};

export const ID = {
args: {
onClick: linkTo('addons-links-parameters--basic'),
},
};
export const Title = {
args: {
onClick: linkTo('addons-links-parameters'),
},
};
export const Basic = {
args: {
onClick: linkTo('addons-links-parameters', 'basic'),
},
};
export const Other = {
args: {
onClick: linkTo('addons-links-parameters', 'basic'),
},
};
export const Third = {
args: {
onClick: linkTo('addons-links-parameters', 'other'),
},
};

export const Callback = {
args: {
onClick: linkTo('addons-links-parameters', (event: Event) => 'basic'),
},
};
41 changes: 41 additions & 0 deletions code/addons/links/template/stories/scroll.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import globalThis from 'global';
import { withLinks } from '@storybook/addon-links';

export default {
component: globalThis.Components.Html,
parameters: {
chromatic: { disable: true },
},
decorators: [withLinks],
};

export const Basic = {
args: {
content: `
<div>
<div style="marginBottom:100vh"></div>
<a class="link" href="#" data-sb-story="basic">go to basic</a>
</div>
`,
},
};
export const Other = {
args: {
content: `
<div>
<div style="marginBottom:100vh"></div>
<a class="link" href="#" data-sb-story="basic">to to basic</a>
</div>
`,
},
};
export const Third = {
args: {
content: `
<div>
<div style="marginBottom:100vh"></div>
<a class="link" href="#" data-sb-story="other">go to other</a>
</div>
`,
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';

import { linkTo } from '@storybook/addon-links';
import { Welcome } from '../react-demo';

export default {
Expand All @@ -11,6 +10,6 @@ export default {
},
};

export const ToStorybook = () => <Welcome showApp={linkTo('Button')} />;
export const ToStorybook = () => <Welcome showApp={() => {}} />;

ToStorybook.storyName = 'to Storybook';
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '../react-demo';
import { Meta, Story } from '@storybook/addon-docs';

Expand All @@ -10,5 +9,5 @@ import { Meta, Story } from '@storybook/addon-docs';
/>

<Story name="to Storybook">
<Welcome showApp={linkTo('Button')} />
<Welcome showApp={() => {}} />
</Story>
17 changes: 0 additions & 17 deletions code/cypress/integration/addon-links.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { moduleMetadata } from '@storybook/angular';
import { Story, Meta, ArgsTable } from '@storybook/addon-docs';
import { Welcome, Button } from '../.././angular-demo';
import { linkTo } from '@storybook/addon-links';
import { DocButtonComponent } from './doc-button/doc-button.component';

# Storybook Docs for Angular
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { linkTo } from '@storybook/addon-links';
import { Button } from '../../angular-demo';

export default {
Expand All @@ -9,7 +8,7 @@ export default {
export const ButtonWithLinkToAnotherStory = () => ({
props: {
text: 'Go to Welcome Story',
onClick: linkTo('Welcome'),
onClick: () => {},
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Meta, StoryFn } from '@storybook/angular';
import { linkTo } from '@storybook/addon-links';
import { AppComponent } from '../app/app.component';

export default {
Expand All @@ -9,6 +8,6 @@ export default {
export const ToAngular: StoryFn = () => ({
component: AppComponent,
props: {
showApp: linkTo('Button'),
showApp: () => {},
},
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Meta, StoryFn } from '@storybook/angular';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from './angular-demo';

export default {
Expand All @@ -9,6 +8,6 @@ export default {
export const ToStorybook: StoryFn = () => ({
component: Welcome,
props: {
showApp: linkTo('Button'),
showApp: () => {},
},
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '../components/react-demo';

export default {
title: 'Welcome',
component: Welcome,
};

export const Story1 = () => <Welcome showApp={linkTo('Button')} />;
export const Story1 = () => <Welcome showApp={() => {}} />;
Story1.title = 'to Storybook';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import type { ComponentMeta, ComponentStoryFn } from '@storybook/react';
import { Welcome } from './react-demo';

Expand All @@ -8,8 +7,6 @@ export default {
component: Welcome,
} as ComponentMeta<typeof Welcome>;

export const ToStorybook: ComponentStoryFn<typeof Welcome> = () => (
<Welcome showApp={linkTo('Button')} />
);
export const ToStorybook: ComponentStoryFn<typeof Welcome> = () => <Welcome showApp={() => {}} />;

ToStorybook.storyName = 'to Storybook';
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '../components/react-demo';

export default {
title: 'Welcome',
component: Welcome,
};

export const ToStorybook = () => <Welcome showApp={linkTo('Button')} />;
export const ToStorybook = () => <Welcome showApp={() => {}} />;

ToStorybook.storyName = 'to Storybook';
15 changes: 0 additions & 15 deletions code/examples/ember-cli/stories/addon-links.stories.js

This file was deleted.

3 changes: 0 additions & 3 deletions code/examples/html-kitchen-sink/stories/welcome.stories.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { withLinks } from '@storybook/addon-links';

import './welcome.css';
import welcome from './welcome.html';

export default {
title: 'Welcome',
decorators: [withLinks],
};

export const Welcome = () => welcome;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '../../components/react-demo';

export default {
Expand All @@ -10,5 +9,5 @@ export default {
// Some other valid values:
// - 'other-demo-buttonmdx--with-text'
// - 'Other/Demo/ButtonMdx'
export const ToStorybook = () => <Welcome showApp={linkTo('Other/Demo/Button')} />;
export const ToStorybook = () => <Welcome showApp={() => {}} />;
ToStorybook.storyName = 'to Storybook';
Loading

0 comments on commit 19d75f0

Please sign in to comment.