react-stickerpipe
Advanced tools
Comparing version 1.2.8 to 1.3.0
@@ -17,26 +17,27 @@ 'use strict'; | ||
function performRequest(method, url, callback) { | ||
var options = { | ||
url: url, | ||
headers: { | ||
ApiKey: this.key, | ||
Platform: 'JS', | ||
UserId: this.userId | ||
} | ||
}; | ||
_superagent2.default[method](options.url).set(options.headers).end(callback); | ||
} | ||
var StickerPipeClient = function () { | ||
function StickerPipeClient(key, userId, baseUrl) { | ||
function StickerPipeClient(apiKey, userId, baseUrl) { | ||
_classCallCheck(this, StickerPipeClient); | ||
Object.assign(this, { key: key, userId: userId, baseUrl: baseUrl }); | ||
Object.assign(this, { apiKey: apiKey, userId: userId, baseUrl: baseUrl }); | ||
} | ||
_createClass(StickerPipeClient, [{ | ||
key: 'performRequest', | ||
value: function performRequest(method, url, callback) { | ||
var options = { | ||
url: url, | ||
headers: { | ||
ApiKey: this.apiKey, | ||
Platform: 'JS', | ||
UserId: this.userId | ||
} | ||
}; | ||
_superagent2.default[method](options.url).set(options.headers).end(callback); | ||
} | ||
}, { | ||
key: 'getMyPacks', | ||
value: function getMyPacks(callback) { | ||
performRequest('get', this.baseUrl + '/shop/my', callback); | ||
this.performRequest('get', this.baseUrl + '/shop/my', callback); | ||
} | ||
@@ -46,3 +47,3 @@ }, { | ||
value: function getShop(callback) { | ||
performRequest('get', this.baseUrl + '/shop', callback); | ||
this.performRequest('get', this.baseUrl + '/shop', callback); | ||
} | ||
@@ -52,3 +53,3 @@ }, { | ||
value: function getPackPreview(packName, callback) { | ||
performRequest('get', this.baseUrl + '/packs/' + packName, callback); | ||
this.performRequest('get', this.baseUrl + '/packs/' + packName, callback); | ||
} | ||
@@ -58,3 +59,3 @@ }, { | ||
value: function purchasePack(packName, callback) { | ||
performRequest('post', this.baseUrl + '/packs/' + packName, callback); | ||
this.performRequest('post', this.baseUrl + '/packs/' + packName, callback); | ||
} | ||
@@ -61,0 +62,0 @@ }]); |
@@ -25,2 +25,6 @@ 'use strict'; | ||
var _iconAdd = require('./icon-add'); | ||
var _iconAdd2 = _interopRequireDefault(_iconAdd); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -123,3 +127,5 @@ | ||
sendSticker = _props.sendSticker, | ||
stickerPacks = _props.stickerPacks; | ||
stickerPacks = _props.stickerPacks, | ||
shop = _props.shop, | ||
toggleShop = _props.toggleShop; | ||
@@ -131,19 +137,23 @@ | ||
_react2.default.createElement( | ||
'h1', | ||
null, | ||
'My Packs' | ||
'section', | ||
{ className: 'pack-list' }, | ||
stickerPacks.length > 0 ? stickerPacks.map(function (stickerPack) { | ||
return _react2.default.createElement(_sticker2.default, { | ||
key: stickerPack.pack_name, | ||
src: stickerPack.main_icon.mdpi, | ||
onClick: function onClick() { | ||
return _this4.showPack(stickerPack.pack_name); | ||
} | ||
}); | ||
}) : _react2.default.createElement( | ||
'p', | ||
null, | ||
'Loading...' | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ onClick: toggleShop, className: 'button-shop' }, | ||
_react2.default.createElement(_iconAdd2.default, { color: shop ? '#00BCD4' : null }) | ||
) | ||
), | ||
stickerPacks.length > 0 ? stickerPacks.map(function (stickerPack) { | ||
return _react2.default.createElement(_sticker2.default, { | ||
key: stickerPack.pack_name, | ||
src: stickerPack.main_icon.mdpi, | ||
onClick: function onClick() { | ||
return _this4.showPack(stickerPack.pack_name); | ||
} | ||
}); | ||
}) : _react2.default.createElement( | ||
'p', | ||
null, | ||
'Loading...' | ||
), | ||
pack ? _react2.default.createElement(_stickerPack2.default, { pack: pack, sendSticker: sendSticker }) : null | ||
@@ -168,3 +178,5 @@ ); | ||
})).isRequired, | ||
getMyPacks: _react2.default.PropTypes.func.isRequired | ||
getMyPacks: _react2.default.PropTypes.func.isRequired, | ||
toggleShop: _react2.default.PropTypes.func.isRequired, | ||
shop: _react2.default.PropTypes.bool.isRequired | ||
}; | ||
@@ -171,0 +183,0 @@ MyStickerPacks.contextTypes = { |
@@ -17,2 +17,7 @@ 'use strict'; | ||
if (!text) { | ||
console.warn('Did not supply any matching response format. Response is:', text); | ||
return null; | ||
} | ||
try { | ||
@@ -28,3 +33,3 @@ var parsedResponse = JSON.parse(text); | ||
return {}; | ||
return null; | ||
} | ||
@@ -31,0 +36,0 @@ |
@@ -50,3 +50,4 @@ 'use strict'; | ||
_this.state = { | ||
stickerPacks: [] | ||
stickerPacks: [], | ||
shop: false | ||
}; | ||
@@ -68,2 +69,3 @@ | ||
_this.getMyPacks = _this.getMyPacks.bind(_this); | ||
_this.toggleShop = _this.toggleShop.bind(_this); | ||
return _this; | ||
@@ -107,6 +109,15 @@ } | ||
}, { | ||
key: 'toggleShop', | ||
value: function toggleShop() { | ||
this.setState({ | ||
shop: !this.state.shop | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var sendSticker = this.props.sendSticker; | ||
var stickerPacks = this.state.stickerPacks; | ||
var _state = this.state, | ||
stickerPacks = _state.stickerPacks, | ||
shop = _state.shop; | ||
@@ -120,5 +131,7 @@ | ||
stickerPacks: stickerPacks, | ||
getMyPacks: this.getMyPacks | ||
getMyPacks: this.getMyPacks, | ||
toggleShop: this.toggleShop, | ||
shop: shop | ||
}), | ||
_react2.default.createElement(_stickerShop2.default, { getMyPacks: this.getMyPacks }) | ||
shop ? _react2.default.createElement(_stickerShop2.default, { getMyPacks: this.getMyPacks }) : null | ||
); | ||
@@ -158,23 +171,3 @@ } | ||
}; | ||
StickerMenu.propTypes = { | ||
apiKey: function apiKey(props, propName) { | ||
if (!props.client && !props[propName]) { | ||
return new Error('Prop ' + propName + ' is required when prop client is not specified!'); | ||
} | ||
return null; | ||
}, | ||
userId: _react2.default.PropTypes.string.isRequired, | ||
sendSticker: _react2.default.PropTypes.func.isRequired, | ||
client: _react2.default.PropTypes.shape({ | ||
getMyPacks: _react2.default.PropTypes.func.isRequired, | ||
getShop: _react2.default.PropTypes.func.isRequired, | ||
getPackPreview: _react2.default.PropTypes.func.isRequired, | ||
purchasePack: _react2.default.PropTypes.func.isRequired | ||
}) | ||
}; | ||
exports.default = StickerMenu; | ||
module.exports = exports['default']; |
@@ -17,2 +17,6 @@ 'use strict'; | ||
var _iconPurchase = require('./icon-purchase'); | ||
var _iconPurchase2 = _interopRequireDefault(_iconPurchase); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -82,18 +86,9 @@ | ||
null, | ||
'Preview' | ||
preview.title | ||
), | ||
_react2.default.createElement('img', { style: style.preview, src: preview.preview_landscape.hdpi, alt: preview.title }), | ||
_react2.default.createElement( | ||
'section', | ||
null, | ||
_react2.default.createElement( | ||
'h1', | ||
null, | ||
preview.title | ||
), | ||
_react2.default.createElement('img', { style: style.preview, src: preview.preview.hdpi, alt: preview.title }), | ||
_react2.default.createElement( | ||
'button', | ||
{ onClick: this.purchasePack }, | ||
'Purchase' | ||
) | ||
'div', | ||
{ onClick: this.purchasePack, className: 'button-purchase' }, | ||
_react2.default.createElement(_iconPurchase2.default, null) | ||
) | ||
@@ -100,0 +95,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var _react = require('react'); | ||
var _react = require("react"); | ||
@@ -18,15 +18,7 @@ var _react2 = _interopRequireDefault(_react); | ||
var style = { | ||
sticker: { | ||
width: '50px', | ||
cursor: 'pointer' | ||
} | ||
}; | ||
return _react2.default.createElement('img', { | ||
className: 'sticker', | ||
return _react2.default.createElement("img", { | ||
className: "sticker", | ||
onClick: onClick, | ||
style: style.sticker, | ||
src: src, | ||
role: 'presentation' | ||
role: "presentation" | ||
}); | ||
@@ -41,2 +33,2 @@ } | ||
exports.default = Sticker; | ||
module.exports = exports['default']; | ||
module.exports = exports["default"]; |
{ | ||
"name": "react-stickerpipe", | ||
"version": "1.2.8", | ||
"version": "1.3.0", | ||
"description": "React Component for StickerPipe API", | ||
@@ -10,6 +10,7 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"watch": "babel -d dist/ -w src/", | ||
"compile": "babel -d dist/ src/", | ||
"lint": "eslint src/*", | ||
"prepublish": "npm run lint && npm run compile" | ||
"prepublish": "npm run lint && npm run compile && npm run test" | ||
}, | ||
@@ -52,2 +53,3 @@ "repository": { | ||
"babel-preset-stage-0": "^6.16.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^3.10.2", | ||
@@ -57,3 +59,5 @@ "eslint-config-airbnb": "^13.0.0", | ||
"eslint-plugin-jsx-a11y": "^2.2.3", | ||
"eslint-plugin-react": "^6.7.1" | ||
"eslint-plugin-react": "^6.7.1", | ||
"mocha": "^3.2.0", | ||
"sinon": "^1.17.6" | ||
}, | ||
@@ -60,0 +64,0 @@ "babel": { |
@@ -10,3 +10,3 @@ # React StickerPipe | ||
[![NPM](https://nodei.co/npm/react-stickerpipe.png)](https://nodei.co/npm/react-stickerpipe/) | ||
[![NPM](https://nodei.co/npm/react-stickerpipe.png?compact=true)](https://nodei.co/npm/react-stickerpipe/) | ||
@@ -13,0 +13,0 @@ Basic Usage |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40285
16
809
14