Skip to content
This repository was archived by the owner on Jan 19, 2023. It is now read-only.

Commit a94cd13

Browse files
authored
Merge pull request #8 from fritz-c/flexible-toolbar-2
Flexible toolbar
2 parents 2a58044 + 6362eb7 commit a94cd13

File tree

8 files changed

+169
-22
lines changed

8 files changed

+169
-22
lines changed

dist/react-image-lightbox.js

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ module.exports = _radium2['default'].call(undefined, ReactImageLightbox);
11471147
'use strict';
11481148

11491149
var Radium = (typeof window !== "undefined" ? window['Radium'] : typeof global !== "undefined" ? global['Radium'] : null);
1150+
var Util = require('./Util');
11501151
var toolbarHeight = '50px';
11511152

11521153
var closeWindowKeyframes = Radium.keyframes({
@@ -1266,25 +1267,25 @@ var styles = {
12661267
left: 0,
12671268
top: 0,
12681269
right: 0,
1269-
height: toolbarHeight
1270+
height: toolbarHeight,
1271+
display: 'flex',
1272+
justifyContent: 'space-between'
12701273
},
12711274
toolbarSide: {
1272-
lineHeight: toolbarHeight,
1273-
position: 'absolute',
1274-
top: 0,
1275-
bottom: 0,
1276-
margin: 0,
1277-
maxWidth: '48%'
1275+
height: toolbarHeight,
1276+
margin: 0
12781277
},
12791278
toolbarLeftSide: {
12801279
paddingLeft: '20px',
12811280
paddingRight: 0,
1282-
left: 0
1281+
flex: '0 1 auto',
1282+
overflow: 'hidden',
1283+
textOverflow: 'ellipsis'
12831284
},
12841285
toolbarRightSide: {
12851286
paddingLeft: 0,
12861287
paddingRight: '20px',
1287-
right: 0
1288+
flex: '0 0 auto'
12881289
},
12891290
toolbarItem: {
12901291
display: 'inline-block',
@@ -1340,8 +1341,58 @@ var styles = {
13401341
}
13411342
};
13421343

1344+
// Use fallback styles for IE users
1345+
if (Util.isIE()) {
1346+
styles.toolbar = {
1347+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
1348+
position: 'absolute',
1349+
left: 0,
1350+
top: 0,
1351+
right: 0,
1352+
height: toolbarHeight
1353+
};
1354+
1355+
styles.toolbarSide = {
1356+
lineHeight: toolbarHeight,
1357+
position: 'absolute',
1358+
top: 0,
1359+
bottom: 0,
1360+
margin: 0,
1361+
maxWidth: '48%'
1362+
};
1363+
1364+
styles.toolbarLeftSide = {
1365+
paddingLeft: '20px',
1366+
paddingRight: 0,
1367+
left: 0
1368+
};
1369+
1370+
styles.toolbarRightSide = {
1371+
paddingLeft: 0,
1372+
paddingRight: '20px',
1373+
right: 0
1374+
};
1375+
}
1376+
13431377
module.exports = styles;
13441378

13451379
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1380+
},{"./Util":5}],5:[function(require,module,exports){
1381+
/**
1382+
* Checks if the user is using Internet Explorer
1383+
*
1384+
* @return {boolean} isIE - True if the user is on IE
1385+
*/
1386+
'use strict';
1387+
1388+
function isIE() {
1389+
var ua = window.navigator.userAgent;
1390+
return ua.indexOf('MSIE ') > -1 || ua.indexOf('Trident/') > -1;
1391+
}
1392+
1393+
module.exports = {
1394+
isIE: isIE
1395+
};
1396+
13461397
},{}]},{},[3])(3)
13471398
});

dist/react-image-lightbox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Util.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Checks if the user is using Internet Explorer
3+
*
4+
* @return {boolean} isIE - True if the user is on IE
5+
*/
6+
'use strict';
7+
8+
function isIE() {
9+
var ua = window.navigator.userAgent;
10+
return ua.indexOf('MSIE ') > -1 || ua.indexOf('Trident/') > -1;
11+
}
12+
13+
module.exports = {
14+
isIE: isIE
15+
};

lib/styles.js

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var Radium = require('radium');
4+
var Util = require('./Util');
45
var toolbarHeight = '50px';
56

