File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
2- import { View } from 'react-native' ;
2+ import { View , Text } from 'react-native' ;
33import style from './style' ;
44
55export 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 } ;
Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments