-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1568 from storybooks/1222-parse-rn-packager-host
Use the RN packager's host by default
- Loading branch information
Showing
24 changed files
with
353 additions
and
6 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
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,8 @@ | ||
{ | ||
"presets": ["babel-preset-expo"], | ||
"env": { | ||
"development": { | ||
"plugins": ["transform-react-jsx-source"] | ||
} | ||
} | ||
} |
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,63 @@ | ||
[ignore] | ||
; We fork some components by platform | ||
.*/*[.]android.js | ||
|
||
; Ignore "BUCK" generated dirs | ||
<PROJECT_ROOT>/\.buckd/ | ||
|
||
; Ignore unexpected extra "@providesModule" | ||
.*/node_modules/.*/node_modules/fbjs/.* | ||
|
||
; Ignore duplicate module providers | ||
; For RN Apps installed via npm, "Libraries" folder is inside | ||
; "node_modules/react-native" but in the source repo it is in the root | ||
.*/Libraries/react-native/React.js | ||
.*/Libraries/react-native/ReactNative.js | ||
|
||
; Additional create-react-native-app ignores | ||
|
||
; Ignore duplicate module providers | ||
.*/node_modules/fbemitter/lib/* | ||
|
||
; Ignore misbehaving dev-dependencies | ||
.*/node_modules/xdl/build/* | ||
.*/node_modules/reqwest/tests/* | ||
|
||
; Ignore missing expo-sdk dependencies (temporarily) | ||
; https://github.com/expo/expo/issues/162 | ||
.*/node_modules/expo/src/* | ||
|
||
; Ignore react-native-fbads dependency of the expo sdk | ||
.*/node_modules/react-native-fbads/* | ||
|
||
[include] | ||
|
||
[libs] | ||
node_modules/react-native/Libraries/react-native/react-native-interface.js | ||
node_modules/react-native/flow | ||
flow/ | ||
|
||
[options] | ||
module.system=haste | ||
|
||
emoji=true | ||
|
||
experimental.strict_type_args=true | ||
|
||
munge_underscores=true | ||
|
||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' | ||
|
||
suppress_type=$FlowIssue | ||
suppress_type=$FlowFixMe | ||
suppress_type=$FixMe | ||
|
||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\) | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+ | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError | ||
|
||
unsafe.enable_getters_and_setters=true | ||
|
||
[version] | ||
^0.47.0 |
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 @@ | ||
node_modules/ | ||
.expo/ | ||
npm-debug.* |
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 @@ | ||
{} |
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,29 @@ | ||
export default from './storybook'; | ||
|
||
// NOTE: The code below is what CRNA generates out of the box. We currently | ||
// have no clever way of replacing this with Storybook's UI (Vanilla RN does!) | ||
// so for now we just replace the code outright. Keeping this here for clarity. | ||
// | ||
// import React from 'react'; | ||
// import { StyleSheet, Text, View } from 'react-native'; | ||
// | ||
// export default class App extends React.Component { | ||
// render() { | ||
// return ( | ||
// <View style={styles.container}> | ||
// <Text>Open up App.js to start working on your app!</Text> | ||
// <Text>Changes you make will automatically reload.</Text> | ||
// <Text>Shake your phone to open the developer menu.</Text> | ||
// </View> | ||
// ); | ||
// } | ||
// } | ||
// | ||
// const styles = StyleSheet.create({ | ||
// container: { | ||
// flex: 1, | ||
// backgroundColor: '#fff', | ||
// alignItems: 'center', | ||
// justifyContent: 'center', | ||
// }, | ||
// }); |
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,9 @@ | ||
import renderer from 'react-test-renderer'; | ||
|
||
import React from 'react'; | ||
import App from './App'; | ||
|
||
it('renders without crashing', () => { | ||
const rendered = renderer.create(<App />).toJSON(); | ||
expect(rendered).toBeTruthy(); | ||
}); |
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 @@ | ||
# CRNA Kitchen Sink | ||
|
||
This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app) and storybook using [getstorybook](https://www.npmjs.com/package/@storybook/cli). |
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,5 @@ | ||
{ | ||
"expo": { | ||
"sdkVersion": "19.0.0" | ||
} | ||
} |
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,36 @@ | ||
{ | ||
"name": "crna-kitchen-sink", | ||
"version": "0.1.0", | ||
"private": true, | ||
"devDependencies": { | ||
"@storybook/addon-actions": "file:../../addons/actions", | ||
"@storybook/addon-links": "file:../../addons/links", | ||
"@storybook/addon-options": "file:../../addons/options", | ||
"@storybook/addon-storyshots": "file:../../addons/storyshots", | ||
"@storybook/addons": "file:../../lib/addons", | ||
"@storybook/channels": "file:../../lib/channels", | ||
"@storybook/channel-postmessage": "file:../../lib/channel-postmessage", | ||
"@storybook/react-native": "file:../../app/react-native", | ||
"@storybook/ui": "file:../../lib/ui", | ||
"react-native-scripts": "1.1.0", | ||
"jest-expo": "~19.0.0", | ||
"react-test-renderer": "16.0.0-alpha.12" | ||
}, | ||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", | ||
"scripts": { | ||
"start": "react-native-scripts start", | ||
"eject": "react-native-scripts eject", | ||
"android": "react-native-scripts android", | ||
"ios": "react-native-scripts ios", | ||
"test": "node node_modules/jest/bin/jest.js --watch", | ||
"storybook": "storybook start -p 7007" | ||
}, | ||
"jest": { | ||
"preset": "jest-expo" | ||
}, | ||
"dependencies": { | ||
"expo": "^19.0.0", | ||
"react": "16.0.0-alpha.12", | ||
"react-native": "^0.46.1" | ||
} | ||
} |
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 '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; | ||
import '@storybook/addon-options/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,24 @@ | ||
import { getStorybookUI, configure } from '@storybook/react-native'; | ||
import { setOptions } from '@storybook/addon-options'; | ||
|
||
// import stories | ||
configure(() => { | ||
// eslint-disable-next-line global-require | ||
require('./stories'); | ||
}, module); | ||
|
||
const StorybookUI = getStorybookUI({ | ||
port: 7007, | ||
onDeviceUI: true, | ||
}); | ||
|
||
setTimeout( | ||
() => | ||
setOptions({ | ||
name: 'CRNA React Native App', | ||
onDeviceUI: true, | ||
}), | ||
100 | ||
); | ||
|
||
export default StorybookUI; |
22 changes: 22 additions & 0 deletions
22
examples/crna-kitchen-sink/storybook/stories/Button/index.android.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ | ||
|
||
import React, { PropTypes } from 'react'; | ||
import { TouchableNativeFeedback } from 'react-native'; | ||
|
||
export default function Button(props) { | ||
return ( | ||
<TouchableNativeFeedback onPress={props.onPress}> | ||
{props.children} | ||
</TouchableNativeFeedback> | ||
); | ||
} | ||
|
||
Button.defaultProps = { | ||
children: null, | ||
onPress: () => {}, | ||
}; | ||
|
||
Button.propTypes = { | ||
children: PropTypes.node, | ||
onPress: PropTypes.func, | ||
}; |
22 changes: 22 additions & 0 deletions
22
examples/crna-kitchen-sink/storybook/stories/Button/index.ios.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ | ||
|
||
import React, { PropTypes } from 'react'; | ||
import { TouchableHighlight } from 'react-native'; | ||
|
||
export default function Button(props) { | ||
return ( | ||
<TouchableHighlight onPress={props.onPress}> | ||
{props.children} | ||
</TouchableHighlight> | ||
); | ||
} | ||
|
||
Button.defaultProps = { | ||
children: null, | ||
onPress: () => {}, | ||
}; | ||
|
||
Button.propTypes = { | ||
children: PropTypes.node, | ||
onPress: PropTypes.func, | ||
}; |
21 changes: 21 additions & 0 deletions
21
examples/crna-kitchen-sink/storybook/stories/CenterView/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ | ||
|
||
import React, { PropTypes } from 'react'; | ||
import { View } from 'react-native'; | ||
import style from './style'; | ||
|
||
export default function CenterView(props) { | ||
return ( | ||
<View style={style.main}> | ||
{props.children} | ||
</View> | ||
); | ||
} | ||
|
||
CenterView.defaultProps = { | ||
children: null, | ||
}; | ||
|
||
CenterView.propTypes = { | ||
children: PropTypes.node, | ||
}; |
8 changes: 8 additions & 0 deletions
8
examples/crna-kitchen-sink/storybook/stories/CenterView/style.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
main: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
}; |
54 changes: 54 additions & 0 deletions
54
examples/crna-kitchen-sink/storybook/stories/Welcome/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ | ||
|
||
import React, { PropTypes } from 'react'; | ||
import { View, Text } from 'react-native'; | ||
|
||
export default class Welcome extends React.Component { | ||
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</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> | ||
); | ||
} | ||
} | ||
|
||
Welcome.defaultProps = { | ||
showApp: null, | ||
}; | ||
|
||
Welcome.propTypes = { | ||
showApp: PropTypes.func, | ||
}; |
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,29 @@ | ||
import React from 'react'; | ||
import { Text } from 'react-native'; | ||
|
||
import { storiesOf } from '@storybook/react-native'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { linkTo } from '@storybook/addon-links'; | ||
|
||
import Button from './Button'; | ||
import CenterView from './CenterView'; | ||
import Welcome from './Welcome'; | ||
|
||
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />); | ||
|
||
storiesOf('Button', module) | ||
.addDecorator(getStory => | ||
<CenterView> | ||
{getStory()} | ||
</CenterView> | ||
) | ||
.add('with text', () => | ||
<Button onPress={action('clicked-text')}> | ||
<Text>Hello Button</Text> | ||
</Button> | ||
) | ||
.add('with some emoji', () => | ||
<Button onPress={action('clicked-emoji')}> | ||
<Text>😀 😎 👍 💯</Text> | ||
</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
Oops, something went wrong.