-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4081900
commit c061a3c
Showing
15 changed files
with
290 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
import type { Meta, StoryFn } from '@storybook/angular'; | ||
import type { Meta, StoryObj } from '@storybook/angular'; | ||
import Button from './button.component'; | ||
|
||
// More on default export: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export | ||
export default { | ||
// More on how to set up stories at: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export | ||
const meta: Meta<Button> = { | ||
title: 'Example/Button', | ||
component: Button, | ||
// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args | ||
render: (args: Button) => ({ | ||
props: { | ||
backgroundColor: null, | ||
...args, | ||
}, | ||
}), | ||
// More on argTypes: https://storybook.js.org/docs/angular/api/argtypes | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
backgroundColor: { | ||
control: 'color', | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args | ||
const Template: StoryFn<Button> = (args: Button) => { | ||
return { | ||
props: { backgroundColor: null, ...args }, | ||
}; | ||
}; | ||
|
||
export const Primary = Template.bind({}); | ||
// More on args: https://storybook.js.org/docs/angular/writing-stories/args | ||
Primary.args = { | ||
primary: true, | ||
label: 'Button', | ||
export default meta; | ||
type Story = StoryObj<Button>; | ||
|
||
// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args | ||
export const Primary: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Secondary = Template.bind({}); | ||
Secondary.args = { | ||
label: 'Button', | ||
export const Secondary: Story = { | ||
args: { | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Large = Template.bind({}); | ||
Large.args = { | ||
size: 'large', | ||
label: 'Button', | ||
export const Large: Story = { | ||
args: { | ||
size: 'large', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Small = Template.bind({}); | ||
Small.args = { | ||
size: 'small', | ||
label: 'Button', | ||
export const Small: Story = { | ||
args: { | ||
size: 'small', | ||
label: 'Button', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 29 additions & 23 deletions
52
code/frameworks/nextjs/template/cli/ts/Button.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,47 @@ | ||
import * as React from 'react'; | ||
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Button } from './Button'; | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
export default { | ||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
const meta: Meta<typeof Button> = { | ||
title: 'Example/Button', | ||
component: Button, | ||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
backgroundColor: { | ||
control: 'color', | ||
}, | ||
}, | ||
} as ComponentMeta<typeof Button>; | ||
}; | ||
|
||
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
const Template: ComponentStoryFn<typeof Button> = (args) => <Button {...args} />; | ||
export default meta; | ||
type Story = StoryObj<typeof Button>; | ||
|
||
export const Primary = Template.bind({}); | ||
// More on args: https://storybook.js.org/docs/react/writing-stories/args | ||
Primary.args = { | ||
primary: true, | ||
label: 'Button', | ||
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
export const Primary: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Secondary = Template.bind({}); | ||
Secondary.args = { | ||
label: 'Button', | ||
export const Secondary: Story = { | ||
args: { | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Large = Template.bind({}); | ||
Large.args = { | ||
size: 'large', | ||
label: 'Button', | ||
export const Large: Story = { | ||
args: { | ||
size: 'large', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Small = Template.bind({}); | ||
Small.args = { | ||
size: 'small', | ||
label: 'Button', | ||
export const Small: Story = { | ||
args: { | ||
size: 'small', | ||
label: 'Button', | ||
}, | ||
}; |
22 changes: 11 additions & 11 deletions
22
code/frameworks/nextjs/template/cli/ts/Header.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import React from 'react'; | ||
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Header } from './Header'; | ||
|
||
export default { | ||
const meta: Meta<typeof Header> = { | ||
title: 'Example/Header', | ||
component: Header, | ||
parameters: { | ||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout | ||
layout: 'fullscreen', | ||
}, | ||
} as ComponentMeta<typeof Header>; | ||
}; | ||
|
||
const Template: ComponentStoryFn<typeof Header> = (args) => <Header {...args} />; | ||
export default meta; | ||
type Story = StoryObj<typeof Header>; | ||
|
||
export const LoggedIn = Template.bind({}); | ||
LoggedIn.args = { | ||
user: { | ||
name: 'Jane Doe', | ||
export const LoggedIn: Story = { | ||
args: { | ||
user: { | ||
name: 'Jane Doe', | ||
}, | ||
}, | ||
}; | ||
|
||
export const LoggedOut = Template.bind({}); | ||
LoggedOut.args = {}; | ||
export const LoggedOut: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import React from 'react'; | ||
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { within, userEvent } from '@storybook/testing-library'; | ||
|
||
import { Page } from './Page'; | ||
|
||
export default { | ||
const meta: Meta<typeof Page> = { | ||
title: 'Example/Page', | ||
component: Page, | ||
parameters: { | ||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout | ||
layout: 'fullscreen', | ||
}, | ||
} as ComponentMeta<typeof Page>; | ||
|
||
const Template: ComponentStoryFn<typeof Page> = (args) => <Page {...args} />; | ||
}; | ||
|
||
export const LoggedOut = Template.bind({}); | ||
export default meta; | ||
type Story = StoryObj<typeof Page>; | ||
|
||
export const LoggedIn = Template.bind({}); | ||
export const LoggedOut: Story = {}; | ||
|
||
// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing | ||
LoggedIn.play = async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
const loginButton = await canvas.getByRole('button', { name: /Log in/i }); | ||
await userEvent.click(loginButton); | ||
export const LoggedIn: Story = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
const loginButton = await canvas.getByRole('button', { | ||
name: /Log in/i, | ||
}); | ||
await userEvent.click(loginButton); | ||
}, | ||
}; |
Oops, something went wrong.