-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. detect CRNA projects 2. simplify RN and CRNA templates by consolidating app into single `index.js` instead of `index.ios.js` and `index.android.js` 3. notify user of extra setup steps in CLI 4. document CRNA idiosyncrasies in README
- Loading branch information
Showing
15 changed files
with
197 additions
and
8 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
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,26 @@ | ||
const mergeDirs = require('merge-dirs').default; | ||
const helpers = require('../../lib/helpers'); | ||
const path = require('path'); | ||
const shell = require('shelljs'); | ||
const latestVersion = require('latest-version'); | ||
|
||
module.exports = latestVersion('@storybook/react-native').then(version => { | ||
// copy all files from the template directory to project directory | ||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite'); | ||
|
||
const packageJson = helpers.getPackageJson(); | ||
|
||
packageJson.dependencies = packageJson.dependencies || {}; | ||
packageJson.devDependencies = packageJson.devDependencies || {}; | ||
|
||
packageJson.devDependencies['@storybook/react-native'] = `^${version}`; | ||
|
||
if (!packageJson.dependencies['react-dom'] && !packageJson.devDependencies['react-dom']) { | ||
packageJson.devDependencies['react-dom'] = '^15.5.4'; | ||
} | ||
|
||
packageJson.scripts = packageJson.scripts || {}; | ||
packageJson.scripts['storybook'] = 'storybook start -p 7007'; | ||
|
||
helpers.writePackageJson(packageJson); | ||
}); |
2 changes: 2 additions & 0 deletions
2
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/storybook/addons.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,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
10 changes: 10 additions & 0 deletions
10
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/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,10 @@ | ||
import React from 'react'; | ||
import { TouchableNativeFeedback } from 'react-native'; | ||
|
||
export default function Button(props) { | ||
return ( | ||
<TouchableNativeFeedback onPress={props.onPress || Function()}> | ||
{props.children} | ||
</TouchableNativeFeedback> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/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,10 @@ | ||
import React from 'react'; | ||
import { TouchableHighlight } from 'react-native'; | ||
|
||
export default function Button(props) { | ||
return ( | ||
<TouchableHighlight onPress={props.onPress || Function()}> | ||
{props.children} | ||
</TouchableHighlight> | ||
); | ||
} |
11 changes: 11 additions & 0 deletions
11
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/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,11 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import style from './style'; | ||
|
||
export default function CenterView(props) { | ||
return ( | ||
<View style={style.main}> | ||
{props.children} | ||
</View> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/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', | ||
}, | ||
}; |
40 changes: 40 additions & 0 deletions
40
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/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,40 @@ | ||
import React 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(e) { | ||
e.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> | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/cli/generators/REACT_NATIVE_SCRIPTS/template/storybook/stories/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,25 @@ | ||
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
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