This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
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
450edb2
commit d6b8b65
Showing
4 changed files
with
50 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default class Example extends Component { | ||
static propTypes = { | ||
inverted: PropTypes.bool | ||
} | ||
|
||
render() { | ||
const { inverted } = this.props; | ||
|
||
let divProps; | ||
|
||
if (inverted) { | ||
divProps = { style: { background: 'black', color: 'white' } }; | ||
} | ||
|
||
return ( | ||
<div {...divProps}> | ||
<h1>This is an example story.</h1> | ||
<p>Navigate to <strong>.storybook/Example</strong> to see how to add a story to your component.</p> | ||
<p>For more info, have a look at the <a target="_blank" href="https://storybook.js.org/basics/introduction/">docs</a> or at some <a target="_blank" href="https://storybook.js.org/examples/">examples</a>.</p> | ||
</div> | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Example from './'; | ||
|
||
// Defaults to <name>.story.js | ||
export const name = 'Example component'; | ||
|
||
export default story => { | ||
const states = { | ||
'Regular state': () => ( | ||
<Example /> | ||
), | ||
'Inverted state': () => ( | ||
<Example inverted /> | ||
), | ||
}; | ||
|
||
for (const [state, render] of Object.entries(states)) { | ||
story.add(state, render); | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Example.js'; |
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