Skip to content

Commit d1d0720

Browse files
author
ben
committed
v0.1.12
1 parent 9c4f02c commit d1d0720

File tree

6 files changed

+77
-59
lines changed

6 files changed

+77
-59
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# react-grid-gallery
22

3+
### v0.1.12 / 2016-08-22
4+
5+
* Replaced ReactDOM.findDOMNode(this) with ref, removed react-dom deps
6+
* Added conditional to ensure image onClick not fired when no function specified
7+
* Moved CheckButton styling (color, hoverColor, selectedColor) to props
8+
9+
310
### v0.1.11 / 2016-08-21
411

512
* Fixed react-dom typo

lib/CheckButton.js

+44-40
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
"use strict";
1+
'use strict';
22

33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66

77
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; }; }();
88

9-
var _react = require("react");
9+
var _react = require('react');
1010

1111
var _react2 = _interopRequireDefault(_react);
1212

@@ -36,19 +36,19 @@ var CheckButton = function (_Component) {
3636
}
3737

3838
_createClass(CheckButton, [{
39-
key: "fill",
39+
key: 'fill',
4040
value: function fill() {
41-
if (this.props.isSelected) return "#4285f4";else if (this.state.hover) return "rgba(255, 255, 255, 1)";
42-
return "rgba(255, 255, 255, 0.7)";
41+
if (this.props.isSelected) return this.props.selectedColor;else if (this.state.hover) return this.props.hoverColor;
42+
return this.props.color;
4343
}
4444
}, {
45-
key: "visibility",
45+
key: 'visibility',
4646
value: function visibility() {
4747
if (this.props.isSelected || this.props.isSelectable && this.props.parentHover) return 'visible';
4848
return 'hidden';
4949
}
5050
}, {
51-
key: "render",
51+
key: 'render',
5252
value: function render() {
5353
var _this2 = this;
5454

@@ -57,9 +57,9 @@ var CheckButton = function (_Component) {
5757
};
5858

5959
return _react2.default.createElement(
60-
"div",
60+
'div',
6161
{
62-
title: "Select",
62+
title: 'Select',
6363
style: {
6464
visibility: this.visibility(),
6565
background: 'none',
@@ -80,43 +80,43 @@ var CheckButton = function (_Component) {
8080
return _this2.setState({ hover: false });
8181
} },
8282
_react2.default.createElement(
83-
"svg",
83+
'svg',
8484
{
8585
fill: this.fill(),
86-
height: "24", viewBox: "0 0 24 24",
87-
width: "24",
88-
xmlns: "http://www.w3.org/2000/svg" },
86+
height: '24', viewBox: '0 0 24 24',
87+
width: '24',
88+
xmlns: 'http://www.w3.org/2000/svg' },
8989
_react2.default.createElement(
90-
"radialGradient",
90+
'radialGradient',
9191
{
92-
id: "shadow",
93-
cx: "38",
94-
cy: "95.488",
95-
r: "10.488",
96-
gradientTransform: "matrix(1 0 0 -1 -26 109)",
97-
gradientUnits: "userSpaceOnUse" },
98-
_react2.default.createElement("stop", {
99-
offset: ".832",
100-
stopColor: "#010101" }),
101-
_react2.default.createElement("stop", {
102-
offset: "1",
103-
stopColor: "#010101",
104-
stopOpacity: "0" })
92+
id: 'shadow',
93+
cx: '38',
94+
cy: '95.488',
95+
r: '10.488',
96+
gradientTransform: 'matrix(1 0 0 -1 -26 109)',
97+
gradientUnits: 'userSpaceOnUse' },
98+
_react2.default.createElement('stop', {
99+
offset: '.832',
100+
stopColor: '#010101' }),
101+
_react2.default.createElement('stop', {
102+
offset: '1',
103+
stopColor: '#010101',
104+
stopOpacity: '0' })
105105
),
106-
_react2.default.createElement("circle", {
106+
_react2.default.createElement('circle', {
107107
style: circleStyle,
108-
opacity: ".26",
109-
fill: "url(#shadow)",
110-
cx: "12", cy: "13.512",
111-
r: "10.488" }),
112-
_react2.default.createElement("circle", {
108+
opacity: '.26',
109+
fill: 'url(#shadow)',
110+
cx: '12', cy: '13.512',
111+
r: '10.488' }),
112+
_react2.default.createElement('circle', {
113113
style: circleStyle,
114-
fill: "#FFF",
115-
cx: "12",
116-
cy: "12.2",
117-
r: "8.292" }),
118-
_react2.default.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
119-
_react2.default.createElement("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" })
114+
fill: '#FFF',
115+
cx: '12',
116+
cy: '12.2',
117+
r: '8.292' }),
118+
_react2.default.createElement('path', { d: 'M0 0h24v24H0z', fill: 'none' }),
119+
_react2.default.createElement('path', { d: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z' })
120120
)
121121
);
122122
}
@@ -126,15 +126,19 @@ var CheckButton = function (_Component) {
126126
}(_react.Component);
127127

128128
CheckButton.propTypes = { index: _react.PropTypes.number,
129+
color: _react.PropTypes.string,
129130
isSelectable: _react.PropTypes.bool,
130131
isSelected: _react.PropTypes.bool,
132+
selectedColor: _react.PropTypes.string,
131133
parentHover: _react.PropTypes.bool,
132134
hover: _react.PropTypes.bool,
135+
hoverColor: _react.PropTypes.string,
133136
onClick: _react.PropTypes.func };
134137

135138
CheckButton.defaultProps = { isSelectable: true,
136139
isSelected: false,
137140
parentHover: false,
138141
hover: false };
139142

140-
exports.default = CheckButton;
143+
exports.default = CheckButton;
144+
//module.exports = CheckButton;

lib/Gallery.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ var _react = require('react');
66

77
var _react2 = _interopRequireDefault(_react);
88

9-
var _reactDom = require('react-dom');
10-
11-
var _reactDom2 = _interopRequireDefault(_reactDom);
12-
139
var _reactImages = require('react-images');
1410

1511
var _reactImages2 = _interopRequireDefault(_reactImages);
@@ -25,6 +21,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
2521
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; }
2622

2723
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; }
24+
//import ReactDOM from 'react-dom';
25+
2826

2927
var update = require('react-addons-update');
3028

@@ -69,15 +67,20 @@ var Gallery = function (_Component) {
6967
}, {
7068
key: 'componentDidUpdate',
7169
value: function componentDidUpdate() {
72-
if (_reactDom2.default.findDOMNode(this).clientWidth !== this.state.containerWidth) {
70+
//if (ReactDOM.findDOMNode(this).clientWidth
71+
// !== this.state.containerWidth){
72+
// this.handleResize();
73+
//}
74+
if (this.refs.gallery.clientWidth !== this.state.containerWidth) {
7375
this.handleResize();
7476
}
7577
}
7678
}, {
7779
key: 'handleResize',
7880
value: function handleResize() {
7981
this.setState({
80-
containerWidth: Math.floor(_reactDom2.default.findDOMNode(this).clientWidth)
82+
containerWidth: Math.floor(this.refs.gallery.clientWidth)
83+
//Math.floor(ReactDOM.findDOMNode(this).clientWidth)
8184
});
8285
}
8386
}, {
@@ -134,7 +137,8 @@ var Gallery = function (_Component) {
134137
key: 'getOnClickThumbnailFunc',
135138
value: function getOnClickThumbnailFunc() {
136139
if (!this.props.onClickThumbnail && this.props.enableLightbox) return this.openLightbox;
137-
return this.props.onClickThumbnail;
140+
if (this.props.onClickThumbnail) return this.props.onClickThumbnail;
141+
return null;
138142
}
139143
}, {
140144
key: 'calculateCutOff',
@@ -232,7 +236,7 @@ var Gallery = function (_Component) {
232236
value: function render() {
233237
return _react2.default.createElement(
234238
'div',
235-
{ id: 'Gallery' },
239+
{ id: 'Gallery', ref: 'gallery' },
236240
this.renderGallery(),
237241
_react2.default.createElement(_reactImages2.default, {
238242
images: this.props.images,

lib/Image.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ var Image = function (_Component) {
9292
value: function renderCheckButton() {
9393
return _react2.default.createElement(_CheckButton2.default, { key: 'Select',
9494
index: this.props.index,
95+
color: "rgba(255, 255, 255, 0.7)",
96+
selectedColor: "#4285f4",
97+
hoverColor: "rgba(255, 255, 255, 1)",
9598
isSelected: this.props.isSelected,
9699
isSelectable: this.props.isSelectable,
97100
onClick: this.props.isSelectable ? this.props.onToggleSelected : null,
@@ -145,9 +148,9 @@ var Image = function (_Component) {
145148
{ className: 'tile-viewport',
146149
style: this.tileViewportStyle(),
147150
key: "tile-viewport-" + this.props.index,
148-
onClick: function onClick(e) {
151+
onClick: this.props.onClick ? function (e) {
149152
return _this2.props.onClick(_this2.props.index, e);
150-
} },
153+
} : null },
151154
_react2.default.createElement('img', {
152155
key: "img-" + this.props.index,
153156
src: this.props.item.thumbnail, title: this.props.item.caption,

lib/react-grid-gallery.bundle.min.js

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-grid-gallery",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"description": "Justified gallery component for React.",
55
"main": "lib/Gallery.js",
66
"dependencies": {

0 commit comments

Comments
 (0)