@times-components/save-and-share-bar 0.13.9 → 0.15.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 +22 -0
- package/dist/save-and-share-bar.js +4 -7
- package/package.json +4 -4
- package/rnw.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.15.0](https://github.com/newsuk/times-components/compare/@times-components/save-and-share-bar@0.14.0...@times-components/save-and-share-bar@0.15.0) (2022-11-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **TDP-000:** Bookmarks migrated to Newskit ([#3176](https://github.com/newsuk/times-components/issues/3176)) ([6eba05d](https://github.com/newsuk/times-components/commit/6eba05defd2dce98f156d024d3b302e0a8d7ba5e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **TDP-000:** Bookmarks migrated to Newskit ([#3174](https://github.com/newsuk/times-components/issues/3174)) ([8d4f7ad](https://github.com/newsuk/times-components/commit/8d4f7ad7fd41d4e54c69ff626edefdd1c4413f36))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [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
29
|
|
|
8
30
|
**Note:** Version bump only for package @times-components/save-and-share-bar
|
|
@@ -13,12 +13,12 @@ var _utils = require("@times-components/utils");
|
|
|
13
13
|
|
|
14
14
|
var _icons = require("@times-components/icons");
|
|
15
15
|
|
|
16
|
-
var _saveStarWeb = _interopRequireDefault(require("@times-components/save-star-web"));
|
|
17
|
-
|
|
18
16
|
var _userState = _interopRequireDefault(require("@times-components/user-state"));
|
|
19
17
|
|
|
20
18
|
var _context = require("@times-components/context");
|
|
21
19
|
|
|
20
|
+
var _tsComponents = require("@times-components/ts-components");
|
|
21
|
+
|
|
22
22
|
var _getTokenisedArticleUrlApi = _interopRequireDefault(require("./get-tokenised-article-url-api"));
|
|
23
23
|
|
|
24
24
|
var _withTrackEvents = _interopRequireDefault(require("./tracking/with-track-events"));
|
|
@@ -116,11 +116,8 @@ class SaveAndShareBar extends _react.Component {
|
|
|
116
116
|
}, /*#__PURE__*/_react.default.createElement(_utils.TcView, {
|
|
117
117
|
style: _styles.default.rowItemRight,
|
|
118
118
|
"data-testid": "save-star"
|
|
119
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
120
|
-
|
|
121
|
-
hoverColor: _styles.default.svgIcon.hoverFillColour,
|
|
122
|
-
articleId: articleId,
|
|
123
|
-
height: _styles.default.svgIcon.star.height
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement(_tsComponents.SaveStar, {
|
|
120
|
+
articleId: articleId
|
|
124
121
|
}))) : null);
|
|
125
122
|
}
|
|
126
123
|
|
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.15.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,8 @@
|
|
|
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/
|
|
41
|
-
"@times-components/
|
|
40
|
+
"@times-components/tracking": "2.15.0",
|
|
41
|
+
"@times-components/ts-components": "1.55.0",
|
|
42
42
|
"@times-components/ts-styleguide": "1.37.6",
|
|
43
43
|
"@times-components/user-state": "0.4.7",
|
|
44
44
|
"@times-components/utils": "6.15.6",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "439fe068e52a9dc997012d6ae5c4812c5ec2c764"
|
|
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/
|
|
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/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(4),l=r.n(c),s=r(6),u=r(7),d=r(8);const p=Object(a.makeClient)();var h=e=>p.query({query:d.getTokenisedArticleUrl,variables:{id:e}}),f=r(9),m="https://www.facebook.com/sharer/sharer.php",g="https://twitter.com/intent/tweet",b=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 v(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){w(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 w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var O={container:{flex:1,flexDirection:"row",justifyContent:"space-between",paddingTop:Object(b.spacing)(2),paddingBottom:Object(b.spacing)(2),height:"100%",alignItems:"center"},activityLoader:{borderRadius:9999,height:40,overflow:"hidden",width:40},label:v(v({},Object(b.fontFactory)({font:"supporting",fontSize:"meta"})),{},{color:b.colours.functional.secondary,marginRight:Object(b.spacing)(2),transform:"translateY(9%)"}),link:{base:"\n margin-left: ".concat(Object(b.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(b.colours.functional.whiteGrey,";\n }\n &:active {\n background-color: ").concat(b.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:b.colours.functional.secondary,height:16,hoverFillColour:b.colours.functional.brandColour,save:{fillColour:b.colours.functional.white,strokeColour:b.colours.functional.secondary}}},I=r(10),S=r.n(I);function k(){return(k=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 T(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 C=e=>{let t=e.children,r=e.colour,n=void 0===r?O.svgIcon.fillColour:r,i=e.dataTestId,c=e.hoverColour,l=void 0===c?O.svgIcon.hoverFillColour:c,s=e.onPress,u=void 0===s?()=>{}:s,d=T(e,["children","colour","dataTestId","hoverColour","onPress"]);return o.a.createElement(a.TcView,{"data-testid":i},o.a.createElement(S.a,k({onPress:u,responsiveLinkStyles:O.link},d),o.a.createElement(a.HoverIcon,{colour:n,hoverColour:l},t)))};class j 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(C,{onPress:this.onShare,dataTestId:"email-share",url:""},e?o.a.createElement(i.IconActivityIndicator,{size:"small",style:O.activityLoader}):o.a.createElement(i.IconEmail,{fillColour:"currentColor",height:O.svgIcon.height,title:"Share by email"}))}}j.defaultProps={publicationName:"TIMES"};var E=j;function x(){return(x=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 P 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,d=e.onShareOnFB,p=e.onShareOnTwitter;return o.a.createElement(a.TcView,{style:O.container,"data-testid":"save-and-share-bar"},c&&o.a.createElement(a.TcView,{style:O.rowItem},o.a.createElement(a.TcText,{style:Object(a.checkStylesForUnits)(O.label)},"Share"),o.a.createElement(s.SectionContext.Consumer,null,e=>{let t=e.publicationName;return o.a.createElement(l.a,{state:l.a.showTokenisedEmailShare,fallback:o.a.createElement(E,x({},this.props,{shouldTokenise:!1,publicationName:t}))},o.a.createElement(E,x({},this.props,{shouldTokenise:!0,publicationName:t})))}),o.a.createElement(C,{onPress:p,target:"_blank",dataTestId:"share-twitter",url:"".concat(g,"?text=").concat(r)},o.a.createElement(i.IconTwitter,{fillColour:"currentColor",height:O.svgIcon.height,title:"Share on Twitter"})),o.a.createElement(C,{onPress:d,target:"_blank",dataTestId:"share-facebook",url:"".concat(m,"?u=").concat(r)},o.a.createElement(i.IconFacebook,{fillColour:"currentColor",height:O.svgIcon.fb.height,title:"Share on Facebook"})),o.a.createElement(C,{color:O.svgIcon.save.strokeColour,hoverColor:O.svgIcon.hoverFillColour,onPress:this.copyToClipboard,dataTestId:"copy-to-clickboard",url:""},o.a.createElement(i.IconCopyLink,{fillColour:"currentColor",height:O.svgIcon.height,title:"Copy link to clipboard"}))),n?o.a.createElement(l.a,{state:l.a.showArticleSaveButton,serverRender:!1},o.a.createElement(a.TcView,{style:O.rowItemRight,"data-testid":"save-star"},o.a.createElement(u.SaveStar,{articleId:t}))):null)}}P.defaultProps={onShareOnFB:()=>{},onShareOnTwitter:()=>{},onShareEmail:()=>{},getTokenisedShareUrl:h};var N;t.default=(N=P,Object(f.withTrackEvents)(N,{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"}]}))}]);
|