Skip to content
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 help text to the react-native preview panel #1142

Merged
merged 1 commit into from
May 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions app/react-native/src/manager/components/PreviewHelp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

class PreviewHelp extends Component {
render() {
return (
<div style={styles.main}>
<h1>Welcome to STORYBOOK</h1>
<p>
This is a UI component dev environment for your app.
</p>
<p>
We've added some basic stories inside the
{' '}
<span style={styles.code}>storybook/stories</span>
{' '}
directory.
{' '}
A story is a single state of one or more UI components. You can have as many stories as you want. Basically a story is like a visual test case.
</p>
<p>
To see your Storybook stories on the device, you should start your mobile app for the
{' '}
<span style={styles.code}>&lt;platform&gt;</span>
{' '}
of your choice (typically ios or android).
</p>
<p>
For <span style={styles.code}>create-react-native-app</span> apps:
</p>
<div style={styles.codeBlock}>
<pre style={styles.instructionsCode}>npm run &lt;platform&gt;</pre>
</div>
<p>
For <span style={styles.code}>react-native init</span> apps:
</p>
<div style={styles.codeBlock}>
<pre style={styles.instructionsCode}>npm run &lt;platform&gt;</pre>
</div>
</div>
);
}
}

const styles = {
main: {
margin: 15,
maxWidth: 600,
lineHeight: 1.4,
fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
},

code: {
fontSize: 15,
fontWeight: 600,
padding: '2px 5px',
border: '1px solid #eae9e9',
borderRadius: 4,
backgroundColor: '#f3f2f2',
color: '#3a3a3a',
},

codeBlock: {
backgroundColor: '#f3f2f2',
padding: '1px 10px',
margin: '10px 0',
},
};

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