Skip to content
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

Addon-links: Fix stories #24400

Merged
merged 9 commits into from
Apr 24, 2024
27 changes: 21 additions & 6 deletions code/addons/links/template/stories/decorator.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,44 @@ export default {
decorators: [withLinks],
};

export const Basic = {
export const Target = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="other">go to other</a>
This is just a story to target with the links
</div>
`,
},
parameters: {
chromatic: { disable: true },
},
};
export const Other = {

export const KindAndStory = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="third">go to third</a>
<a class="link" href="#" data-sb-kind="addons-links-decorator" data-sb-story="story-only">go to story only</a>
</div>
`,
},
};
export const Third = {

export const StoryOnly = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="target">go to target</a>
</div>
`,
},
};

export const KindOnly = {
args: {
content: `
<div>
<a class="link" href="#" data-sb-story="basic">go to basic</a>
<a class="link" href="#" data-sb-kind="addons-links-decorator">go to target</a>
</div>
`,
},
Expand Down
22 changes: 22 additions & 0 deletions code/addons/links/template/stories/hrefto.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { hrefTo } from '@storybook/addon-links';

export default {
component: globalThis.Components.Html,
title: 'hrefTo',
parameters: {
chromatic: { disable: true },
},
args: {
content: '<div><code id="content">Waiting for hrefTo to resolve...</code></div>',
},
};

export const Default = {
play: async () => {
const href = await hrefTo('addons-links-hrefto', 'target');
const content = document.querySelector('#content');
if (content) {
content.textContent = href;
}
},
};
58 changes: 47 additions & 11 deletions code/addons/links/template/stories/linkto.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { linkTo } from '@storybook/addon-links';

export default {
component: globalThis.Components.Button,
title: 'linkTo',
args: {
label: 'Click Me!',
},
Expand All @@ -11,34 +12,69 @@ export default {
},
};

export const ID = {
export const Target = {
args: {
onClick: linkTo('addons-links-parameters--basic'),
label: 'This is just a story to target with the links',
},
parameters: {
chromatic: { disable: true },
},
};
export const Title = {

export const Id = {
args: {
onClick: linkTo('addons-links-parameters'),
onClick: linkTo('addons-links-linkto--target'),
label: 'addons-links-linkto--target',
},
};
export const Basic = {

export const TitleOnly = {
args: {
onClick: linkTo('addons-links-parameters', 'basic'),
onClick: linkTo('addons/links/linkTo'),
label: 'addons/links/linkTo',
},
};
export const Other = {

export const NormalizedTitleOnly = {
args: {
onClick: linkTo('addons-links-parameters', 'basic'),
onClick: linkTo('addons-links-linkto'),
label: 'addons-links-linkto',
},
};
export const Third = {

export const TitleAndName = {
args: {
onClick: linkTo('addons-links-parameters', 'other'),
onClick: linkTo('addons/links/linkTo', 'Target'),
label: 'addons/links/linkTo, Target',
},
};

export const NormalizedTitleAndName = {
args: {
onClick: linkTo('addons-links-linkto', 'target'),
label: 'addons-links-linkto, target',
},
};

export const Callback = {
args: {
onClick: linkTo('addons-links-parameters', (event: Event) => 'basic'),
onClick: linkTo(
(event: Event) => 'addons-links-linkto',
(event: Event) => 'target'
),
},
};

export const ToMDXDocs = {
args: {
onClick: linkTo('Configure Your Project'),
label: 'Configure Your Project',
},
};

export const ToAutodocs = {
args: {
onClick: linkTo('Example Button', 'Docs'),
label: 'Example Button, Docs',
},
};
41 changes: 0 additions & 41 deletions code/addons/links/template/stories/scroll.stories.ts

This file was deleted.