Skip to content

Commit

Permalink
Merge pull request #16989 from WIVSW/button-story-snippets-for-html
Browse files Browse the repository at this point in the history
Button story snippets for html framework
  • Loading branch information
shilman committed Dec 27, 2021
1 parent aa57def commit 595ed22
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/get-started/whats-a-story.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Let’s start with the `Button` component. A story is a function that describes
'svelte/button-story.native-format.mdx',
'svelte/button-story.mdx.mdx',
'web-components/button-story.js.mdx',
'html/button-story.js.mdx',
'html/button-story.ts.mdx',
]}
/>

Expand Down
22 changes: 22 additions & 0 deletions docs/snippets/html/button-story.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```js
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
};

export const Primary = () => {
const btn = document.createElement('button');
btn.innerText = 'Button';

btn.className = [
'storybook-button',
'storybook-button--medium',
'storybook-button--primary',
].join(' ');

return btn;
};
```
24 changes: 24 additions & 0 deletions docs/snippets/html/button-story.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
```ts
import { Meta, StoryFn } from '@storybook/html';

export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
} as Meta;

export const Primary: StoryFn = (): HTMLButtonElement => {
const btn = document.createElement('button');
btn.innerText = 'Button';

btn.className = [
'storybook-button',
'storybook-button--medium',
'storybook-button--primary',
].join(' ');

return btn;
};
```

0 comments on commit 595ed22

Please sign in to comment.