@times-components/save-and-share-bar 0.13.3 → 0.13.5

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 CHANGED
@@ -3,6 +3,25 @@
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.13.5](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.13.4...@times-components/save-and-share-bar@0.13.5) (2022-10-19)
7
+
8
+ **Note:** Version bump only for package @times-components/save-and-share-bar
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.13.4](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.13.3...@times-components/save-and-share-bar@0.13.4) (2022-10-18)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **TDP-2612:** UserState refactor ([#3167](https://github.com/newsuk/times-components/issues/3167)) ([acb908b](https://github.com/newsuk/times-components/commit/acb908ba9827284f9d91b02c1246f4578716c559))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.13.3](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.13.2...@times-components/save-and-share-bar@0.13.3) (2022-10-14)
7
26
 
8
27
  **Note:** Version bump only for package @times-components/save-and-share-bar
@@ -73,7 +73,7 @@ class SaveAndShareBar extends _react.Component {
73
73
  }, "Share"), /*#__PURE__*/_react.default.createElement(_context.SectionContext.Consumer, null, _ref => {
74
74
  let publicationName = _ref.publicationName;
75
75
  return /*#__PURE__*/_react.default.createElement(_userState.default, {
76
- state: _userState.default.subscriber,
76
+ state: _userState.default.showTokenisedEmailShare,
77
77
  fallback: /*#__PURE__*/_react.default.createElement(_emailShare.default, _extends({}, this.props, {
78
78
  shouldTokenise: false,
79
79
  publicationName: publicationName
@@ -111,7 +111,7 @@ class SaveAndShareBar extends _react.Component {
111
111
  height: _styles.default.svgIcon.height,
112
112
  title: "Copy link to clipboard"
113
113
  }))), savingEnabled ? /*#__PURE__*/_react.default.createElement(_userState.default, {
114
- state: _userState.default.loggedIn,
114
+ state: _userState.default.showArticleSaveButton,
115
115
  serverRender: false
116
116
  }, /*#__PURE__*/_react.default.createElement(_utils.TcView, {
117
117
  style: _styles.default.rowItemRight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/save-and-share-bar",
3
- "version": "0.13.3",
3
+ "version": "0.13.5",
4
4
  "description": "Save and Share bar",
5
5
  "main": "dist/save-and-share-bar",
6
6
  "dev": "src/save-and-share-bar",
@@ -32,25 +32,25 @@
32
32
  "homepage": "https://github.com/newsuk/times-components#readme",
33
33
  "dependencies": {
34
34
  "@storybook/addon-knobs": "5.3.18",
35
- "@times-components/context": "1.10.1",
36
- "@times-components/icons": "2.19.2",
37
- "@times-components/link": "3.11.2",
38
- "@times-components/message-bar": "0.7.2",
35
+ "@times-components/context": "1.10.2",
36
+ "@times-components/icons": "2.19.3",
37
+ "@times-components/link": "3.11.3",
38
+ "@times-components/message-bar": "0.7.3",
39
39
  "@times-components/provider-queries": "2.18.0",
40
- "@times-components/save-star-web": "0.9.3",
41
- "@times-components/tracking": "2.12.3",
42
- "@times-components/ts-styleguide": "1.37.2",
43
- "@times-components/user-state": "0.4.2",
44
- "@times-components/utils": "6.15.1",
40
+ "@times-components/save-star-web": "0.9.5",
41
+ "@times-components/tracking": "2.13.0",
42
+ "@times-components/ts-styleguide": "1.37.3",
43
+ "@times-components/user-state": "0.4.3",
44
+ "@times-components/utils": "6.15.2",
45
45
  "prop-types": "15.7.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@babel/core": "7.4.4",
49
49
  "@times-components/eslint-config-thetimes": "0.8.18",
50
50
  "@times-components/jest-configurator-web": "0.8.0",
51
- "@times-components/jest-serializer": "3.4.1",
51
+ "@times-components/jest-serializer": "3.4.2",
52
52
  "@times-components/provider-test-tools": "1.27.0",
53
- "@times-components/storybook": "4.5.2",
53
+ "@times-components/storybook": "4.5.3",
54
54
  "@times-components/webpack-configurator": "2.1.0",
55
55
  "babel-jest": "24.8.0",
56
56
  "eslint": "5.9.0",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "1da4d8169d316fe83739814ab4ba16ce195709c9"
75
+ "gitHead": "6bd3787a6f3a06b7dcecca9ffe88d8114660297f"
76
76
  }
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=11)}([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/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);const p=Object(a.makeClient)();var f=e=>p.query({query:h.getTokenisedArticleUrl,variables:{id:e}}),m=r(9),g="https://www.facebook.com/sharer/sharer.php",b="https://twitter.com/intent/tweet",v=r(1);function y(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 w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){O(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var I={container:{flex:1,flexDirection:"row",justifyContent:"space-between",paddingTop:Object(v.spacing)(2),paddingBottom:Object(v.spacing)(2),height:"100%",alignItems:"center"},activityLoader:{borderRadius:9999,height:40,overflow:"hidden",width:40},label:w(w({},Object(v.fontFactory)({font:"supporting",fontSize:"meta"})),{},{color:v.colours.functional.secondary,marginRight:Object(v.spacing)(2),transform:"translateY(9%)"}),link:{base:"\n margin-left: ".concat(Object(v.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(v.colours.functional.whiteGrey,";\n }\n &:active {\n background-color: ").concat(v.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:v.colours.functional.secondary,height:16,hoverFillColour:v.colours.functional.brandColour,save:{fillColour:v.colours.functional.white,strokeColour:v.colours.functional.secondary}}},k=r(10),S=r.n(k);function T(){return(T=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 C(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?I.svgIcon.fillColour:r,i=e.dataTestId,c=e.hoverColour,l=void 0===c?I.svgIcon.hoverFillColour:c,s=e.onPress,u=void 0===s?()=>{}:s,d=C(e,["children","colour","dataTestId","hoverColour","onPress"]);return o.a.createElement(a.TcView,{"data-testid":i},o.a.createElement(S.a,T({onPress:u,responsiveLinkStyles:I.link},d),o.a.createElement(a.HoverIcon,{colour:n,hoverColour:l},t)))};class E 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:I.activityLoader}):o.a.createElement(i.IconEmail,{fillColour:"currentColor",height:I.svgIcon.height,title:"Share by email"}))}}E.defaultProps={publicationName:"TIMES"};var x=E;function P(){return(P=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 N 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,h=e.onShareOnTwitter;return o.a.createElement(a.TcView,{style:I.container,"data-testid":"save-and-share-bar"},c&&o.a.createElement(a.TcView,{style:I.rowItem},o.a.createElement(a.TcText,{style:Object(a.checkStylesForUnits)(I.label)},"Share"),o.a.createElement(d.SectionContext.Consumer,null,e=>{let t=e.publicationName;return o.a.createElement(u.a,{state:u.a.subscriber,fallback:o.a.createElement(x,P({},this.props,{shouldTokenise:!1,publicationName:t}))},o.a.createElement(x,P({},this.props,{shouldTokenise:!0,publicationName:t})))}),o.a.createElement(j,{onPress:h,target:"_blank",dataTestId:"share-twitter",url:"".concat(b,"?text=").concat(r)},o.a.createElement(i.IconTwitter,{fillColour:"currentColor",height:I.svgIcon.height,title:"Share on Twitter"})),o.a.createElement(j,{onPress:s,target:"_blank",dataTestId:"share-facebook",url:"".concat(g,"?u=").concat(r)},o.a.createElement(i.IconFacebook,{fillColour:"currentColor",height:I.svgIcon.fb.height,title:"Share on Facebook"})),o.a.createElement(j,{color:I.svgIcon.save.strokeColour,hoverColor:I.svgIcon.hoverFillColour,onPress:this.copyToClipboard,dataTestId:"copy-to-clickboard",url:""},o.a.createElement(i.IconCopyLink,{fillColour:"currentColor",height:I.svgIcon.height,title:"Copy link to clipboard"}))),n?o.a.createElement(u.a,{state:u.a.loggedIn,serverRender:!1},o.a.createElement(a.TcView,{style:I.rowItemRight,"data-testid":"save-star"},o.a.createElement(l.a,{colour:I.svgIcon.save.strokeColour,hoverColor:I.svgIcon.hoverFillColour,articleId:t,height:I.svgIcon.star.height}))):null)}}N.defaultProps={onShareOnFB:()=>{},onShareOnTwitter:()=>{},onShareEmail:()=>{},getTokenisedShareUrl:f};var A;t.default=(A=N,Object(m.withTrackEvents)(A,{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"}]}))}]);
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=11)}([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/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);const p=Object(a.makeClient)();var f=e=>p.query({query:h.getTokenisedArticleUrl,variables:{id:e}}),m=r(9),g="https://www.facebook.com/sharer/sharer.php",b="https://twitter.com/intent/tweet",v=r(1);function y(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 w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){O(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var I={container:{flex:1,flexDirection:"row",justifyContent:"space-between",paddingTop:Object(v.spacing)(2),paddingBottom:Object(v.spacing)(2),height:"100%",alignItems:"center"},activityLoader:{borderRadius:9999,height:40,overflow:"hidden",width:40},label:w(w({},Object(v.fontFactory)({font:"supporting",fontSize:"meta"})),{},{color:v.colours.functional.secondary,marginRight:Object(v.spacing)(2),transform:"translateY(9%)"}),link:{base:"\n margin-left: ".concat(Object(v.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(v.colours.functional.whiteGrey,";\n }\n &:active {\n background-color: ").concat(v.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:v.colours.functional.secondary,height:16,hoverFillColour:v.colours.functional.brandColour,save:{fillColour:v.colours.functional.white,strokeColour:v.colours.functional.secondary}}},k=r(10),S=r.n(k);function T(){return(T=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 C(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?I.svgIcon.fillColour:r,i=e.dataTestId,c=e.hoverColour,l=void 0===c?I.svgIcon.hoverFillColour:c,s=e.onPress,u=void 0===s?()=>{}:s,d=C(e,["children","colour","dataTestId","hoverColour","onPress"]);return o.a.createElement(a.TcView,{"data-testid":i},o.a.createElement(S.a,T({onPress:u,responsiveLinkStyles:I.link},d),o.a.createElement(a.HoverIcon,{colour:n,hoverColour:l},t)))};class E 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:I.activityLoader}):o.a.createElement(i.IconEmail,{fillColour:"currentColor",height:I.svgIcon.height,title:"Share by email"}))}}E.defaultProps={publicationName:"TIMES"};var x=E;function P(){return(P=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 N 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,h=e.onShareOnTwitter;return o.a.createElement(a.TcView,{style:I.container,"data-testid":"save-and-share-bar"},c&&o.a.createElement(a.TcView,{style:I.rowItem},o.a.createElement(a.TcText,{style:Object(a.checkStylesForUnits)(I.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(x,P({},this.props,{shouldTokenise:!1,publicationName:t}))},o.a.createElement(x,P({},this.props,{shouldTokenise:!0,publicationName:t})))}),o.a.createElement(j,{onPress:h,target:"_blank",dataTestId:"share-twitter",url:"".concat(b,"?text=").concat(r)},o.a.createElement(i.IconTwitter,{fillColour:"currentColor",height:I.svgIcon.height,title:"Share on Twitter"})),o.a.createElement(j,{onPress:s,target:"_blank",dataTestId:"share-facebook",url:"".concat(g,"?u=").concat(r)},o.a.createElement(i.IconFacebook,{fillColour:"currentColor",height:I.svgIcon.fb.height,title:"Share on Facebook"})),o.a.createElement(j,{color:I.svgIcon.save.strokeColour,hoverColor:I.svgIcon.hoverFillColour,onPress:this.copyToClipboard,dataTestId:"copy-to-clickboard",url:""},o.a.createElement(i.IconCopyLink,{fillColour:"currentColor",height:I.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:I.rowItemRight,"data-testid":"save-star"},o.a.createElement(l.a,{colour:I.svgIcon.save.strokeColour,hoverColor:I.svgIcon.hoverFillColour,articleId:t,height:I.svgIcon.star.height}))):null)}}N.defaultProps={onShareOnFB:()=>{},onShareOnTwitter:()=>{},onShareEmail:()=>{},getTokenisedShareUrl:f};var A;t.default=(A=N,Object(m.withTrackEvents)(A,{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"}]}))}]);