react-vk
Advanced tools
Comparing version 1.1.5 to 1.1.6
{ | ||
"name": "react-vk", | ||
"version": "1.1.5", | ||
"private": false, | ||
"version": "1.1.6", | ||
"main": "build/index.js", | ||
@@ -13,4 +14,16 @@ "description": "VK API bindings for React", | ||
"build": "babel src -d build", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run build", | ||
"prettier": "prettier --write", | ||
"precommit": "lint-staged" | ||
}, | ||
"lint-staged": { | ||
"src/*.js": [ | ||
"npm run prettier", | ||
"git add" | ||
], | ||
"*.md": [ | ||
"npm run prettier", | ||
"git add" | ||
] | ||
}, | ||
"repository": { | ||
@@ -26,3 +39,3 @@ "type": "git", | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.4", | ||
"babel-eslint": "^8.2.2", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.13", | ||
@@ -32,4 +45,14 @@ "babel-preset-env": "^1.6.1", | ||
"babel-preset-stage-1": "^6.24.1", | ||
"eslint": "^4.19.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-config-react-app": "^2.1.0", | ||
"eslint-plugin-flowtype": "^2.46.1", | ||
"eslint-plugin-import": "^2.10.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.7.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.0.1", | ||
"prettier": "^1.11.1", | ||
"prop-types": "^15.6.1", | ||
"react": "^16.2.0" | ||
"react": "^16.3.0" | ||
}, | ||
@@ -36,0 +59,0 @@ "keywords": [ |
240
README.md
@@ -14,4 +14,6 @@ # react-vk | ||
## Important note! | ||
For local projects run your server on port 80 (This is VK API requirement for local projects) | ||
For example using create-react-app in your package.json: | ||
```js | ||
@@ -22,5 +24,7 @@ "start": "PORT=80 react-scripts start" | ||
Then: | ||
```shell | ||
sudo npm run start | ||
``` | ||
You need run this command as administrator! | ||
@@ -32,17 +36,17 @@ | ||
- `<VK apiId={123456} />` - provides child components with vk. apiId - requires | ||
- `<AllowMessagesFromCommunity />` - AllowMessagesFromCommunity Widget instance | ||
- `<Application />` - App Widget instance | ||
- `<Auth />` - Auth Widget instance | ||
- `<Comments />` - Comments Widget instance | ||
- `<CommentsBrowse />` - CommentsBrowse Widget instance | ||
- `<CommunityMessages />` - CommunityMessages Widget instance | ||
- `<ContactUs />` - ContactUs Widget instance | ||
- `<Group />` - Group Widget instance | ||
- `<Like />` - Like Widget instance | ||
- `<Playlist />` - Playlist Widget instance | ||
- `<Poll />` - Poll Widget instance | ||
- `<Post />` - Post Widget instance | ||
- `<Recommended />` - Recommended Widget instance | ||
- `<Subscribe />` - Subscribe Widget instance | ||
* `<VK apiId={123456} />` - provides child components with vk. apiId - requires | ||
* `<AllowMessagesFromCommunity />` - AllowMessagesFromCommunity Widget instance | ||
* `<Application />` - App Widget instance | ||
* `<Auth />` - Auth Widget instance | ||
* `<Comments />` - Comments Widget instance | ||
* `<CommentsBrowse />` - CommentsBrowse Widget instance | ||
* `<CommunityMessages />` - CommunityMessages Widget instance | ||
* `<ContactUs />` - ContactUs Widget instance | ||
* `<Group />` - Group Widget instance | ||
* `<Like />` - Like Widget instance | ||
* `<Playlist />` - Playlist Widget instance | ||
* `<Poll />` - Poll Widget instance | ||
* `<Post />` - Post Widget instance | ||
* `<Recommended />` - Recommended Widget instance | ||
* `<Subscribe />` - Subscribe Widget instance | ||
@@ -53,102 +57,102 @@ #### Information about components | ||
- `<VK apiId={number} onApiAvailable={function}/>` | ||
requires apiId for init VK. More information on [VK API](https://vk.com/dev/openapi) | ||
onApiAvailable - function that provide you access to VK api instance | ||
* `<VK apiId={number} onApiAvailable={function}/>` | ||
requires apiId for init VK. More information on [VK API](https://vk.com/dev/openapi) | ||
onApiAvailable - function that provide you access to VK api instance | ||
- `<AllowMessagesFromCommunity elementId={string} options={object} groupId={number} onAllow={function} onDeny={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
use functions: onAllow(When "Allow messages" button is pressed), | ||
onDeny(If the user denies messages) | ||
More information on [VK API](https://vk.com/dev/widget_allow_messages_from_community) | ||
* `<AllowMessagesFromCommunity elementId={string} options={object} groupId={number} onAllow={function} onDeny={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
use functions: onAllow(When "Allow messages" button is pressed), | ||
onDeny(If the user denies messages) | ||
More information on [VK API](https://vk.com/dev/widget_allow_messages_from_community) | ||
- `<Application elementId={string} appId={number} options={object}/>` | ||
requires appId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
More information on [VK API](https://vk.com/dev/widget_app) | ||
* `<Application elementId={string} appId={number} options={object}/>` | ||
requires appId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
More information on [VK API](https://vk.com/dev/widget_app) | ||
- `<Auth elementId={string} options={object} onAuth={function}/>` | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
use onAuth function(which can use a result of authorization(object with following fields: uid, first_name, last_name, photo, photo_rec, hash) | ||
More information on [VK API](https://vk.com/dev/widget_auth) | ||
* `<Auth elementId={string} options={object} onAuth={function}/>` | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
use onAuth function(which can use a result of authorization(object with following fields: uid, first_name, last_name, photo, photo_rec, hash) | ||
More information on [VK API](https://vk.com/dev/widget_auth) | ||
- `<Comments elementId={string} options={object} pageId={string} onNewComment={function} onDeleteComment={function} />` | ||
You can set options by object, | ||
pageId - ID of the page on your site, | ||
elementId - ID of the container element for the module. | ||
When a comment is posted or deleted 4 parameters are passed to the handler functions(onNewComment, onDeleteComment): | ||
num, last_comment, date, sign | ||
More information on [VK API](https://vk.com/dev/widget_comments) | ||
* `<Comments elementId={string} options={object} pageId={string} onNewComment={function} onDeleteComment={function} />` | ||
You can set options by object, | ||
pageId - ID of the page on your site, | ||
elementId - ID of the container element for the module. | ||
When a comment is posted or deleted 4 parameters are passed to the handler functions(onNewComment, onDeleteComment): | ||
num, last_comment, date, sign | ||
More information on [VK API](https://vk.com/dev/widget_comments) | ||
- `<CommentsBrowse elementId={string} options={object} />` | ||
You can set options by object, | ||
pageId - ID of the page on your site, | ||
elementId - ID of the container element for the module. | ||
More information on [VK API](https://vk.com/dev/widget_comments) | ||
* `<CommentsBrowse elementId={string} options={object} />` | ||
You can set options by object, | ||
pageId - ID of the page on your site, | ||
elementId - ID of the container element for the module. | ||
More information on [VK API](https://vk.com/dev/widget_comments) | ||
- `<CommunityMessages elementId={string} options={object} groupId={number} onMount={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
onMount = function that get mounted widget and elementId for extra actions: | ||
- destroy — deletes the widget(requires elementId); | ||
- expand — expands widget frame, may take welcomeScreen parameter (1 to show the welcome screen); | ||
- stopTitleAnimation — disables title animation when new message received; | ||
- minimize — minimizes widget frame. | ||
More information on [VK API](https://vk.com/dev/widget_community_messages) | ||
* `<CommunityMessages elementId={string} options={object} groupId={number} onMount={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
onMount = function that get mounted widget and elementId for extra actions: | ||
* destroy — deletes the widget(requires elementId); | ||
* expand — expands widget frame, may take welcomeScreen parameter (1 to show the welcome screen); | ||
* stopTitleAnimation — disables title animation when new message received; | ||
* minimize — minimizes widget frame. | ||
More information on [VK API](https://vk.com/dev/widget_community_messages) | ||
- `<ContactUs elementId={string} options={object} ownerId={number} />` | ||
requires ownerId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_contact_us) | ||
* `<ContactUs elementId={string} options={object} ownerId={number} />` | ||
requires ownerId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_contact_us) | ||
- `<Group elementId={string} groupId={number} options={object} onJoin={function} onLeave={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
When the 'Follow on VK' button is clicked your can use onJoin and onLeave functions | ||
More information on [VK API](https://vk.com/dev/widget_community) | ||
* `<Group elementId={string} groupId={number} options={object} onJoin={function} onLeave={function} />` | ||
requires groupId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
When the 'Follow on VK' button is clicked your can use onJoin and onLeave functions | ||
More information on [VK API](https://vk.com/dev/widget_community) | ||
- `<Like elementId={string} options={object} pageId={string} onLike={function} onUnlike={function} onShare={function} onUnshare={function} />` | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
pageId - ID of the page on your site, | ||
When Like button is clicked you can use onLike and onUnlike functions. You can use number of Likes for the current page as a parameter. | ||
Similar when Share With Friends is selected | ||
More information on [VK API](https://vk.com/dev/widget_like) | ||
* `<Like elementId={string} options={object} pageId={string} onLike={function} onUnlike={function} onShare={function} onUnshare={function} />` | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
pageId - ID of the page on your site, | ||
When Like button is clicked you can use onLike and onUnlike functions. You can use number of Likes for the current page as a parameter. | ||
Similar when Share With Friends is selected | ||
More information on [VK API](https://vk.com/dev/widget_like) | ||
- `<Playlist elementId={string} ownerId={number} playlistId={number} hash={string} options={object} />` | ||
For correct works requires ownerId, playlistId, hash(service parameter. hash can be obtained in the constructor only.) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_playlist) | ||
* `<Playlist elementId={string} ownerId={number} playlistId={number} hash={string} options={object} />` | ||
For correct works requires ownerId, playlistId, hash(service parameter. hash can be obtained in the constructor only.) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_playlist) | ||
- `<Poll elementId={string} options={object} pollId={string} />` | ||
requires pollId for correct work(You can get it using the form on https://vk.com/dev/Poll or with a button "Get code" in the existing poll) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_poll) | ||
* `<Poll elementId={string} options={object} pollId={string} />` | ||
requires pollId for correct work(You can get it using the form on https://vk.com/dev/Poll or with a button "Get code" in the existing poll) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_poll) | ||
- `<Post elementId={string} options={object} ownerId={number} postId={number} hash={string} />` | ||
For correct works requires ownerId, postId, hash(You can get hash in widget's constructor or "Export" window only.) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_post) | ||
* `<Post elementId={string} options={object} ownerId={number} postId={number} hash={string} />` | ||
For correct works requires ownerId, postId, hash(You can get hash in widget's constructor or "Export" window only.) | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_post) | ||
- `<Recommended elementId={string} options={object} />` | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_recommended) | ||
* `<Recommended elementId={string} options={object} />` | ||
You can set options by object, | ||
elementId - ID of the container element for the module | ||
More information on [VK API](https://vk.com/dev/widget_recommended) | ||
- `<Subscribe elementId={string} options={object} ownerId={number} onSubscribe={function} onUnsubscribe={function} />` | ||
requires ownerId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
when user subscribes, you can use onSubscribe function; when user unsubscribes — onUnsubscribe. | ||
More information on [VK API](https://vk.com/dev/widget_recommended) | ||
https://vk.com/dev/widget_subscribe | ||
* `<Subscribe elementId={string} options={object} ownerId={number} onSubscribe={function} onUnsubscribe={function} />` | ||
requires ownerId for correct work. | ||
You can set options by object, | ||
elementId - ID of the container element for the module, | ||
when user subscribes, you can use onSubscribe function; when user unsubscribes — onUnsubscribe. | ||
More information on [VK API](https://vk.com/dev/widget_recommended) | ||
https://vk.com/dev/widget_subscribe | ||
@@ -162,5 +166,5 @@ ## Basic usage | ||
```js | ||
window.onload = function () { | ||
VK.init({apiId: 123456}); | ||
} | ||
window.onload = function() { | ||
VK.init({ apiId: 123456 }); | ||
}; | ||
``` | ||
@@ -185,6 +189,6 @@ | ||
```js | ||
window.onload = function () { | ||
VK.init({apiId: 123456}); | ||
VK.Widgets.Auth('vk_auth', {}); | ||
} | ||
window.onload = function() { | ||
VK.init({ apiId: 123456 }); | ||
VK.Widgets.Auth("vk_auth", {}); | ||
}; | ||
``` | ||
@@ -277,3 +281,3 @@ | ||
<button onClick={this.handleClick}>Delete CommunityMessages</button> | ||
<VK apiId={6247321}> | ||
<VK apiId={123456}> | ||
<CommunityMessages | ||
@@ -288,11 +292,12 @@ groupId={127607773} | ||
); | ||
``` | ||
## More details and examples | ||
You can clone this repository and check more examples | ||
```shell | ||
git clone https://github.com/mmarkelov/react-vk.git | ||
cd ./react-vk | ||
npm install && npm run examples | ||
cd ./react-vk/examples | ||
npm install && npm run dev | ||
``` | ||
@@ -302,5 +307,10 @@ | ||
##TODO | ||
* [ ] Add tests | ||
## Acknowledgements | ||
- Thanks to [@gribnoysup](https://github.com/gribnoysup/) and his [react-yandex-maps](https://github.com/gribnoysup/react-yandex-maps) for inspiration and motivation. | ||
- Thanks to [@seeden](https://github.com/seeden/) and his [react-facebook](https://github.com/seeden/react-facebook) for inspiration and motivation. | ||
- Lots of features were founded in these perfect packages. | ||
* Thanks to [@gribnoysup](https://github.com/gribnoysup/) and his [react-yandex-maps](https://github.com/gribnoysup/react-yandex-maps) for inspiration and motivation. | ||
* Thanks to [@seeden](https://github.com/seeden/) and his [react-facebook](https://github.com/seeden/react-facebook) for inspiration and motivation. | ||
* Lots of features were founded in these perfect packages. |
63506
308
19