Skip to content

Commit 8850dc5

Browse files
committed
Add more examples
1 parent b213d4c commit 8850dc5

File tree

5 files changed

+63
-17
lines changed

5 files changed

+63
-17
lines changed

docs/.storybook/decorator-centered.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { StyleSheet, View } from 'react-native';
33

44
const styles = StyleSheet.create({
55
root: {
6+
flex: 1,
7+
alignItems: 'center',
8+
justifyContent: 'center',
69
minHeight: '100vh',
7-
maxWidth: 680,
8-
marginHorizontal: 'auto'
910
}
1011
});
1112

docs/stories/gradientBackground.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native';
3+
import LinearGradient from 'react-native-linear-gradient';
4+
5+
export default () => (
6+
<LinearGradient start={{ x: 0.5, y: 1 }} end={{ x: 0.5, y: 0 }} colors={['red', 'blue']} style={styles.page}>
7+
<Text style={styles.buttonText}>Hello !</Text>
8+
</LinearGradient>
9+
);
10+
11+
const styles = StyleSheet.create({
12+
page: {
13+
flex: 1,
14+
justifyContent: 'center',
15+
},
16+
buttonText: {
17+
fontSize: 18,
18+
textAlign: 'center',
19+
color: '#ffffff',
20+
backgroundColor: 'transparent',
21+
},
22+
});

docs/stories/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react';
2-
3-
import { storiesOf } from '@storybook/react';
42
import LinearGradient from 'react-native-linear-gradient';
53
import { View } from 'react-native';
4+
import signInWithFacebook from './signInWithFacebook';
5+
import gradientBackground from './gradientBackground';
6+
7+
import { storiesOf } from '@storybook/react';
68

7-
storiesOf('LinearGradient', module).add('simple', () => <LinearGradient colors={['red', 'blue']} />);
9+
storiesOf('LinearGradient', module)
10+
.add('signInWithFacebook', signInWithFacebook)
11+
.add('gradientBackground', gradientBackground);

docs/stories/signInWithFacebook.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native';
3+
import LinearGradient from 'react-native-linear-gradient';
4+
5+
export default () => (
6+
<TouchableOpacity>
7+
<LinearGradient colors={['#4c669f', '#3b5998', '#192f6a']} style={styles.linearGradient}>
8+
<Text style={styles.buttonText}>Sign in with Facebook</Text>
9+
</LinearGradient>
10+
</TouchableOpacity>
11+
);
12+
13+
const styles = StyleSheet.create({
14+
linearGradient: {
15+
paddingLeft: 15,
16+
paddingRight: 15,
17+
borderRadius: 5,
18+
},
19+
buttonText: {
20+
fontSize: 18,
21+
fontFamily: 'Gill Sans',
22+
textAlign: 'center',
23+
margin: 10,
24+
color: '#ffffff',
25+
backgroundColor: 'transparent',
26+
},
27+
});

src/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@ import { StyleSheet, View } from 'react-native';
33

44
export default props => {
55
return (
6-
<div
7-
style={{
8-
display: 'flex',
9-
flex: 1,
10-
flexDirection: 'column',
11-
alignItems: 'stretch',
12-
background: `linear-gradient(to top, ${props.colors.join(',')})`,
13-
}}
14-
>
15-
<View style={[styles.container, props.style]}>{props.children}</View>
16-
</div>
6+
<View style={[styles.container, props.style, { backgroundImage: `linear-gradient(to top, ${props.colors.join(',')})` }]}>
7+
{props.children}
8+
</View>
179
);
1810
};
1911

2012
const styles = StyleSheet.create({
2113
container: {
22-
flex: 1,
14+
alignSelf: 'stretch',
2315
},
2416
});

0 commit comments

Comments
 (0)