Skip to content

Commit

Permalink
0.5.19
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Jul 19, 2018
1 parent 86cfcd9 commit c6d9c2b
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 286 deletions.
3 changes: 3 additions & 0 deletions .github/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# React-Images

### v0.5.19 / 2018-07-19
- Fix babel lib output not transpiling

### v0.5.18 / 2018-07-19
- LightBox srcSet support for string and array #236 thanks to [lordoffreaks](https://github.com/lordoffreaks)
- Upgrade react-transition-group to v2 #238 thanks to [filipecosta01](https://github.com/filipecosta01)
Expand Down
2 changes: 1 addition & 1 deletion dist/react-images.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ var possibleConstructorReturn = function (self, call) {
function deepMerge(target) {
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var extended = _extends({}, target);
var extended = Object.assign({}, target);

Object.keys(source).forEach(function (key) {
if (_typeof(source[key]) !== 'object' || !source[key]) {
Expand Down
2 changes: 1 addition & 1 deletion dist/react-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ var possibleConstructorReturn = function (self, call) {
function deepMerge(target) {
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var extended = _extends({}, target);
var extended = Object.assign({}, target);

Object.keys(source).forEach(function (key) {
if (_typeof(source[key]) !== 'object' || !source[key]) {
Expand Down
2 changes: 1 addition & 1 deletion dist/react-images.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/src/standalone.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-transition-group/2.0.0/react-transition-group.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-photo-gallery.min.js"></script>
<script src="https://rawgit.com/neptunian/react-scrolllock/master/dist/react-scrolllock.min.js"></script>
<script src="https://unpkg.com/[email protected].18/dist/react-images.min.js"></script>
<script src="https://unpkg.com/[email protected].19/dist/react-images.min.js"></script>
<script type="text/babel">
const photos = [
{src: 'https://images.unsplash.com/photo-1470619549108-b85c56fe5be8?w=1024&h=1024', width:1, height:1},
Expand Down
200 changes: 124 additions & 76 deletions lib/Lightbox.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,76 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _propTypes = require('prop-types');

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _propTypes2 = _interopRequireDefault(_propTypes);

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _aphrodite = require('aphrodite');

var _reactScrolllock = require('react-scrolllock');

var _reactScrolllock2 = _interopRequireDefault(_reactScrolllock);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

var _Arrow = require('./components/Arrow');

var _Arrow2 = _interopRequireDefault(_Arrow);

var _Container = require('./components/Container');

var _Container2 = _interopRequireDefault(_Container);

var _Footer = require('./components/Footer');

var _Footer2 = _interopRequireDefault(_Footer);

var _Header = require('./components/Header');

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { css, StyleSheet } from 'aphrodite';
import ScrollLock from 'react-scrolllock';
var _Header2 = _interopRequireDefault(_Header);

import defaultTheme from './theme';
import Arrow from './components/Arrow';
import Container from './components/Container';
import Footer from './components/Footer';
import Header from './components/Header';
import PaginatedThumbnails from './components/PaginatedThumbnails';
import Portal from './components/Portal';
import DefaultSpinner from './components/Spinner';
var _PaginatedThumbnails = require('./components/PaginatedThumbnails');

import bindFunctions from './utils/bindFunctions';
import canUseDom from './utils/canUseDom';
import deepMerge from './utils/deepMerge';
var _PaginatedThumbnails2 = _interopRequireDefault(_PaginatedThumbnails);

var _Portal = require('./components/Portal');

var _Portal2 = _interopRequireDefault(_Portal);

var _Spinner = require('./components/Spinner');

var _Spinner2 = _interopRequireDefault(_Spinner);

var _bindFunctions = require('./utils/bindFunctions');

var _bindFunctions2 = _interopRequireDefault(_bindFunctions);

var _canUseDom = require('./utils/canUseDom');

var _canUseDom2 = _interopRequireDefault(_canUseDom);

var _deepMerge = require('./utils/deepMerge');

var _deepMerge2 = _interopRequireDefault(_deepMerge);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

// consumers sometimes provide incorrect type or casing
function normalizeSourceSet(data) {
Expand All @@ -43,11 +91,11 @@ var Lightbox = function (_Component) {

var _this = _possibleConstructorReturn(this, (Lightbox.__proto__ || Object.getPrototypeOf(Lightbox)).call(this, props));

_this.theme = deepMerge(defaultTheme, props.theme);
_this.classes = StyleSheet.create(deepMerge(defaultStyles, _this.theme));
_this.theme = (0, _deepMerge2.default)(_theme2.default, props.theme);
_this.classes = _aphrodite.StyleSheet.create((0, _deepMerge2.default)(defaultStyles, _this.theme));
_this.state = { imageLoaded: false };

bindFunctions.call(_this, ['gotoNext', 'gotoPrev', 'closeBackdrop', 'handleKeyboardInput', 'handleImageLoaded']);
_bindFunctions2.default.call(_this, ['gotoNext', 'gotoPrev', 'closeBackdrop', 'handleKeyboardInput', 'handleImageLoaded']);
return _this;
}

Expand All @@ -73,7 +121,7 @@ var Lightbox = function (_Component) {
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (!canUseDom) return;
if (!_canUseDom2.default) return;

// preload images
if (nextProps.preloadNextImage) {
Expand Down Expand Up @@ -221,7 +269,7 @@ var Lightbox = function (_Component) {
value: function renderArrowPrev() {
if (this.props.currentImage === 0) return null;

return React.createElement(Arrow, {
return _react2.default.createElement(_Arrow2.default, {
direction: 'left',
icon: 'arrowLeft',
onClick: this.gotoPrev,
Expand All @@ -234,7 +282,7 @@ var Lightbox = function (_Component) {
value: function renderArrowNext() {
if (this.props.currentImage === this.props.images.length - 1) return null;

return React.createElement(Arrow, {
return _react2.default.createElement(_Arrow2.default, {
direction: 'right',
icon: 'arrowRight',
onClick: this.gotoNext,
Expand All @@ -253,26 +301,26 @@ var Lightbox = function (_Component) {
var imageLoaded = this.state.imageLoaded;


if (!isOpen) return React.createElement('span', { key: 'closed' });
if (!isOpen) return _react2.default.createElement('span', { key: 'closed' });

var offsetThumbnails = 0;
if (showThumbnails) {
offsetThumbnails = this.theme.thumbnail.size + this.theme.container.gutter.vertical;
}

return React.createElement(
Container,
return _react2.default.createElement(
_Container2.default,
{
key: 'open',
onClick: backdropClosesModal && this.closeBackdrop,
onTouchEnd: backdropClosesModal && this.closeBackdrop
},
React.createElement(
_react2.default.createElement(
'div',
null,
React.createElement(
_react2.default.createElement(
'div',
{ className: css(this.classes.content), style: { marginBottom: offsetThumbnails, maxWidth: width } },
{ className: (0, _aphrodite.css)(this.classes.content), style: { marginBottom: offsetThumbnails, maxWidth: width } },
imageLoaded && this.renderHeader(),
this.renderImages(),
this.renderSpinner(),
Expand All @@ -281,7 +329,7 @@ var Lightbox = function (_Component) {
imageLoaded && this.renderThumbnails(),
imageLoaded && this.renderArrowPrev(),
imageLoaded && this.renderArrowNext(),
this.props.preventScroll && React.createElement(ScrollLock, null)
this.props.preventScroll && _react2.default.createElement(_reactScrolllock2.default, null)
)
);
}
Expand All @@ -305,11 +353,11 @@ var Lightbox = function (_Component) {
var thumbnailsSize = showThumbnails ? this.theme.thumbnail.size : 0;
var heightOffset = this.theme.header.height + this.theme.footer.height + thumbnailsSize + this.theme.container.gutter.vertical + 'px';

return React.createElement(
return _react2.default.createElement(
'figure',
{ className: css(this.classes.figure) },
React.createElement('img', {
className: css(this.classes.image, imageLoaded && this.classes.imageLoaded),
{ className: (0, _aphrodite.css)(this.classes.figure) },
_react2.default.createElement('img', {
className: (0, _aphrodite.css)(this.classes.image, imageLoaded && this.classes.imageLoaded),
onClick: onClickImage,
sizes: sizes,
alt: image.alt,
Expand All @@ -335,7 +383,7 @@ var Lightbox = function (_Component) {

if (!showThumbnails) return;

return React.createElement(PaginatedThumbnails, {
return _react2.default.createElement(_PaginatedThumbnails2.default, {
currentImage: currentImage,
images: images,
offset: thumbnailOffset,
Expand All @@ -352,7 +400,7 @@ var Lightbox = function (_Component) {
showCloseButton = _props5.showCloseButton;


return React.createElement(Header, {
return _react2.default.createElement(_Header2.default, {
customControls: customControls,
onClose: onClose,
showCloseButton: showCloseButton,
Expand All @@ -371,7 +419,7 @@ var Lightbox = function (_Component) {

if (!images || !images.length) return null;

return React.createElement(Footer, {
return _react2.default.createElement(_Footer2.default, {
caption: images[currentImage].caption,
countCurrent: currentImage + 1,
countSeparator: imageCountSeparator,
Expand All @@ -390,10 +438,10 @@ var Lightbox = function (_Component) {

var Spinner = spinner;

return React.createElement(
return _react2.default.createElement(
'div',
{ className: css(this.classes.spinner, !imageLoaded && this.classes.spinnerActive) },
React.createElement(Spinner, {
{ className: (0, _aphrodite.css)(this.classes.spinner, !imageLoaded && this.classes.spinnerActive) },
_react2.default.createElement(Spinner, {
color: spinnerColor,
size: spinnerSize
})
Expand All @@ -402,48 +450,48 @@ var Lightbox = function (_Component) {
}, {
key: 'render',
value: function render() {
return React.createElement(
Portal,
return _react2.default.createElement(
_Portal2.default,
null,
this.renderDialog()
);
}
}]);

return Lightbox;
}(Component);
}(_react.Component);

Lightbox.propTypes = {
backdropClosesModal: PropTypes.bool,
closeButtonTitle: PropTypes.string,
currentImage: PropTypes.number,
customControls: PropTypes.arrayOf(PropTypes.node),
enableKeyboardInput: PropTypes.bool,
imageCountSeparator: PropTypes.string,
images: PropTypes.arrayOf(PropTypes.shape({
src: PropTypes.string.isRequired,
srcSet: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
caption: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
thumbnail: PropTypes.string
backdropClosesModal: _propTypes2.default.bool,
closeButtonTitle: _propTypes2.default.string,
currentImage: _propTypes2.default.number,
customControls: _propTypes2.default.arrayOf(_propTypes2.default.node),
enableKeyboardInput: _propTypes2.default.bool,
imageCountSeparator: _propTypes2.default.string,
images: _propTypes2.default.arrayOf(_propTypes2.default.shape({
src: _propTypes2.default.string.isRequired,
srcSet: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]),
caption: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
thumbnail: _propTypes2.default.string
})).isRequired,
isOpen: PropTypes.bool,
leftArrowTitle: PropTypes.string,
onClickImage: PropTypes.func,
onClickNext: PropTypes.func,
onClickPrev: PropTypes.func,
onClose: PropTypes.func.isRequired,
preloadNextImage: PropTypes.bool,
preventScroll: PropTypes.bool,
rightArrowTitle: PropTypes.string,
showCloseButton: PropTypes.bool,
showImageCount: PropTypes.bool,
showThumbnails: PropTypes.bool,
spinner: PropTypes.func,
spinnerColor: PropTypes.string,
spinnerSize: PropTypes.number,
theme: PropTypes.object,
thumbnailOffset: PropTypes.number,
width: PropTypes.number
isOpen: _propTypes2.default.bool,
leftArrowTitle: _propTypes2.default.string,
onClickImage: _propTypes2.default.func,
onClickNext: _propTypes2.default.func,
onClickPrev: _propTypes2.default.func,
onClose: _propTypes2.default.func.isRequired,
preloadNextImage: _propTypes2.default.bool,
preventScroll: _propTypes2.default.bool,
rightArrowTitle: _propTypes2.default.string,
showCloseButton: _propTypes2.default.bool,
showImageCount: _propTypes2.default.bool,
showThumbnails: _propTypes2.default.bool,
spinner: _propTypes2.default.func,
spinnerColor: _propTypes2.default.string,
spinnerSize: _propTypes2.default.number,
theme: _propTypes2.default.object,
thumbnailOffset: _propTypes2.default.number,
width: _propTypes2.default.number
};
Lightbox.defaultProps = {
closeButtonTitle: 'Close (Esc)',
Expand All @@ -457,15 +505,15 @@ Lightbox.defaultProps = {
rightArrowTitle: 'Next (Right arrow key)',
showCloseButton: true,
showImageCount: true,
spinner: DefaultSpinner,
spinner: _Spinner2.default,
spinnerColor: 'white',
spinnerSize: 100,
theme: {},
thumbnailOffset: 2,
width: 1024
};
Lightbox.childContextTypes = {
theme: PropTypes.object.isRequired
theme: _propTypes2.default.object.isRequired
};

var defaultStyles = {
Expand Down Expand Up @@ -508,4 +556,4 @@ var defaultStyles = {
}
};

export default Lightbox;
exports.default = Lightbox;
Loading

0 comments on commit c6d9c2b

Please sign in to comment.