-
-
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
Showing
9 changed files
with
3,170 additions
and
123 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
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,2 @@ | ||
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; |
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,3 @@ | ||
import StorybookUI from './storybook'; | ||
|
||
export default StorybookUI; |
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,3 @@ | ||
import StorybookUI from './storybook'; | ||
|
||
export default StorybookUI; |
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,3 @@ | ||
import StorybookUI from './storybook'; | ||
|
||
export default StorybookUI; |
54 changes: 54 additions & 0 deletions
54
examples/react-native-typesript/storybook/stories/Welcome/index.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { View, Text } from 'react-native'; | ||
|
||
/* | ||
interface Props { | ||
showApp?: () => void, | ||
} | ||
*/ | ||
|
||
type Props = { | ||
showApp: () => void, | ||
}; | ||
|
||
export default class Welcome extends React.Component<Props> { | ||
styles = { | ||
wrapper: { | ||
flex: 1, | ||
padding: 24, | ||
justifyContent: 'center', | ||
}, | ||
header: { | ||
fontSize: 18, | ||
marginBottom: 18, | ||
}, | ||
content: { | ||
fontSize: 12, | ||
marginBottom: 10, | ||
lineHeight: 18, | ||
}, | ||
}; | ||
|
||
showApp(event) { | ||
event.preventDefault(); | ||
if (this.props.showApp) this.props.showApp(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<View style={this.styles.wrapper}> | ||
<Text style={this.styles.header}>Welcome to React Native Storybook (with Typescript)</Text> | ||
<Text style={this.styles.content}> | ||
This is a UI Component development environment for your React Native app. Here you can | ||
display and interact with your UI components as stories. A story is a single state of one | ||
or more UI components. You can have as many stories as you want. In other words a story is | ||
like a visual test case. | ||
</Text> | ||
<Text style={this.styles.content}> | ||
We have added some stories inside the "storybook/stories" directory for examples. Try | ||
editing the "storybook/stories/Welcome.js" file to edit this message. | ||
</Text> | ||
</View> | ||
); | ||
} | ||
} |
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,6 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react-native'; | ||
|
||
import Welcome from './Welcome'; | ||
|
||
storiesOf('Welcome', module).add('to Storybook', () => <Welcome />); |
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 @@ | ||
/* eslint-disable global-require */ | ||
import React, { Component } from 'react'; | ||
import { AppRegistry } from 'react-native'; | ||
import { getStorybookUI, configure } from '@storybook/react-native'; | ||
|
||
// import stories | ||
configure(() => { | ||
// eslint-disable-next-line | ||
require('./stories'); | ||
}, module); | ||
|
||
// This assumes that storybook is running on the same host as your RN packager, | ||
// to set manually use, e.g. host: 'localhost' option | ||
const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true }); | ||
|
||
// react-native hot module loader must take in a Class - https://github.com/facebook/react-native/issues/10991 | ||
// https://github.com/storybooks/storybook/issues/2081 | ||
// eslint-disable-next-line react/prefer-stateless-function | ||
class StorybookUIHMRRoot extends Component { | ||
render() { | ||
return <StorybookUIRoot />; | ||
} | ||
} | ||
|
||
AppRegistry.registerComponent('ReactNativeTypescript', () => StorybookUIHMRRoot); | ||
export default StorybookUIHMRRoot; |
Oops, something went wrong.