Skip to content

Commit

Permalink
Add some help text into the react-native preview panel
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-oakes committed May 28, 2017
1 parent af985d1 commit 4cd2c15
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
62 changes: 62 additions & 0 deletions app/react-native/src/manager/components/PreviewHelp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

class PreviewHelp extends Component {
render() {
return (
<div style={styles.container}>
<p>
To see your Storybook stories on the device, you should start your mobile app for the &lt;platform&gt; of your choice (typically ios or android).
</p>
<div style={styles.instructionsContainer}>
<div style={styles.instructions}>
<p style={styles.instructionsText}>For create-react-native-app apps:</p>
<pre style={styles.instructionsCode}>npm run &lt;platform&gt;</pre>
</div>
<div style={styles.instructions}>
<p style={styles.instructionsText}>For "react-native init" or ejected apps:</p>
<pre style={styles.instructionsCode}>react-native run-&lt;platform&gt;</pre>
</div>
</div>
</div>
);
}
}

const styles = {
container: {
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
background: 'white',
width: '100%',
height: '100%',
},

instructionsContainer: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
width: '50%',
},
instructions: {
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
margin: '0 20px',
},
instructionsText: {
marginBottom: '0',
},
instructionsCode: {
width: '100%',
padding: '10px',
backgroundColor: '#EEEEEE',
textAlign: 'center',
},
};

export default PreviewHelp;
3 changes: 2 additions & 1 deletion app/react-native/src/manager/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Provider } from '@storybook/ui';
import createChannel from '@storybook/channel-websocket';
import addons from '@storybook/addons';
import uuid from 'uuid';
import PreviewHelp from './components/PreviewHelp';

export default class ReactProvider extends Provider {
constructor({ url: domain, options }) {
Expand Down Expand Up @@ -47,7 +48,7 @@ export default class ReactProvider extends Provider {
);
}

return innerPreview;
return innerPreview || <PreviewHelp />;
}

handleAPI(api) {
Expand Down

0 comments on commit 4cd2c15

Please sign in to comment.