|
| 1 | +import React from 'react'; |
| 2 | +import { storiesOf } from '@storybook/react'; |
| 3 | + |
| 4 | +import { Text } from 'react-native'; |
| 5 | +import { Header } from 'react-native-elements'; |
| 6 | + |
| 7 | +import MyCustomLeftComponent from './MyCustomLeftComponent' |
| 8 | +import MyCustomCenterComponent from './MyCustomCenterComponent' |
| 9 | +import MyCustomRightComponent from './MyCustomRightComponent' |
| 10 | + |
| 11 | +storiesOf('Header|Header', module) |
| 12 | + |
| 13 | + .add('with default components', () => ( |
| 14 | + <Header |
| 15 | + leftComponent={{ icon: 'menu', color: '#fff' }} |
| 16 | + centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }} |
| 17 | + rightComponent={{ icon: 'home', color: '#fff' }} |
| 18 | + /> |
| 19 | + )) |
| 20 | + |
| 21 | + .add('Left aligned center component', () => ( |
| 22 | + <Header |
| 23 | + placement="left" |
| 24 | + leftComponent={{ icon: 'menu', color: '#fff' }} |
| 25 | + centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }} |
| 26 | + rightComponent={{ icon: 'home', color: '#fff' }} |
| 27 | + /> |
| 28 | + )) |
| 29 | + |
| 30 | + .add('with custom components passed in through props', () => ( |
| 31 | + <Header |
| 32 | + leftComponent={<MyCustomLeftComponent />} |
| 33 | + centerComponent={<MyCustomCenterComponent />} |
| 34 | + rightComponent={<MyCustomRightComponent />} |
| 35 | + /> |
| 36 | + )) |
| 37 | + |
| 38 | + .add('with mixed components', () => { |
| 39 | + const renderCenterComponent = () => ( |
| 40 | + <Text style={{ fontWeight: 'bold', color: '#fff' }}> |
| 41 | + React Native Elements |
| 42 | + </Text> |
| 43 | + ) |
| 44 | + |
| 45 | + return ( |
| 46 | + <Header |
| 47 | + leftComponent={<MyCustomLeftComponent />} |
| 48 | + centerComponent={renderCenterComponent()} |
| 49 | + rightComponent={{ icon: 'home', style: { color: '#fff' } }} |
| 50 | + /> |
| 51 | + ) |
| 52 | + }) |
| 53 | + |
| 54 | + .add('with custom components passed in as children', () => ( |
| 55 | + <Header> |
| 56 | + <MyCustomLeftComponent /> |
| 57 | + <MyCustomCenterComponent /> |
| 58 | + <MyCustomRightComponent /> |
| 59 | + </Header> |
| 60 | + )) |
| 61 | + |
| 62 | + .add('Header customisability', () => ( |
| 63 | + <Header |
| 64 | + statusBarProps={{ barStyle: 'light-content' }} |
| 65 | + barStyle="light-content" // or directly |
| 66 | + leftComponent={<MyCustomLeftComponent />} |
| 67 | + centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }} |
| 68 | + containerStyle={{ |
| 69 | + backgroundColor: '#3D6DCC', |
| 70 | + justifyContent: 'space-around', |
| 71 | + }} |
| 72 | + /> |
| 73 | + )); |
0 commit comments