Skip to content

Commit

Permalink
Bump 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kuy committed Apr 13, 2016
1 parent f13256e commit 2017129
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,30 @@ import { reducer as tooltip } from 'redux-tooltip';
// ...
export default combineReducers(
{ your, reducers, ..., tooltip }
{ your, awesome, reducers, ..., tooltip }
);
```

That's it!

#### [Optional] 4. Insert `redux-tooltip` middleware with yours

If you want to use 'delay' feature, please insert `redux-tooltip` middleware to enable the feature.

```
import { middleware as tooltip } from 'redux-tooltip';
// ...
const store = createStore(
reducer,
initialstate,
applyMiddleware(
your, awesome, middlewares, ..., tooltip
)
);
```

## API

### `<Tooltip />`
Expand Down
2 changes: 1 addition & 1 deletion lib/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function tooltip() {
var action = arguments[1];

// Check usage of deprecated props
(0, _utils.deprecatedWarning)(action.payload);
(0, _utils.deprecatedWarning)(action);

var handler = handlers[action.type];
return handler ? handler(state, action) : state;
Expand Down
23 changes: 20 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ var _isDom = require('is-dom');

var _isDom2 = _interopRequireDefault(_isDom);

var _actions = require('./actions');

var actions = _interopRequireWildcard(_actions);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
Expand Down Expand Up @@ -286,11 +292,22 @@ function resolve(obj) {
return names;
}

function deprecatedWarning(props) {
if (props && props.el) {
var actionTypes = Object.keys(actions).map(function (k) {
return actions[k];
}).filter(function (e) {
return typeof e === 'string';
});
function deprecatedWarning(action) {
var type = action.type;
var payload = action.payload;

if (actionTypes.indexOf(action.type) === -1) {
return; // Ignore non-related actions
}
if (payload && payload.el) {
console.warn('DEPRECATED: Use \'origin\' instead of \'el\' in props for Tooltip component or \'show\' action.');
}
if (props && props.el && props.origin) {
if (payload && payload.el && payload.origin) {
console.warn('Do not pass both \'origin\' and \'el\' props at the same time.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-tooltip",
"version": "0.5.3",
"version": "0.5.4",
"description": "A tooltip React component for Redux",
"main": "./lib/index.js",
"repository": {
Expand Down

0 comments on commit 2017129

Please sign in to comment.