38
STORYBOOK & REACT NATIVE Jair Trejo

React storybook

Embed Size (px)

Citation preview

Page 1: React storybook

STORYBOOK &

REACT NATIVE

Jair Trejo

Page 2: React storybook

WHO AM I?

Jair Trejo

Full-stack developer at Chegg

@jairtrejo on Twitter

2

Page 3: React storybook

WHAT IS REACT STORYBOOK?

Page 4: React storybook

4

Page 5: React storybook

5

importReactfrom'react';

import{View}from'react-native';

import{storiesOf,action}from'@kadira/react-native-storybook';

import{SpeechBubble}from‘../../components/SpeechBubble’;

storiesOf(‘SpeechBubble');

.add('defaultview',()=>(

<Viewstyle={{width:300}}>

<SpeechBubblemessage="Default,explanatorybubble"

severity={SpeechBubble.SEVERITY.INFO}

tailPosition={50}/>

</View>

))

.add('warning',()=>(

<SpeechBubblemessage="Watchout!Somethingunexpectedjusthappened"

severity={SpeechBubble.SEVERITY.WARNING}

tailPosition={50}/>

));

Page 6: React storybook

6

Page 7: React storybook

7

A tight feedback loop for developing new components and new states for those components.

Page 8: React storybook

8

A clear, convenient place to communicate and collaborate with designers.

Page 9: React storybook

9

A place where you can visually check that everything works and looks as intended.

Page 10: React storybook

HOW IS IT USEFUL TO ME?

Page 11: React storybook

REACT NATIVE STORYBOOK

11

Page 12: React storybook

12

Page 13: React storybook

13

Page 14: React storybook

14

Page 15: React storybook

15

Page 16: React storybook

16

constsimpleFavorite=newFavorite({

id:'1',

title:'LearningReactNative…’,

url:'https://amzn.com/1491929006',

shortUrl:'amazon.com/gp/product/149…',

source:newSource({

type:'tweet',

id:'707050076170891264',

from:newFriend({

name:'BonnieEisenman',

username:'brindelle'

})

}),

});

storiesOf('FavoriteDetail')

.add('defaultview',()=>(

<FavoriteDetailfavorite={simpleFavorite}

onBack={action('Goback')}

onFavoritePress={action('Favoritepressed')}

onShare={action('Share')}/>

));

Page 17: React storybook

17

linkTo

Page 18: React storybook

18

Page 19: React storybook

19

Page 20: React storybook

20

Page 21: React storybook

21

Page 22: React storybook

22

State

HTMLVDom

UI

Page 23: React storybook

23

Page 24: React storybook

24

exportdefaultconnectComponent(

(state$)=>({

favorites:state$.map('.getIn',['feed','favorites']),

refreshing:state$.map('.getIn',['feed','lastFetched'])

.map(d=>d===null)

}),

()=>({

onFavoritePressed:asActionType('FAVORITE_SELECTED'),

onRefresh:asActionType('FETCH_FAVORITES'),

})

)(Feed);

Page 25: React storybook

25

exportclassFeedextendsComponent{...}

exportdefaultconnectComponent(...)(Feed);

Page 26: React storybook

26

Page 27: React storybook

27

Page 28: React storybook

28

Page 29: React storybook

HOW CAN YOU START USING IT?

Page 30: React storybook

KADIRAHQ/REACT-STORYBOOK

30

Page 31: React storybook

31

Page 32: React storybook

32

import{storiesOf,action}from'@kadira/react-native-storybook';

import{Favorite}from'../../components/Favorite';

storiesOf('Favorite')

.add('defaultview',()=>(

<FavoriteComponentfavorite={simpleFavorite}

onPress={action('Favoritepressed')}/>

));

Page 33: React storybook

33

storiesOf('Favorite')

.addDecorator((story)=>(

<Viewstyle={{

flexDirection:'column',

alignItems:'stretch',

justifyContent:'center',

flex:1}}

>

{story()}

</View>

));

Page 34: React storybook

34

Page 35: React storybook

35

Page 36: React storybook

36

Page 37: React storybook

37

A tight feedback loop for developing new components and new states for those components.

A clear, convenient place to communicate and collaborate with designers.

A place where you can visually check that everything works and looks as intended.

Page 38: React storybook

THANK YOU!

Let’s stay in touch: @jairtrejo