@ta-interaktiv/react-polymorphic-share-buttons
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -0,1 +1,41 @@ | ||
<a name="1.2.5"></a> | ||
## [1.2.5](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/compare/v1.2.4...v1.2.5) (2018-02-15) | ||
<a name="1.2.4"></a> | ||
## [1.2.4](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/compare/v1.2.1...v1.2.4) (2018-02-15) | ||
### chore | ||
* IDE changes ([fbeecca5b212677af78d9d4988d80e3d97f10373](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/fbeecca5b212677af78d9d4988d80e3d97f10373)) | ||
* IDE changes ([bb89a237dd52530cecf32530d82af7962cd90d18](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/bb89a237dd52530cecf32530d82af7962cd90d18)) | ||
### fix | ||
* mobile2.tagesanzeiger.ch -> m.tagesanzeiger.ch ([2f8f0b05477faa187e5f64b516c7b87c9ec03aa2](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/2f8f0b05477faa187e5f64b516c7b87c9ec03aa2)) | ||
### Patch | ||
* iconClassName comes from the beginning and gets passed through. ([d7e820b07edcab2c70b5bc73a712db6bd81f0dda](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/d7e820b07edcab2c70b5bc73a712db6bd81f0dda)) | ||
<a name="1.2.1"></a> | ||
## [1.2.1](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/compare/1.2.0...1.2.1) (2017-10-10) | ||
### Tooling | ||
* Add flow ([21e66a9f5fc928f28154ea1b0bbe74f077326a5c](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/21e66a9f5fc928f28154ea1b0bbe74f077326a5c)) | ||
* Add package.json scripts ([2e7e6c56927b5170864240bfab8a09f17a8c7a3e](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/2e7e6c56927b5170864240bfab8a09f17a8c7a3e)) | ||
* Add React as peer dependencies ([97a13d5d3dd0c55f9fc89cada84d64de9919224e](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/97a13d5d3dd0c55f9fc89cada84d64de9919224e)) | ||
* Remove browser field in package.json ([1f5c2cb80494292ce16b0f9636c405534e9c9bca](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/1f5c2cb80494292ce16b0f9636c405534e9c9bca)) | ||
* Update dependency to @ta-interaktiv/react-share-buttons ([01c33508eb720701b2ce2b1a69c5a63e2b9ffaca](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/01c33508eb720701b2ce2b1a69c5a63e2b9ffaca)) | ||
* Upgrade storybook ([c0fcb0d05ae5fd593ee2656417acc379ac604aa3](https://gitlab.com/ta-interactive/react-polymorphic-share-buttons/commit/c0fcb0d05ae5fd593ee2656417acc379ac604aa3)) | ||
# Changelog | ||
@@ -2,0 +42,0 @@ |
{ | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "dist/index.js", | ||
"jsnext:main": "src/index", | ||
"module": "src/index", | ||
"jsnext:main": "es/index", | ||
"module": "es/index", | ||
"scripts": { | ||
"dist": "yarn run fix && babel src -d dist", | ||
"dist": "BABEL_ENV=commonjs babel src -d dist", | ||
"dist:es": "yarn run copy-flow-sources && yarn run strip-flow-types", | ||
"copy-flow-sources": "flow-copy-source src es", | ||
"strip-flow-types": "BABEL_ENV=es babel src -d es", | ||
"lint": "eslint src/", | ||
@@ -12,3 +15,3 @@ "fix": "eslint src/ --fix", | ||
"watch-scss": "node-sass scss/styles.scss --output style --source-map true --watch", | ||
"prepublishOnly": "yarn run compile-scss && yarn run docs && yarn run dist", | ||
"prepublishOnly": "yarn run fix && yarn run compile-scss && yarn run docs && yarn run dist && yarn run dist:es", | ||
"storybook": "start-storybook -p 9001 -c storybook", | ||
@@ -41,3 +44,3 @@ "docs": "documentation readme src/*.js --section=API", | ||
"babel-cli": "^6.18.0", | ||
"babel-eslint": "^7.1.0", | ||
"babel-eslint": "^8", | ||
"babel-plugin-syntax-flow": "^6.18.0", | ||
@@ -57,3 +60,4 @@ "babel-plugin-transform-class-properties": "^6.24.1", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"flow-bin": "^0.51.0", | ||
"flow-bin": "^0.56", | ||
"flow-copy-source": "^1.2.1", | ||
"husky": "^0.14.3", | ||
@@ -64,8 +68,13 @@ "lint-staged": "^4.2.3", | ||
"prop-types": "^15.5.10", | ||
"react": "^15.0.0", | ||
"react-dom": "^15.0.0", | ||
"react": "^15 || ^16", | ||
"react-dom": "^15 || ^16", | ||
"react-storybook-addon-backgrounds": "^0.0.7" | ||
}, | ||
"peerDependencies": { | ||
"react": "^15 || ^16", | ||
"react-dom": "^15 || ^16" | ||
}, | ||
"files": [ | ||
"dist/", | ||
"es/", | ||
"src/", | ||
@@ -75,4 +84,5 @@ "style/" | ||
"dependencies": { | ||
"@ta-interaktiv/newsnet-api-flow-types": "^0.5.1", | ||
"@ta-interaktiv/parse-hostname": "^1.0.0", | ||
"@ta-interaktiv/react-share-buttons": "^1.1.0", | ||
"@ta-interaktiv/react-share-buttons": "^1.6.5", | ||
"d3-request": "^1.0.3" | ||
@@ -94,3 +104,7 @@ }, | ||
"homepage": "https://gitlab.com/ta-interactive/react-polymorphic-share-buttons#README", | ||
"name": "@ta-interaktiv/react-polymorphic-share-buttons" | ||
"name": "@ta-interaktiv/react-polymorphic-share-buttons", | ||
"browserslist": [ | ||
">= 0.25% in CH", | ||
"last 3 major versions" | ||
] | ||
} |
@@ -14,4 +14,2 @@ # Polymorphic Sharing Buttons | ||
<a name="module_PolymorphicShareButtons"></a> | ||
## API | ||
@@ -57,4 +55,4 @@ | ||
- `props` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `props.articleID` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The article ID of the main / link article | ||
- `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `props.articleID` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The article ID of the main / link article | ||
in the CD. Used to get the appropriate share URLs and counts. | ||
@@ -64,34 +62,13 @@ - `props.clickHandler` **[clickHandler](#clickhandler)?** An action to execute when | ||
API endpoint. | ||
- `props.displayType` **{VERTICAL_BUTTONS: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), HORIZONTAL_ICONS: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)}** The display type, either | ||
- `props.displayType` **{VERTICAL_BUTTONS: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), HORIZONTAL_ICONS: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}** The display type, either | ||
horizontally aligned icons (with share counter) or vertically stacked | ||
buttons. Defaults to vertical buttons. (optional, default `VERTICAL_BUTTONS`) | ||
- `props.inverted` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether the list should be | ||
- `props.inverted` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether the list should be | ||
displayed on a dark background. (optional, default `false`) | ||
- `props.hashtags` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>?** A list of hashtags to tag the shared | ||
- `props.hashtags` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** A list of hashtags to tag the shared | ||
content with. Facebook will only accept the first value, so make it | ||
count. | ||
- `props.additionalFacebookShares` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Manually add Facebook | ||
- `props.additionalFacebookShares` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Manually add Facebook | ||
shares in case some of them got lost due to changing the canonical URL. | ||
### community | ||
The community object as provided by the Newsnet API. | ||
Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
**Properties** | ||
- `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier of the community (i.e. 'facebook' | ||
or 'twitter') | ||
- `count` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The number of shares of this type. | ||
- `share_type_id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A GUID that links article and community | ||
type. | ||
- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The canonical URL of the article that should be | ||
used for sharing this article. | ||
- `name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The front facing name of the community. | ||
- `title` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The title of the article for sharing. | ||
- `description` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The call to action for the community. | ||
- `facebook_id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The Facebook App ID. | ||
- `via` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The via account name to use on Twitter. | ||
### requestStatus | ||
@@ -110,24 +87,11 @@ | ||
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) | ||
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function) | ||
**Parameters** | ||
- `articleID` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The ID of the article. | ||
- `community` **[community](#community)** A community object, as provided by the | ||
- `articleID` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The ID of the article. | ||
- `community` **community** A community object, as provided by the | ||
Newsnet API | ||
- `event` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The react event object. | ||
- `event` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The react event object. | ||
## Remarks | ||
### Fallback | ||
In case the article with the given ID can't be found, the component will fall | ||
back to sensible defaults and still provide sharing buttons. | ||
### Display Type | ||
Currently available values: | ||
- 'horizontal icons' | ||
- 'vertical buttons' | ||
- 'horizontal buttons' | ||
Returns **void** |
@@ -0,1 +1,2 @@ | ||
// @flow | ||
/** | ||
@@ -24,25 +25,8 @@ * @module PolymorphicShareButtons | ||
/** | ||
* The community object as provided by the Newsnet API. | ||
* | ||
* @typedef {Object} community | ||
* @property {string} type The identifier of the community (i.e. 'facebook' | ||
* or 'twitter') | ||
* @property {number} count The number of shares of this type. | ||
* @property {string} share_type_id A GUID that links article and community | ||
* type. | ||
* @property {string} url The canonical URL of the article that should be | ||
* used for sharing this article. | ||
* @property {string} [name] The front facing name of the community. | ||
* @property {string} [title] The title of the article for sharing. | ||
* @property {string} [description] The call to action for the community. | ||
* @property {string} [facebook_id] The Facebook App ID. | ||
* @property {string} [via] The via account name to use on Twitter. | ||
*/ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import * as React from 'react' | ||
import { json, request } from 'd3-request' | ||
import { parseHostname } from '@ta-interaktiv/parse-hostname' | ||
import ShareButtons, { displayTypes } from '@ta-interaktiv/react-share-buttons' | ||
import ShareButtons from '@ta-interaktiv/react-share-buttons' | ||
import type { DisplayTypes } from '@ta-interaktiv/react-share-buttons/es/displayTypes' | ||
import type { Community } from '@ta-interaktiv/newsnet-api-flow-types/api/articles/article/communities/community' | ||
import '../style/styles.css' | ||
@@ -52,3 +36,2 @@ | ||
* Enum states for the loading process. | ||
* @type {{LOADING: string, ERROR: string, READY: string}} | ||
*/ | ||
@@ -66,5 +49,20 @@ const requestStatus = { | ||
type Props = { | ||
additionalFacebookShares?: number, | ||
articleID: string, | ||
clickHandler: (articleID: string, community: Community) => void, | ||
displayType?: DisplayTypes, | ||
hashtags?: Array<string>, | ||
inverted?: boolean | ||
} | ||
type State = { | ||
communities: Array<Community>, | ||
loadingState: 'loading' | 'error' | 'ready' | ||
} | ||
/** | ||
* Share buttons that are configured using the Newsnet API, using the article ID | ||
* | ||
* | ||
* @param {object} props | ||
@@ -88,10 +86,10 @@ * @param {string} props.articleID The article ID of the main / link article | ||
*/ | ||
class PolymorphicShareButtons extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
this.state = { | ||
loadingState: requestStatus.LOADING | ||
} | ||
class PolymorphicShareButtons extends React.Component<Props, State> { | ||
state = { | ||
loadingState: requestStatus.LOADING, | ||
communities: [] | ||
} | ||
static defaultProps = { | ||
clickHandler: defaultClickHandler | ||
} | ||
@@ -152,4 +150,2 @@ // region React component overrides | ||
console.log(data.communities) | ||
this.setState({ | ||
@@ -166,19 +162,2 @@ communities: data.communities, | ||
PolymorphicShareButtons.propTypes = { | ||
displayType: PropTypes.oneOf([ | ||
displayTypes.HORIZONTAL_ICONS, | ||
displayTypes.VERTICAL_BUTTONS | ||
]), | ||
inverted: PropTypes.bool, | ||
hashtags: PropTypes.arrayOf(PropTypes.string), | ||
articleID: PropTypes.string.isRequired, | ||
clickHandler: PropTypes.func, | ||
additionalFacebookShares: PropTypes.number, | ||
iconClassName: PropTypes.string | ||
} | ||
PolymorphicShareButtons.defaultProps = { | ||
clickHandler: defaultClickHandler | ||
} | ||
/** | ||
@@ -193,3 +172,3 @@ * The default click handler will call the share counting REST API upon | ||
*/ | ||
function defaultClickHandler (articleID, community) { | ||
function defaultClickHandler (articleID: string, community: Community): void { | ||
const shareTypeId = community['share_type_id'] | ||
@@ -196,0 +175,0 @@ request( |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
37083
11
455
1
6
29
94
+ Added@ta-interaktiv/newsnet-api-flow-types@0.5.1(transitive)