@times-components/save-and-share-bar 0.13.9 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/save-and-share-bar.js +5 -1
- package/package.json +5 -4
- package/rnw.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.14.0](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.13.9...@times-components/save-and-share-bar@0.14.0) (2022-11-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **TDP-000:** Bookmarks migrated to Newskit ([#3174](https://github.com/newsuk/times-components/issues/3174)) ([8d4f7ad](https://github.com/newsuk/times-components/commit/8d4f7ad7fd41d4e54c69ff626edefdd1c4413f36))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.13.9](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.13.8...@times-components/save-and-share-bar@0.13.9) (2022-11-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @times-components/save-and-share-bar
|
|
@@ -19,6 +19,8 @@ var _userState = _interopRequireDefault(require("@times-components/user-state"))
|
|
|
19
19
|
|
|
20
20
|
var _context = require("@times-components/context");
|
|
21
21
|
|
|
22
|
+
var _tsComponents = require("@times-components/ts-components");
|
|
23
|
+
|
|
22
24
|
var _getTokenisedArticleUrlApi = _interopRequireDefault(require("./get-tokenised-article-url-api"));
|
|
23
25
|
|
|
24
26
|
var _withTrackEvents = _interopRequireDefault(require("./tracking/with-track-events"));
|
|
@@ -116,7 +118,9 @@ class SaveAndShareBar extends _react.Component {
|
|
|
116
118
|
}, /*#__PURE__*/_react.default.createElement(_utils.TcView, {
|
|
117
119
|
style: _styles.default.rowItemRight,
|
|
118
120
|
"data-testid": "save-star"
|
|
119
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
121
|
+
}, typeof window !== "undefined" && window.location.search.includes("saveStarSwitch") ? /*#__PURE__*/_react.default.createElement(_tsComponents.SaveStar, {
|
|
122
|
+
articleId: articleId
|
|
123
|
+
}) : /*#__PURE__*/_react.default.createElement(_saveStarWeb.default, {
|
|
120
124
|
colour: _styles.default.svgIcon.save.strokeColour,
|
|
121
125
|
hoverColor: _styles.default.svgIcon.hoverFillColour,
|
|
122
126
|
articleId: articleId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-components/save-and-share-bar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Save and Share bar",
|
|
5
5
|
"main": "dist/save-and-share-bar",
|
|
6
6
|
"dev": "src/save-and-share-bar",
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"@times-components/link": "3.11.6",
|
|
38
38
|
"@times-components/message-bar": "0.7.7",
|
|
39
39
|
"@times-components/provider-queries": "2.18.0",
|
|
40
|
-
"@times-components/save-star-web": "0.9.
|
|
41
|
-
"@times-components/tracking": "2.
|
|
40
|
+
"@times-components/save-star-web": "0.9.10",
|
|
41
|
+
"@times-components/tracking": "2.15.0",
|
|
42
|
+
"@times-components/ts-components": "1.55.0",
|
|
42
43
|
"@times-components/ts-styleguide": "1.37.6",
|
|
43
44
|
"@times-components/user-state": "0.4.7",
|
|
44
45
|
"@times-components/utils": "6.15.6",
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"publishConfig": {
|
|
73
74
|
"access": "public"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "4850e14b67950ecdef8730cea86c0a19960e16d2"
|
|
76
77
|
}
|
package/rnw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=
|
|
1
|
+
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("@times-components/utils/rnw")},function(e,t){e.exports=require("@times-components/icons/rnw")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/save-star-web/rnw")},function(e,t){e.exports=require("@times-components/context/rnw")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("@times-components/provider-queries/rnw")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=(r(5),r(2)),i=r(3),c=r(6),l=r.n(c),s=r(4),u=r.n(s),d=r(7),h=r(8),p=r(9);const f=Object(a.makeClient)();var m=e=>f.query({query:p.getTokenisedArticleUrl,variables:{id:e}}),g=r(10),b="https://www.facebook.com/sharer/sharer.php",v="https://twitter.com/intent/tweet",y=r(1);function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var S={container:{flex:1,flexDirection:"row",justifyContent:"space-between",paddingTop:Object(y.spacing)(2),paddingBottom:Object(y.spacing)(2),height:"100%",alignItems:"center"},activityLoader:{borderRadius:9999,height:40,overflow:"hidden",width:40},label:O(O({},Object(y.fontFactory)({font:"supporting",fontSize:"meta"})),{},{color:y.colours.functional.secondary,marginRight:Object(y.spacing)(2),transform:"translateY(9%)"}),link:{base:"\n margin-left: ".concat(Object(y.spacing)(1),";\n cursor: pointer;\n border-radius: ").concat(40,"px;\n\n &, > * {\n display: flex;\n align-items: center;\n justify-content: center;\n height: ").concat(40,"px;\n width: ").concat(40,"px;\n }\n\n &:hover {\n background-color: ").concat(y.colours.functional.whiteGrey,";\n }\n &:active {\n background-color: ").concat(y.colours.functional.keyline,";\n }\n ")},rowItem:{alignItems:"center",flexDirection:"row",height:40},rowItemRight:{alignItems:"center",flexDirection:"row",height:40,marginLeft:"auto"},svgIcon:{fb:{height:18},star:{height:18},fillColour:y.colours.functional.secondary,height:16,hoverFillColour:y.colours.functional.brandColour,save:{fillColour:y.colours.functional.white,strokeColour:y.colours.functional.secondary}}},k=r(11),T=r.n(k);function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function E(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var j=e=>{let t=e.children,r=e.colour,n=void 0===r?S.svgIcon.fillColour:r,i=e.dataTestId,c=e.hoverColour,l=void 0===c?S.svgIcon.hoverFillColour:c,s=e.onPress,u=void 0===s?()=>{}:s,d=E(e,["children","colour","dataTestId","hoverColour","onPress"]);return o.a.createElement(a.TcView,{"data-testid":i},o.a.createElement(T.a,C({onPress:u,responsiveLinkStyles:S.link},d),o.a.createElement(a.HoverIcon,{colour:n,hoverColour:l},t)))};class x extends n.Component{constructor(e){super(e),this.state={isLoading:!1},this.onShare=this.onShare.bind(this)}onShare(e){const t=this.props,r=t.articleId,n=t.getTokenisedShareUrl,o=t.shouldTokenise,a=t.articleUrl,i=t.onShareEmail,c=t.articleHeadline;if(e.preventDefault(),i({articleId:r,articleUrl:a,articleHeadline:c}),o)this.setState({isLoading:!0}),n(r).then(e=>{const t=e.data;t&&t.article&&(this.setState({isLoading:!1}),this.openMailClient(t.article.tokenisedUrl))}).catch(e=>{this.setState({isLoading:!1}),console.error("Error in connecting to api",e)});else{const e=window.location.search.match(/[?&]shareToken=([^&]+)/);this.openMailClient(e?"".concat(a,"?shareToken=").concat(e[1]):a)}}openMailClient(e){const t=this.props,r=t.articleHeadline,n="TIMES"!==t.publicationName?"The Sunday Times":"The Times",o="mailto:?subject=".concat(r," from ").concat(n,"&body=I thought you would be interested in this story from ").concat(n,"%0A%0A").concat(r,"%0A%0A").concat(e);window.location.assign(o)}render(){const e=this.state.isLoading;return o.a.createElement(j,{onPress:this.onShare,dataTestId:"email-share",url:""},e?o.a.createElement(i.IconActivityIndicator,{size:"small",style:S.activityLoader}):o.a.createElement(i.IconEmail,{fillColour:"currentColor",height:S.svgIcon.height,title:"Share by email"}))}}x.defaultProps={publicationName:"TIMES"};var P=x;function N(){return(N=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}class A extends n.Component{constructor(e){super(e),this.copyToClipboard=this.copyToClipboard.bind(this)}copyToClipboard(e){const t=this.props,r=t.onCopyLink,n=t.articleUrl;e.preventDefault(),navigator.clipboard.writeText(n),r()}render(){const e=this.props,t=e.articleId,r=e.articleUrl,n=e.savingEnabled,c=e.sharingEnabled,s=e.onShareOnFB,p=e.onShareOnTwitter;return o.a.createElement(a.TcView,{style:S.container,"data-testid":"save-and-share-bar"},c&&o.a.createElement(a.TcView,{style:S.rowItem},o.a.createElement(a.TcText,{style:Object(a.checkStylesForUnits)(S.label)},"Share"),o.a.createElement(d.SectionContext.Consumer,null,e=>{let t=e.publicationName;return o.a.createElement(u.a,{state:u.a.showTokenisedEmailShare,fallback:o.a.createElement(P,N({},this.props,{shouldTokenise:!1,publicationName:t}))},o.a.createElement(P,N({},this.props,{shouldTokenise:!0,publicationName:t})))}),o.a.createElement(j,{onPress:p,target:"_blank",dataTestId:"share-twitter",url:"".concat(v,"?text=").concat(r)},o.a.createElement(i.IconTwitter,{fillColour:"currentColor",height:S.svgIcon.height,title:"Share on Twitter"})),o.a.createElement(j,{onPress:s,target:"_blank",dataTestId:"share-facebook",url:"".concat(b,"?u=").concat(r)},o.a.createElement(i.IconFacebook,{fillColour:"currentColor",height:S.svgIcon.fb.height,title:"Share on Facebook"})),o.a.createElement(j,{color:S.svgIcon.save.strokeColour,hoverColor:S.svgIcon.hoverFillColour,onPress:this.copyToClipboard,dataTestId:"copy-to-clickboard",url:""},o.a.createElement(i.IconCopyLink,{fillColour:"currentColor",height:S.svgIcon.height,title:"Copy link to clipboard"}))),n?o.a.createElement(u.a,{state:u.a.showArticleSaveButton,serverRender:!1},o.a.createElement(a.TcView,{style:S.rowItemRight,"data-testid":"save-star"},"undefined"!=typeof window&&window.location.search.includes("saveStarSwitch")?o.a.createElement(h.SaveStar,{articleId:t}):o.a.createElement(l.a,{colour:S.svgIcon.save.strokeColour,hoverColor:S.svgIcon.hoverFillColour,articleId:t,height:S.svgIcon.star.height}))):null)}}A.defaultProps={onShareOnFB:()=>{},onShareOnTwitter:()=>{},onShareEmail:()=>{},getTokenisedShareUrl:m};var q;t.default=(q=A,Object(g.withTrackEvents)(q,{analyticsEvents:[{actionName:"Pressed",eventName:"onSaveToMyArticles",getAttrs:e=>({articleId:e.articleId,articleHeadline:e.articleHeadline}),trackingName:"ArticleSaveToMyArticles"},{actionName:"Pressed",eventName:"onShareEmail",getAttrs:e=>({articleId:e.articleId,articleHeadline:e.articleHeadline}),trackingName:"ArticleShareUrlByEmail"},{actionName:"Pressed",eventName:"onCopyLink",getAttrs:e=>({articleId:e.articleId,articleHeadline:e.articleHeadline}),trackingName:"ArticleCopyLink"},{actionName:"Pressed",eventName:"onShareOnFB",getAttrs:e=>({articleId:e.articleId,articleHeadline:e.articleHeadline}),trackingName:"ArticleShareOnFacebook"},{actionName:"Pressed",eventName:"onShareOnTwitter",getAttrs:e=>({articleId:e.articleId,articleHeadline:e.articleHeadline}),trackingName:"ArticleShareOnTwitter"}]}))}]);
|