Skip to content

Switch to using the prop-types package #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"transform-flow-comments"
],
"presets": [
"react-app"
"es2015",
"react"
]
}
30 changes: 22 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{
"extends": "react-app",
"rules": {
// Possible Errors
"comma-dangle": ["error", "always-multiline"],
// Stylistic Issues
"jsx-quotes": ["error", "prefer-double"],
"quotes": ["error", "backtick"]
}
parser: "babel-eslint",
extends: [
"airbnb",
"plugin:flowtype/recommended",
],
plugins: [
"react",
"flowtype",
],
rules: {
linebreak-style: "off",
react/jsx-filename-extension: [1, { "extensions": [".js", ".jsx"] }],
import/no-unresolved: [2, { caseSensitive: false }],
react/no-find-dom-node: "off",
},
env: {
browser: true,
jasmine: true,
jest: true,
mocha: true,
node: true,
},
}
6 changes: 3 additions & 3 deletions docs/static/js/main.f1f5a6d7.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/static/js/main.f1f5a6d7.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ var ToastContainer = function (_Component) {
_createClass(ToastContainer, [{
key: "error",
value: function error(message, title, optionsOverride) {
this._notify(this.props.toastType.error, message, title, optionsOverride);
this.notify(this.props.toastType.error, message, title, optionsOverride);
}
}, {
key: "info",
value: function info(message, title, optionsOverride) {
this._notify(this.props.toastType.info, message, title, optionsOverride);
this.notify(this.props.toastType.info, message, title, optionsOverride);
}
}, {
key: "success",
value: function success(message, title, optionsOverride) {
this._notify(this.props.toastType.success, message, title, optionsOverride);
this.notify(this.props.toastType.success, message, title, optionsOverride);
}
}, {
key: "warning",
value: function warning(message, title, optionsOverride) {
this._notify(this.props.toastType.warning, message, title, optionsOverride);
this.notify(this.props.toastType.warning, message, title, optionsOverride);
}
}, {
key: "clear",
Expand All @@ -89,8 +89,8 @@ var ToastContainer = function (_Component) {
});
}
}, {
key: "_notify",
value: function _notify(type, message, title) {
key: "notify",
value: function notify(type, message, title) {
var _this3 = this;

var optionsOverride = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
Expand Down
66 changes: 33 additions & 33 deletions lib/ToastMessage/animationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@ exports.default = {
componentDidMount: function componentDidMount() {
var _this = this;

this._is_mounted = true;
this._show();
this.isMounted = true;
this.show();
var node = _reactDom2.default.findDOMNode(this);

var onHideComplete = function onHideComplete() {
if (_this.isHiding) {
_this._set_is_hiding(false);
_this.setIsHiding(false);
_ReactTransitionEvents2.default.removeEndEventListener(node, onHideComplete);
_this._handle_remove();
_this.handleRemove();
}
};
_ReactTransitionEvents2.default.addEndEventListener(node, onHideComplete);

if (this.props.timeOut > 0) {
this._set_interval_id(setTimeout(this.hideToast, this.props.timeOut));
this.setIntervalId(setTimeout(this.hideToast, this.props.timeOut));
}
},
componentWillUnmount: function componentWillUnmount() {
this._is_mounted = false;
this.isMounted = false;
if (this.intervalId) {
clearTimeout(this.intervalId);
}
},
_set_transition: function _set_transition(hide) {
setTransition: function setTransition(hide) {
var animationType = hide ? "leave" : "enter";
var node = _reactDom2.default.findDOMNode(this);
var className = this.props.transition + "-" + animationType;
Expand All @@ -84,9 +84,9 @@ exports.default = {
(0, _elementClass2.default)(node).add(className);

// Need to do this to actually trigger a transition.
this._queue_class(activeClassName);
this.queueClass(activeClassName);
},
_clear_transition: function _clear_transition(hide) {
clearTransition: function clearTransition(hide) {
var node = _reactDom2.default.findDOMNode(this);
var animationType = hide ? "leave" : "enter";
var className = this.props.transition + "-" + animationType;
Expand All @@ -96,9 +96,9 @@ exports.default = {
classList.remove(className);
classList.remove(activeClassName);
},
_set_animation: function _set_animation(hide) {
setAnimation: function setAnimation(hide) {
var node = _reactDom2.default.findDOMNode(this);
var animations = this._get_animation_classes(hide);
var animations = this.getAnimationClasses(hide);
var endListener = function endListener(e) {
if (e && e.target !== node) {
return;
Expand All @@ -117,32 +117,32 @@ exports.default = {
return (0, _elementClass2.default)(node).add(anim);
});
},
_get_animation_classes: function _get_animation_classes(hide) {
getAnimationClasses: function getAnimationClasses(hide) {
var animations = hide ? this.props.hideAnimation : this.props.showAnimation;
if ("[object Array]" === toString.call(animations)) {
return animations;
} else if ("string" === typeof animations) {
return animations.split(" ");
}
},
_clear_animation: function _clear_animation(hide) {
clearAnimation: function clearAnimation(hide) {
var node = _reactDom2.default.findDOMNode(this);
var animations = this._get_animation_classes(hide);
var animations = this.getAnimationClasses(hide);
animations.forEach(function (animation) {
return (0, _elementClass2.default)(node).remove(animation);
});
},
_queue_class: function _queue_class(className) {
queueClass: function queueClass(className) {
this.classNameQueue.push(className);

if (!this.timeout) {
this.timeout = setTimeout(this._flush_class_name_queue, TICK);
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
}
},
_flush_class_name_queue: function _flush_class_name_queue() {
flushClassNameQueue: function flushClassNameQueue() {
var _this2 = this;

if (this._is_mounted) {
if (this.isMounted) {
(function () {
var node = _reactDom2.default.findDOMNode(_this2);
_this2.classNameQueue.forEach(function (className) {
Expand All @@ -153,49 +153,49 @@ exports.default = {
this.classNameQueue.length = 0;
this.timeout = null;
},
_show: function _show() {
show: function show() {
if (this.props.transition) {
this._set_transition();
this.setTransition();
} else if (this.props.showAnimation) {
this._set_animation();
this.setAnimation();
}
},
handleMouseEnter: function handleMouseEnter() {
clearTimeout(this.intervalId);
this._set_interval_id(null);
this.setIntervalId(null);
if (this.isHiding) {
this._set_is_hiding(false);
this.setIsHiding(false);

if (this.props.hideAnimation) {
this._clear_animation(true);
this.clearAnimation(true);
} else if (this.props.transition) {
this._clear_transition(true);
this.clearTransition(true);
}
}
},
handleMouseLeave: function handleMouseLeave() {
if (!this.isHiding && (this.props.timeOut > 0 || this.props.extendedTimeOut > 0)) {
this._set_interval_id(setTimeout(this.hideToast, this.props.extendedTimeOut));
this.setIntervalId(setTimeout(this.hideToast, this.props.extendedTimeOut));
}
},
hideToast: function hideToast(override) {
if (this.isHiding || this.intervalId === null && !override) {
return;
}

this._set_is_hiding(true);
this.setIsHiding(true);
if (this.props.transition) {
this._set_transition(true);
this.setTransition(true);
} else if (this.props.hideAnimation) {
this._set_animation(true);
this.setAnimation(true);
} else {
this._handle_remove();
this.handleRemove();
}
},
_set_interval_id: function _set_interval_id(intervalId) {
setIntervalId: function setIntervalId(intervalId) {
this.intervalId = intervalId;
},
_set_is_hiding: function _set_is_hiding(isHiding) {
setIsHiding: function setIsHiding(isHiding) {
this.isHiding = isHiding;
}
};
};
2 changes: 1 addition & 1 deletion lib/ToastMessage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var ToastMessageSpec = {
event.stopPropagation();
this.hideToast(true);
},
_handle_remove: function _handle_remove() {
handleRemove: function handleRemove() {
this.props.handleRemove(this.props.toastId);
},
_render_close_button: function _render_close_button() {
Expand Down
22 changes: 11 additions & 11 deletions lib/ToastMessage/jQueryMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _reactDom2 = _interopRequireDefault(_reactDom);

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

function call_show_method($node, props) {
function callShowMethod($node, props) {
$node[props.showMethod]({
duration: props.showDuration,
easing: props.showEasing
Expand Down Expand Up @@ -40,21 +40,21 @@ exports.default = {
};
},
componentDidMount: function componentDidMount() {
call_show_method(this._get_$_node(), this.props);
callShowMethod(this._get_$_node(), this.props);
if (this.props.timeOut > 0) {
this._set_interval_id(setTimeout(this.hideToast, this.props.timeOut));
this.setIntervalId(setTimeout(this.hideToast, this.props.timeOut));
}
},
handleMouseEnter: function handleMouseEnter() {
clearTimeout(this.state.intervalId);
this._set_interval_id(null);
this._set_is_hiding(false);
this.setIntervalId(null);
this.setIsHiding(false);

call_show_method(this._get_$_node().stop(true, true), this.props);
callShowMethod(this._get_$_node().stop(true, true), this.props);
},
handleMouseLeave: function handleMouseLeave() {
if (!this.state.isHiding && (this.props.timeOut > 0 || this.props.extendedTimeOut > 0)) {
this._set_interval_id(setTimeout(this.hideToast, this.props.extendedTimeOut));
this.setIntervalId(setTimeout(this.hideToast, this.props.extendedTimeOut));
}
},
hideToast: function hideToast(override) {
Expand All @@ -66,22 +66,22 @@ exports.default = {
this._get_$_node()[this.props.hideMethod]({
duration: this.props.hideDuration,
easing: this.props.hideEasing,
complete: this._handle_remove
complete: this.handleRemove
});
},
_get_$_node: function _get_$_node() {
/* eslint-disable no-undef */
return jQuery(_reactDom2.default.findDOMNode(this));
/* eslint-enable no-undef */
},
_set_interval_id: function _set_interval_id(intervalId) {
setIntervalId: function setIntervalId(intervalId) {
this.setState({
intervalId: intervalId
});
},
_set_is_hiding: function _set_is_hiding(isHiding) {
setIsHiding: function setIsHiding(isHiding) {
this.setState({
isHiding: isHiding
});
}
};
};
64 changes: 33 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,43 @@
},
"homepage": "https://tomchentw.github.io/react-toastr/",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "6.1.2",
"babel-plugin-lodash": "^3.2.9",
"babel-plugin-transform-flow-comments": "^6.8.0",
"babel-plugin-typecheck": "^3.9.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-app": "^0.2.1",
"babel-preset-stage-0": "^6.5.0",
"codeclimate-test-reporter": "^0.3.3",
"cross-env": "^3.1.1",
"eslint": "3.5.0",
"eslint-config-react-app": "0.2.1",
"eslint-plugin-flowtype": "2.18.1",
"eslint-plugin-import": "1.12.0",
"eslint-plugin-jsx-a11y": "2.2.2",
"eslint-plugin-react": "6.3.0",
"jquery": "^3.1.0",
"prismjs": "^1.5.1",
"raw-loader": "^0.5.1",
"react": "^15.3.2",
"react-addons-test-utils": "^15.3.2",
"react-github-fork-ribbon": "^0.4.4",
"react-scripts": "0.6.1",
"rimraf": "^2.5.4",
"standard-version": "^2.4.0"
"babel-cli": "6.24.1",
"babel-core": "6.24.1",
"babel-eslint": "7.2.3",
"babel-plugin-lodash": "3.2.11",
"babel-plugin-transform-flow-comments": "6.22.0",
"babel-plugin-typecheck": "3.9.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"babel-preset-react-app": "2.2.0",
"babel-preset-stage-0": "6.24.1",
"codeclimate-test-reporter": "0.4.1",
"cross-env": "4.0.0",
"eslint": "3.19.0",
"eslint-config-airbnb": "14.1.0",
"eslint-plugin-flowtype": "2.32.1",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.10.3",
"jquery": "3.2.1",
"prismjs": "1.6.0",
"raw-loader": "0.5.1",
"react": "15.5.4",
"react-dom": "15.5.4",
"react-github-fork-ribbon": "0.5.0",
"react-scripts": "0.9.5",
"rimraf": "2.6.1",
"standard-version": "4.0.0"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0"
"react": "^0.14.0 || ^15.0.0",
"react-dom": "^0.14.0 || ^15.0.0"
},
"dependencies": {
"classnames": "^2.2.5",
"element-class": "^0.2.2",
"lodash": "^4.16.1",
"classnames": "2.2.5",
"element-class": "0.2.2",
"lodash": "4.17.4",
"prop-types": "15.5.8",
"react-addons-update": "^0.14.0 || ^15.0.0",
"react-dom": "^0.14.0 || ^15.0.0"
}
Expand Down
Loading