mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 16:22:09 +08:00
Update buttons stories
This commit is contained in:
parent
eef5494030
commit
b07813866a
@ -8,19 +8,21 @@ export default {
|
|||||||
component: Button,
|
component: Button,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args: Button) => ({
|
||||||
component: Button,
|
component: Button,
|
||||||
props: {
|
props: args,
|
||||||
text: 'Hello Button',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Emoji = () => ({
|
export const Text = ButtonStory.bind({});
|
||||||
component: Button,
|
Text.args = {
|
||||||
props: {
|
children: 'Button',
|
||||||
text: '😀 😎 👍 💯',
|
onClick: action('onClick'),
|
||||||
},
|
};
|
||||||
});
|
|
||||||
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
||||||
|
|
||||||
|
@ -6,23 +6,26 @@ import Button from './button';
|
|||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
|
argTypes: {
|
||||||
|
text: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args) => ({
|
||||||
component: Button,
|
component: Button,
|
||||||
props: {
|
props: args,
|
||||||
text: 'Hello Button',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Emoji = () => ({
|
export const Text = ButtonStory.bind({});
|
||||||
component: Button,
|
Text.args = {
|
||||||
props: {
|
children: 'Button',
|
||||||
text: '😀 😎 👍 💯',
|
onClick: action('onClick'),
|
||||||
},
|
};
|
||||||
});
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => ({
|
export const TextWithAction = () => ({
|
||||||
component: Button,
|
component: Button,
|
||||||
|
@ -4,29 +4,26 @@ import { linkTo } from '@storybook/addon-links';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args) => ({
|
||||||
template: hbs`<button {{action onClick}}>Hello Button</button>`,
|
template: hbs`<button {{action onClick}}>{{children}}</button>`,
|
||||||
context: {
|
context: args,
|
||||||
onClick: action('clicked'),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Emoji = () => ({
|
export const Text = ButtonStory.bind({});
|
||||||
template: hbs`
|
Text.args = {
|
||||||
<button {{action onClick}}>
|
children: 'Button',
|
||||||
<span role="img" aria-label="so cool">
|
onClick: action('onClick'),
|
||||||
😀 😎 👍 💯
|
};
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
`,
|
|
||||||
context: {
|
|
||||||
onClick: action('clicked'),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => ({
|
export const TextWithAction = () => ({
|
||||||
template: hbs`
|
template: hbs`
|
||||||
|
@ -3,25 +3,29 @@ import { linkTo } from '@storybook/addon-links';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => {
|
const ButtonStory = ({ onClick, children }) => {
|
||||||
const btn = document.createElement('button');
|
const btn = document.createElement('button');
|
||||||
btn.type = 'button';
|
btn.type = 'button';
|
||||||
btn.innerText = 'Hello Button';
|
btn.innerText = children;
|
||||||
btn.addEventListener('click', action('clicked'));
|
btn.addEventListener('click', onClick);
|
||||||
return btn;
|
return btn;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Emoji = () => {
|
export const Text = ButtonStory.bind({});
|
||||||
const btn = document.createElement('button');
|
Text.args = {
|
||||||
btn.type = 'button';
|
children: 'Button',
|
||||||
btn.innerText = '😀 😎 👍 💯';
|
onClick: action('onClick'),
|
||||||
btn.addEventListener('click', action('clicked'));
|
|
||||||
return btn;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => {
|
export const TextWithAction = () => {
|
||||||
const btn = document.createElement('button');
|
const btn = document.createElement('button');
|
||||||
|
@ -6,22 +6,25 @@ import Button from './Button';
|
|||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = ({ children, ...args }) => ({
|
||||||
view: () => m(Button, { onclick: action('clicked') }, 'Hello Button'),
|
view: () => m(Button, args, children),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Emoji = () => ({
|
export const Text = ButtonStory.bind({});
|
||||||
view: () =>
|
Text.args = {
|
||||||
m(
|
children: 'Button',
|
||||||
Button,
|
onClick: action('onClick'),
|
||||||
{ onclick: action('clicked') },
|
};
|
||||||
m('span', { role: 'img', ariaLabel: 'so cool' }, '😀 😎 👍 💯')
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => ({
|
export const TextWithAction = () => ({
|
||||||
view: () => m(Button, { onclick: () => action('This was clicked')() }, 'Trigger Action'),
|
view: () => m(Button, { onclick: () => action('This was clicked')() }, 'Trigger Action'),
|
||||||
|
@ -8,19 +8,23 @@ import Button from './Button';
|
|||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => <Button onClick={action('clicked')}>Hello Button</Button>;
|
const ButtonStory = (args) => <Button {...args} />;
|
||||||
|
|
||||||
export const Emoji = () => (
|
export const Text = ButtonStory.bind({});
|
||||||
<Button onClick={action('clicked')}>
|
Text.args = {
|
||||||
<span role="img" aria-label="so cool">
|
children: 'Button',
|
||||||
😀 😎 👍 💯
|
onClick: action('onClick'),
|
||||||
</span>
|
};
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => (
|
export const TextWithAction = () => (
|
||||||
<Button onClick={() => action('This was clicked')()}>Trigger Action</Button>
|
<Button onClick={() => action('This was clicked')()}>Trigger Action</Button>
|
||||||
|
@ -2,31 +2,35 @@ import { createElement } from 'rax';
|
|||||||
import { action } from '@storybook/addon-actions';
|
import { action } from '@storybook/addon-actions';
|
||||||
import { linkTo } from '@storybook/addon-links';
|
import { linkTo } from '@storybook/addon-links';
|
||||||
|
|
||||||
import Text from 'rax-text';
|
import RaxText from 'rax-text';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const text = () => (
|
const ButtonStory = ({ children, ...args }) => (
|
||||||
<button type="button">
|
<button type="button" {...args}>
|
||||||
<Text>Hello Button</Text>
|
<RaxText>{children}</RaxText>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Emoji = () => (
|
export const Text = ButtonStory.bind({});
|
||||||
<button onClick={action('clicked')} type="button">
|
Text.args = {
|
||||||
<Text role="img" aria-label="so cool">
|
children: 'Button',
|
||||||
😀 😎 👍 💯
|
onClick: action('onClick'),
|
||||||
</Text>
|
};
|
||||||
</button>
|
|
||||||
);
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => (
|
export const TextWithAction = () => (
|
||||||
<button onClick={() => action('This was clicked')()} type="button">
|
<button onClick={() => action('This was clicked')()} type="button">
|
||||||
<Text>Trigger Action</Text>
|
<RaxText>Trigger Action</RaxText>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -35,7 +39,7 @@ TextWithAction.parameters = { notes: 'My notes on a button with emojis' };
|
|||||||
|
|
||||||
export const ButtonWithLinkToAnotherStory = () => (
|
export const ButtonWithLinkToAnotherStory = () => (
|
||||||
<button onClick={linkTo('Welcome')} type="button">
|
<button onClick={linkTo('Welcome')} type="button">
|
||||||
<Text>Go to Welcome Story</Text>
|
<RaxText>Go to Welcome Story</RaxText>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ import { Button } from './Button';
|
|||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const ButtonStory = (args) => <Button {...args} />;
|
const ButtonStory = (args) => <Button {...args} />;
|
||||||
|
@ -8,11 +8,23 @@ import './MyButton.tag';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
|
argTypes: {
|
||||||
|
content: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args) => mount('my-button', args);
|
||||||
tags: ['<my-button>Hello Button</my-button>'],
|
|
||||||
});
|
export const Text = ButtonStory.bind({});
|
||||||
|
Text.args = {
|
||||||
|
content: 'Button',
|
||||||
|
onClick: action('onClick'),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
content: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const WithScenario = () => ({
|
export const WithScenario = () => ({
|
||||||
tags: [{ content: MyButtonRaw, boundAs: 'MyButton' }],
|
tags: [{ content: MyButtonRaw, boundAs: 'MyButton' }],
|
||||||
|
@ -6,23 +6,26 @@ import Button from './button.svelte';
|
|||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args) => ({
|
||||||
Component: Button,
|
Component: Button,
|
||||||
props: { text: 'Hello Button' },
|
props: args,
|
||||||
on: { click: action('clicked') },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Emoji = () => ({
|
export const Text = ButtonStory.bind({});
|
||||||
Component: Button,
|
Text.args = {
|
||||||
props: {
|
children: 'Button',
|
||||||
text: '😀 😎 👍 💯',
|
click: action('onClick'),
|
||||||
},
|
};
|
||||||
on: { click: action('clicked') },
|
|
||||||
});
|
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => ({
|
export const TextWithAction = () => ({
|
||||||
Component: Button,
|
Component: Button,
|
||||||
|
@ -8,12 +8,23 @@ export default {
|
|||||||
component: MyButton,
|
component: MyButton,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => ({
|
const ButtonStory = (args) => ({
|
||||||
|
props: Object.keys(args),
|
||||||
components: { MyButton },
|
components: { MyButton },
|
||||||
template: '<my-button @click="action">Hello Button</my-button>',
|
template: '<my-button :color="color" :rounded="rounded">{{label}}</my-button>',
|
||||||
methods: { action: action('clicked') },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const Text = ButtonStory.bind({});
|
||||||
|
Text.args = {
|
||||||
|
children: 'Button',
|
||||||
|
onClick: action('onClick'),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => ({
|
export const TextWithAction = () => ({
|
||||||
components: { MyButton },
|
components: { MyButton },
|
||||||
template: '<my-button @click="action">Trigger Action</my-button>',
|
template: '<my-button @click="action">Trigger Action</my-button>',
|
||||||
|
@ -4,21 +4,27 @@ import { linkTo } from '@storybook/addon-links';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
title: 'Button',
|
||||||
|
argTypes: {
|
||||||
|
children: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Text = () => html`
|
const ButtonStory = (args) => html`
|
||||||
<button @click=${action('clicked')}>
|
<button @click=${action('clicked')}>
|
||||||
Hello Button
|
Hello Button
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Emoji = () => html`
|
export const Text = ButtonStory.bind({});
|
||||||
<button @click=${action('clicked')}>
|
Text.args = {
|
||||||
😀 😎 👍 💯
|
children: 'Button',
|
||||||
</button>
|
onClick: action('onClick'),
|
||||||
`;
|
};
|
||||||
|
|
||||||
Emoji.parameters = { notes: 'My notes on a button with emojis' };
|
export const Emoji = ButtonStory.bind({});
|
||||||
|
Emoji.args = {
|
||||||
|
children: '😀 😎 👍 💯',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextWithAction = () => html`
|
export const TextWithAction = () => html`
|
||||||
<button @click=${() => action('This was clicked')()}>
|
<button @click=${() => action('This was clicked')()}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user