Skip to content

Commit 482f838

Browse files
author
Muhammed Thanish
authored
Merge pull request #111 from storybooks/device-msg
Show a help text on device
2 parents a087ed7 + 3b36dc2 commit 482f838

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/preview/components/StoryView/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { View } from 'react-native';
2+
import { View, Text } from 'react-native';
33
import style from './style';
44

55
export default class StoryView extends Component {
@@ -13,9 +13,19 @@ export default class StoryView extends Component {
1313
this.setState({storyFn, selection});
1414
}
1515

16+
renderHelp() {
17+
return (
18+
<View style={style.help}>
19+
{this.props.url
20+
? <Text>Please open the Storybook UI ({this.props.url}) with a web browser and select a story for preview.</Text>
21+
: <Text>Please open the Storybook UI with a web browser and select a story for preview.</Text>}
22+
</View>
23+
);
24+
}
25+
1626
render() {
1727
if (!this.state.storyFn) {
18-
return null;
28+
return this.renderHelp();
1929
}
2030
const { kind, story } = this.state.selection;
2131
const context = { kind, story };

src/preview/components/StoryView/style.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ export default {
22
main: {
33
flex: 1,
44
},
5+
help: {
6+
flex: 1,
7+
padding: 15,
8+
alignItems: 'center',
9+
justifyContent: 'center',
10+
},
511
};

src/preview/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ export default class Preview {
5454

5555
getStorybookUI(params = {}) {
5656
return () => {
57+
let webUrl = null;
5758
let channel = addons.getChannel();
5859
if (!channel) {
5960
const host = params.host || 'localhost';
6061
const port = params.port || 7007;
6162
const url = `ws://${host}:${port}`;
63+
webUrl = `http://${host}:${port}`;
6264
channel = createChannel({ url });
6365
addons.setChannel(channel);
6466
}
@@ -67,7 +69,7 @@ export default class Preview {
6769
this._sendSetStories();
6870
this._sendGetCurrentStory();
6971
// finally return the preview component
70-
return <StoryView events={this._events} />;
72+
return <StoryView url={webUrl} events={this._events} />;
7173
}
7274
}
7375

0 commit comments

Comments
 (0)