Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8453854

Browse files
Add story for Header
1 parent c02dfe1 commit 8453854

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
const MyCustomCenterComponent = () => (
5+
<View>
6+
<Text style={{ fontWeight: 'bold', color: '#fff' }}>
7+
React Native Elements
8+
</Text>
9+
</View>
10+
)
11+
12+
export default MyCustomCenterComponent;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import { Avatar } from 'react-native-elements';
3+
4+
const MyCustomLeftComponent = () => (
5+
<Avatar rounded icon={{ name: 'home', type: 'font-awesome' }} />
6+
)
7+
8+
export default MyCustomLeftComponent;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { Button } from 'react-native-elements';
3+
4+
const MyCustomRightComponent = () => (
5+
<Button
6+
icon={{
7+
name: "search",
8+
size: 20,
9+
color: "white",
10+
type: "font-awesome"
11+
}}
12+
/>
13+
)
14+
15+
export default MyCustomRightComponent;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /