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
18 changes: 12 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,35 @@ export default {
decorators: [withLinks],
};

export const Basic = {
export const Target = {
render: () => 'This is just a story to target with the links',
};

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

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

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
23 changes: 23 additions & 0 deletions code/addons/links/template/stories/hrefto.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { hrefTo } from '@storybook/addon-links';

export default {
component: globalThis.Components.Html,
title: 'hrefTo',
parameters: {
chromatic: { disable: true },
},
};

export const Default = {
render: () => {
hrefTo('addons-links-hrefto', 'target').then((href) => {
const root = document.querySelector('#storybook-root');
if (!root) {
return;
}
const node = document.createElement('code');
node.innerHTML = href;
root.appendChild(node);
});
},
};
53 changes: 42 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,64 @@ export default {
},
};

export const ID = {
export const Target = {
render: () => 'This is just a story to target with the links',
};

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

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

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

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

export const NormalizedTitleAndName = {
args: {
onClick: linkTo('addons-links-parameters', 'other'),
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.