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
Angular: Convert angular-cli stories to CSF #7668
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c560ee2
Angular: Convert angular-cli stories to CSF
shilman 3a3768d
Merge branch 'next' into 7101-angular-example-to-csf
ndelangen 854204e
Merge branch 'next' into 7101-angular-example-to-csf
shilman 6ae2223
Angular-cli example: Fix failing storyshots
shilman File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
49 changes: 30 additions & 19 deletions
49
examples/angular-cli/src/stories/addon-actions.stories.ts
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,23 +1,34 @@ | ||
import { storiesOf } from '@storybook/angular'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { Button } from '@storybook/angular/demo'; | ||
|
||
storiesOf('Addon|Actions', module) | ||
.add('Action only', () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Action only', | ||
onClick: action('log 1'), | ||
}, | ||
})) | ||
.add('Action and method', () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Action and Method', | ||
onClick: e => { | ||
console.log(e); | ||
e.preventDefault(); | ||
action('log2')(e.target); | ||
}, | ||
export default { | ||
title: 'Addon|Actions', | ||
}; | ||
|
||
export const actionOnly = () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Action only', | ||
onClick: action('log 1'), | ||
}, | ||
}); | ||
|
||
actionOnly.story = { | ||
name: 'Action only', | ||
}; | ||
|
||
export const actionAndMethod = () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Action and Method', | ||
onClick: e => { | ||
console.log(e); | ||
e.preventDefault(); | ||
action('log2')(e.target); | ||
}, | ||
})); | ||
}, | ||
}); | ||
|
||
actionAndMethod.story = { | ||
name: 'Action and method', | ||
}; |
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,24 +1,28 @@ | ||
import { storiesOf } from '@storybook/angular'; | ||
import { withTests } from '@storybook/addon-jest'; | ||
|
||
import { AppComponent } from '../app/app.component'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import * as results from '../../addon-jest.testresults.json'; | ||
|
||
storiesOf('Addon|Jest', module) | ||
.addDecorator( | ||
export default { | ||
title: 'Addon|Jest', | ||
decorators: [ | ||
withTests({ | ||
results, | ||
filesExt: '((\\.specs?)|(\\.tests?))?(\\.ts)?$', | ||
}) | ||
) | ||
.add( | ||
'app.component with jest tests', | ||
() => ({ | ||
component: AppComponent, | ||
props: {}, | ||
}), | ||
{ | ||
jest: 'app.component', | ||
} | ||
); | ||
], | ||
}; | ||
|
||
export const appComponentWithJestTests = () => ({ | ||
component: AppComponent, | ||
props: {}, | ||
}); | ||
|
||
appComponentWithJestTests.story = { | ||
name: 'app.component with jest tests', | ||
|
||
parameters: { | ||
jest: 'app.component', | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import { linkTo } from '@storybook/addon-links'; | ||
import { storiesOf } from '@storybook/angular'; | ||
import { Button } from '@storybook/angular/demo'; | ||
|
||
storiesOf('Addon|Links', module).add('button with link to another story', () => ({ | ||
export default { | ||
title: 'Addon|Links', | ||
}; | ||
|
||
export const buttonWithLinkToAnotherStory = () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Go to Welcome Story', | ||
onClick: linkTo('Welcome'), | ||
}, | ||
})); | ||
}); | ||
|
||
buttonWithLinkToAnotherStory.story = { | ||
name: 'button with link to another 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,34 +1,39 @@ | ||
import { storiesOf } from '@storybook/angular'; | ||
import { Button } from '@storybook/angular/demo'; | ||
|
||
storiesOf('Addon|Notes', module) | ||
.add( | ||
'Simple note', | ||
() => ({ | ||
component: Button, | ||
props: { | ||
text: 'Notes on some Button', | ||
onClick: () => {}, | ||
}, | ||
}), | ||
{ notes: 'My notes on some button' } | ||
) | ||
.add( | ||
'Note with HTML', | ||
() => ({ | ||
component: Button, | ||
props: { | ||
text: 'Notes with HTML', | ||
onClick: () => {}, | ||
}, | ||
}), | ||
{ | ||
notes: ` | ||
<h2>My notes on emojis</h2> | ||
export default { | ||
title: 'Addon|Notes', | ||
}; | ||
|
||
<em>It's not all that important to be honest, but..</em> | ||
export const simpleNote = () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Notes on some Button', | ||
onClick: () => {}, | ||
}, | ||
}); | ||
|
||
Emojis are great, I love emojis, in fact I like using them in my Component notes too! 😇 | ||
`, | ||
} | ||
); | ||
simpleNote.story = { | ||
name: 'Simple note', | ||
parameters: { notes: 'My notes on some button' }, | ||
}; | ||
|
||
export const noteWithHtml = () => ({ | ||
component: Button, | ||
props: { | ||
text: 'Notes with HTML', | ||
onClick: () => {}, | ||
}, | ||
}); | ||
|
||
noteWithHtml.story = { | ||
name: 'Note with HTML', | ||
parameters: { | ||
notes: ` | ||
<h2>My notes on emojis</h2> | ||
|
||
<em>It's not all that important to be honest, but..</em> | ||
|
||
Emojis are great, I love emojis, in fact I like using them in my Component notes too! 😇 | ||
`, | ||
}, | ||
}; |
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,7 +1,14 @@ | ||
import { storiesOf } from '@storybook/angular'; | ||
import { AppComponent } from '../app/app.component'; | ||
|
||
storiesOf('App Component', module).add('Component with separate template', () => ({ | ||
export default { | ||
title: 'App Component', | ||
}; | ||
|
||
export const componentWithSeparateTemplate = () => ({ | ||
component: AppComponent, | ||
props: {}, | ||
})); | ||
}); | ||
|
||
componentWithSeparateTemplate.story = { | ||
name: 'Component with separate template', | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to type this? In
strict: true
you most likely have toexport const actionOnly: any
in order to call.story
Maybe
actionOnly: Story = () => { ... }
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kroeder great idea! #7677