Skip to content

Commit 6074760

Browse files
committed
Merge pull request oblador#30 from xirc/overlay-background-color
Add backgroundColor property
2 parents 28a0851 + f701300 commit 6074760

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

Lightbox.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ var Lightbox = React.createClass({
2020
mixins: [TimerMixin],
2121

2222
propTypes: {
23-
activeProps: PropTypes.object,
24-
renderHeader: PropTypes.func,
25-
renderContent: PropTypes.func,
26-
underlayColor: PropTypes.string,
27-
onOpen: PropTypes.func,
28-
onClose: PropTypes.func,
29-
springConfig: PropTypes.shape({
30-
tension: PropTypes.number,
31-
friction: PropTypes.number,
23+
activeProps: PropTypes.object,
24+
renderHeader: PropTypes.func,
25+
renderContent: PropTypes.func,
26+
underlayColor: PropTypes.string,
27+
backgroundColor: PropTypes.string,
28+
onOpen: PropTypes.func,
29+
onClose: PropTypes.func,
30+
springConfig: PropTypes.shape({
31+
tension: PropTypes.number,
32+
friction: PropTypes.number,
3233
}),
33-
swipeToDismiss: PropTypes.bool,
34+
swipeToDismiss: PropTypes.bool,
3435
},
3536

3637
getDefaultProps: function() {
@@ -73,6 +74,7 @@ var Lightbox = React.createClass({
7374
renderHeader: this.props.renderHeader,
7475
swipeToDismiss: this.props.swipeToDismiss,
7576
springConfig: this.props.springConfig,
77+
backgroundColor: this.props.backgroundColor,
7678
children: this.getContent(),
7779
onClose: this.onClose,
7880
};

LightboxOverlay.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ var LightboxOverlay = React.createClass({
3535
tension: PropTypes.number,
3636
friction: PropTypes.number,
3737
}),
38-
isOpen: PropTypes.bool,
39-
renderHeader: PropTypes.func,
40-
onOpen: PropTypes.func,
41-
onClose: PropTypes.func,
42-
swipeToDismiss: PropTypes.bool,
38+
backgroundColor: PropTypes.string,
39+
isOpen: PropTypes.bool,
40+
renderHeader: PropTypes.func,
41+
onOpen: PropTypes.func,
42+
onClose: PropTypes.func,
43+
swipeToDismiss: PropTypes.bool,
4344
},
4445

4546
getInitialState: function() {
@@ -59,6 +60,7 @@ var LightboxOverlay = React.createClass({
5960
getDefaultProps: function() {
6061
return {
6162
springConfig: { tension: 30, friction: 7 },
63+
backgroundColor: 'black',
6264
};
6365
},
6466

@@ -152,6 +154,7 @@ var LightboxOverlay = React.createClass({
152154
renderHeader,
153155
swipeToDismiss,
154156
origin,
157+
backgroundColor,
155158
} = this.props;
156159

157160
var {
@@ -186,7 +189,7 @@ var LightboxOverlay = React.createClass({
186189
height: openVal.interpolate({inputRange: [0, 1], outputRange: [origin.height, WINDOW_HEIGHT]}),
187190
}];
188191

189-
var background = (<Animated.View style={[styles.background, lightboxOpacityStyle]}></Animated.View>);
192+
var background = (<Animated.View style={[styles.background, { backgroundColor: backgroundColor }, lightboxOpacityStyle]}></Animated.View>);
190193
var header = (<Animated.View style={[styles.header, lightboxOpacityStyle]}>{(renderHeader ?
191194
renderHeader(this.close) :
192195
(
@@ -226,7 +229,6 @@ var styles = StyleSheet.create({
226229
left: 0,
227230
width: WINDOW_WIDTH,
228231
height: WINDOW_HEIGHT,
229-
backgroundColor: 'black',
230232
},
231233
open: {
232234
position: 'absolute',

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var MyApp = React.createClass({
6868
|**`onClose`**|`function`|Triggered when lightbox is closed|
6969
|**`onOpen`**|`function`|Triggered when lightbox is opened|
7070
|**`underlayColor`**|`string`|Color of touchable background, defaults to `black`|
71+
|**`backgroundColor`**|`string`|Color of lightbox background, defaults to `black`|
7172
|**`swipeToDismiss`**|`bool`|Enables gestures to dismiss the fullscreen mode by swiping up or down, defaults to `true`.|
7273
|**`springConfig`**|`object`|[`Animated.spring`](https://facebook.github.io/react-native/docs/animations.html) configuration, defaults to `{ tension: 30, friction: 7 }`.|
7374

0 commit comments

Comments
 (0)