67
var closeWindowKeyframes = Radium.keyframes({
@@ -120,25 +121,25 @@ var styles = {
120121
left: 0,
121122
top: 0,
122123
right: 0,
123-
height: toolbarHeight
124+
height: toolbarHeight,
125+
display: 'flex',
126+
justifyContent: 'space-between'
124127
},
125128
toolbarSide: {
126-
lineHeight: toolbarHeight,
127-
position: 'absolute',
128-
top: 0,
129-
bottom: 0,
130-
margin: 0,
131-
maxWidth: '48%'
129+
height: toolbarHeight,
130+
margin: 0
132131
},
133132
toolbarLeftSide: {
134133
paddingLeft: '20px',
135134
paddingRight: 0,
136-
left: 0
135+
flex: '0 1 auto',
136+
overflow: 'hidden',
137+
textOverflow: 'ellipsis'
137138
},
138139
toolbarRightSide: {
139140
paddingLeft: 0,
140141
paddingRight: '20px',
141-
right: 0
142+
flex: '0 0 auto'
142143
},
143144
toolbarItem: {
144145
display: 'inline-block',
@@ -194,4 +195,37 @@ var styles = {
194195
}
195196
};
196197

198+
// Use fallback styles for IE users
199+
if (Util.isIE()) {
200+
styles.toolbar = {
201+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
202+
position: 'absolute',
203+
left: 0,
204+
top: 0,
205+
right: 0,
206+
height: toolbarHeight
207+
};
208+
209+
styles.toolbarSide = {
210+
lineHeight: toolbarHeight,
211+
position: 'absolute',
212+
top: 0,
213+
bottom: 0,
214+
margin: 0,
215+
maxWidth: '48%'
216+
};
217+
218+
styles.toolbarLeftSide = {
219+
paddingLeft: '20px',
220+
paddingRight: 0,
221+
left: 0
222+
};
223+
224+
styles.toolbarRightSide = {
225+
paddingLeft: 0,
226+
paddingRight: '20px',
227+
right: 0
228+
};
229+
}
230+
197231
module.exports = styles;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-image-lightbox",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "A lightbox component for React.js",
55
"scripts": {
66
"start": "node_modules/.bin/gulp dev"
@@ -40,4 +40,4 @@
4040
"react-dom": "global:ReactDOM",
4141
"radium": "global:Radium"
4242
}
43-
}
43+
}

src/ReactImageLightbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* react-image-lightbox 2.0.0
2+
* react-image-lightbox 2.2.0
33
* Copyright 2016 Chris Fritz All rights reserved.
44
* @license Open source under the MIT License
55
*/

src/Styles.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Radium = require('radium');
2+
const Util = require('./Util');
23
const toolbarHeight = '50px';
34

45
const closeWindowKeyframes = Radium.keyframes({
@@ -198,4 +199,37 @@ const styles = {
198199
},
199200
};
200201

202+
// Use fallback styles for browsers without flexbox support
203+
if (Util.getIEVersion() < 10) {
204+
styles.toolbar = {
205+
backgroundColor : 'rgba(0, 0, 0, 0.5)',
206+
position : 'absolute',
207+
left : 0,
208+
top : 0,
209+
right : 0,
210+
height : toolbarHeight,
211+
};
212+
213+
styles.toolbarSide = {
214+
lineHeight : toolbarHeight,
215+
position : 'absolute',
216+
top : 0,
217+
bottom : 0,
218+
margin : 0,
219+
maxWidth : '48%',
220+
};
221+
222+
styles.toolbarLeftSide = {
223+
paddingLeft : '20px',
224+
paddingRight : 0,
225+
left : 0,
226+
};
227+
228+
styles.toolbarRightSide = {
229+
paddingLeft : 0,
230+
paddingRight : '20px',
231+
right : 0,
232+
};
233+
}
234+
201235
module.exports = styles;

src/Util.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Get the version of Internet Explorer in use, or undefined
3+
*
4+
* @return {?number} ieVersion - IE version as an integer, or undefined if not IE
5+
*/
6+
function getIEVersion() {
7+
var match = navigator.userAgent.match(/(?:MSIE |Trident\/.*; rv:)(\d+)/);
8+
return match ? parseInt(match[1]) : undefined;
9+
}
10+
11+
module.exports = {
12+
getIEVersion: getIEVersion,
13+
};

0 commit comments

Comments
 (0)