-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Added create-react-native-app support #1117
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e2673b
Add CRNA support
shilman cfe5239
Fix linting and simplify code in CRNA generator
shilman fbb5a86
Fix linting err in CRNA script
shilman b7df231
Remove unused variable in CRNA
shilman 01db559
Suppress lint error
shilman d7ab0c2
Merge branch 'master' into 1115-crna-support
ndelangen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,25 @@ | ||
const mergeDirs = require('merge-dirs').default; | ||
const helpers = require('../../lib/helpers'); | ||
const path = require('path'); | ||
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'; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice one 👍 |
||
|
||
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
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.
This is a good coverage of options, nice work