@twreporter/react-components 8.5.0-rc.1
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 +544 -0
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/lib/bookmark-list/bookmark.js +251 -0
- package/lib/bookmark-list/bookmarks.js +93 -0
- package/lib/bookmark-list/customized-link.js +45 -0
- package/lib/bookmark-list/image-wrapper.js +119 -0
- package/lib/bookmark-list/index.js +312 -0
- package/lib/bookmark-list/redirect-to-sign-in.js +35 -0
- package/lib/bookmark-widget/index.js +259 -0
- package/lib/confirmation/index.js +125 -0
- package/lib/donation-link.js +75 -0
- package/lib/error/index.js +17 -0
- package/lib/error/message.js +567 -0
- package/lib/footer/constants/paths.js +8 -0
- package/lib/footer/constants/styles.js +81 -0
- package/lib/footer/content.js +227 -0
- package/lib/footer/icon-list.js +191 -0
- package/lib/footer/index.js +123 -0
- package/lib/footer/logo.js +92 -0
- package/lib/is-fetching-wrapper.js +126 -0
- package/lib/link-with-tracker.js +153 -0
- package/lib/listing-page/components/image.js +185 -0
- package/lib/listing-page/components/list-item.js +197 -0
- package/lib/listing-page/components/list.js +188 -0
- package/lib/listing-page/components/topics/index.js +215 -0
- package/lib/listing-page/components/topics/page-content.js +44 -0
- package/lib/listing-page/components/topics/post-item.js +139 -0
- package/lib/listing-page/components/topics/posts.js +24 -0
- package/lib/listing-page/components/topics/section.js +104 -0
- package/lib/listing-page/components/topics/topic-item.js +206 -0
- package/lib/listing-page/constants/mockup-spec.js +39 -0
- package/lib/listing-page/constants/predefined-css.js +21 -0
- package/lib/listing-page/constants/topics.js +13 -0
- package/lib/listing-page/index.js +30 -0
- package/lib/mobile-pop-up-modal.js +161 -0
- package/lib/more.js +98 -0
- package/lib/pagination/index.js +310 -0
- package/lib/podcast-link.js +73 -0
- package/lib/side-bar/index.js +317 -0
- package/lib/table-of-contents/index.js +532 -0
- package/lib/utils/link-with-params.js +27 -0
- package/package.json +33 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _styles = _interopRequireDefault(require("./constants/styles"));
|
|
17
|
+
|
|
18
|
+
var _paths = require("./constants/paths");
|
|
19
|
+
|
|
20
|
+
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
21
|
+
|
|
22
|
+
var _templateObject, _templateObject2;
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
+
|
|
28
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
31
|
+
|
|
32
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
|
+
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
39
|
+
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
|
+
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
|
+
|
|
46
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
47
|
+
|
|
48
|
+
var Link = /*#__PURE__*/_styledComponents["default"].a.withConfig({
|
|
49
|
+
displayName: "logo__Link",
|
|
50
|
+
componentId: "sc-1lniyyi-0"
|
|
51
|
+
})(["position:relative;cursor:pointer;text-decoration:none !important;"]);
|
|
52
|
+
|
|
53
|
+
var StyledReporterLogo = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
54
|
+
displayName: "logo__StyledReporterLogo",
|
|
55
|
+
componentId: "sc-1lniyyi-1"
|
|
56
|
+
})(["transform:translateX(-22px);width:", "px;height:", "px;img{width:100%;filter:grayscale(100%);opacity:", ";}img:hover{filter:none;opacity:1;}", " ", ""], _styles["default"].reporterLogo.width.mobile, _styles["default"].reporterLogo.height.mobile, _styles["default"].grayScaleOpacity.pureBlackWhiteSrc, _mediaQuery["default"].tabletAndAbove(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n "])), _styles["default"].reporterLogo.width.desktop, _styles["default"].reporterLogo.height.desktop), _mediaQuery["default"].hdOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transform: translateX(-25px);\n width: ", "px;\n height: ", "px;\n "])), _styles["default"].reporterLogo.width.hd, _styles["default"].reporterLogo.height.hd));
|
|
57
|
+
|
|
58
|
+
var Logo = /*#__PURE__*/function (_React$PureComponent) {
|
|
59
|
+
_inherits(Logo, _React$PureComponent);
|
|
60
|
+
|
|
61
|
+
var _super = _createSuper(Logo);
|
|
62
|
+
|
|
63
|
+
function Logo() {
|
|
64
|
+
_classCallCheck(this, Logo);
|
|
65
|
+
|
|
66
|
+
return _super.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_createClass(Logo, [{
|
|
70
|
+
key: "render",
|
|
71
|
+
value: function render() {
|
|
72
|
+
var mainOrigin = this.props.mainOrigin;
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement(Link, {
|
|
74
|
+
href: mainOrigin
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledReporterLogo, null, /*#__PURE__*/_react["default"].createElement("img", {
|
|
76
|
+
alt: "The Reporter Logo",
|
|
77
|
+
src: "".concat(_paths.assets, "logo-horizontal02.svg")
|
|
78
|
+
})));
|
|
79
|
+
}
|
|
80
|
+
}]);
|
|
81
|
+
|
|
82
|
+
return Logo;
|
|
83
|
+
}(_react["default"].PureComponent);
|
|
84
|
+
|
|
85
|
+
Logo.propTypes = {
|
|
86
|
+
mainOrigin: _propTypes["default"].string.isRequired
|
|
87
|
+
};
|
|
88
|
+
Logo.defaultProps = {
|
|
89
|
+
mainOrigin: ''
|
|
90
|
+
};
|
|
91
|
+
var _default = Logo;
|
|
92
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _storageUrlProcessor = require("@twreporter/core/lib/utils/storage-url-processor");
|
|
11
|
+
|
|
12
|
+
var storage = _interopRequireWildcard(require("@twreporter/core/lib/constants/storage"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
+
|
|
20
|
+
var _excluded = ["isFetching", "showSpinner"];
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
|
|
28
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
29
|
+
|
|
30
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
|
+
|
|
32
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
+
|
|
34
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
35
|
+
|
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
37
|
+
|
|
38
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
39
|
+
|
|
40
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
|
+
|
|
42
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
43
|
+
|
|
44
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
45
|
+
|
|
46
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
|
+
|
|
48
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
|
+
|
|
50
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
|
+
|
|
52
|
+
var spinnerLogoUrl = "".concat(storage.google.schema, "://").concat(storage.google.hostname, "/").concat(storage.google.bucket, "/images/spinner-logo.gif");
|
|
53
|
+
|
|
54
|
+
var FetchingBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
55
|
+
displayName: "is-fetching-wrapper__FetchingBlock",
|
|
56
|
+
componentId: "sc-1oo61h6-0"
|
|
57
|
+
})(["position:relative;display:", ";min-height:100vh;width:100%;", ""], function (props) {
|
|
58
|
+
return props.isFetching ? 'block' : 'none';
|
|
59
|
+
}, function (props) {
|
|
60
|
+
return props.showSpinner ? "\n background-image: url(".concat((0, _storageUrlProcessor.replaceGCSUrlOrigin)(spinnerLogoUrl), ");\n background-position: center;\n background-repeat: no-repeat;\n ") : '';
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var TransitionBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
64
|
+
displayName: "is-fetching-wrapper__TransitionBlock",
|
|
65
|
+
componentId: "sc-1oo61h6-1"
|
|
66
|
+
})(["transition:opacity 1s ease-in-out;opacity:", ";"], function (props) {
|
|
67
|
+
return props.isFetching ? 0 : 1;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var FetchingWrapper = function FetchingWrapper(WrappedComponent) {
|
|
71
|
+
var Wrapper = /*#__PURE__*/function (_React$PureComponent) {
|
|
72
|
+
_inherits(Wrapper, _React$PureComponent);
|
|
73
|
+
|
|
74
|
+
var _super = _createSuper(Wrapper);
|
|
75
|
+
|
|
76
|
+
function Wrapper() {
|
|
77
|
+
_classCallCheck(this, Wrapper);
|
|
78
|
+
|
|
79
|
+
return _super.apply(this, arguments);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_createClass(Wrapper, [{
|
|
83
|
+
key: "render",
|
|
84
|
+
value: function render() {
|
|
85
|
+
// TODO make client customize FetchingBlock
|
|
86
|
+
var _this$props = this.props,
|
|
87
|
+
isFetching = _this$props.isFetching,
|
|
88
|
+
showSpinner = _this$props.showSpinner,
|
|
89
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
90
|
+
|
|
91
|
+
if ( /*#__PURE__*/_react["default"].isValidElement(WrappedComponent)) {
|
|
92
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(FetchingBlock, {
|
|
93
|
+
isFetching: isFetching,
|
|
94
|
+
showSpinner: showSpinner
|
|
95
|
+
}), /*#__PURE__*/_react["default"].createElement(TransitionBlock, {
|
|
96
|
+
isFetching: isFetching
|
|
97
|
+
}, WrappedComponent));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(FetchingBlock, {
|
|
101
|
+
isFetching: isFetching,
|
|
102
|
+
showSpinner: showSpinner
|
|
103
|
+
}), /*#__PURE__*/_react["default"].createElement(TransitionBlock, {
|
|
104
|
+
isFetching: isFetching
|
|
105
|
+
}, /*#__PURE__*/_react["default"].createElement(WrappedComponent, rest)));
|
|
106
|
+
}
|
|
107
|
+
}]);
|
|
108
|
+
|
|
109
|
+
return Wrapper;
|
|
110
|
+
}(_react["default"].PureComponent);
|
|
111
|
+
|
|
112
|
+
Wrapper.defaultProps = {
|
|
113
|
+
isFetching: false,
|
|
114
|
+
showSpinner: false // fetchingBlockStyles: '',
|
|
115
|
+
|
|
116
|
+
};
|
|
117
|
+
Wrapper.propTypes = {
|
|
118
|
+
isFetching: _propTypes["default"].bool,
|
|
119
|
+
showSpinner: _propTypes["default"].bool // fetchingBlockStyles: PropTypes.string,
|
|
120
|
+
|
|
121
|
+
};
|
|
122
|
+
return Wrapper;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var _default = FetchingWrapper;
|
|
126
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
15
|
+
|
|
16
|
+
var _excluded = ["clickActionName", "href", "to", "rel", "target"];
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
+
|
|
26
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
27
|
+
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
|
+
|
|
30
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
+
|
|
32
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
33
|
+
|
|
34
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
35
|
+
|
|
36
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
|
+
|
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
+
|
|
40
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
+
|
|
42
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
43
|
+
|
|
44
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
+
|
|
46
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
|
+
|
|
48
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
|
+
|
|
50
|
+
var _ = {
|
|
51
|
+
get: _get["default"]
|
|
52
|
+
};
|
|
53
|
+
var eventAction = 'Click';
|
|
54
|
+
var hitType = 'event';
|
|
55
|
+
var keysToBeTracked = ['Enter', 'NumpadEnter', 'Space'];
|
|
56
|
+
|
|
57
|
+
var TrackedLink = /*#__PURE__*/function (_PureComponent) {
|
|
58
|
+
_inherits(TrackedLink, _PureComponent);
|
|
59
|
+
|
|
60
|
+
var _super = _createSuper(TrackedLink);
|
|
61
|
+
|
|
62
|
+
function TrackedLink(props) {
|
|
63
|
+
var _this;
|
|
64
|
+
|
|
65
|
+
_classCallCheck(this, TrackedLink);
|
|
66
|
+
|
|
67
|
+
_this = _super.call(this, props);
|
|
68
|
+
_this.sendClickTrackingEvent = _this.sendClickTrackingEvent.bind(_assertThisInitialized(_this));
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_createClass(TrackedLink, [{
|
|
73
|
+
key: "isKeyToBeTracked",
|
|
74
|
+
value: function isKeyToBeTracked(keyCode) {
|
|
75
|
+
return keysToBeTracked.some(function (keyToBeTracked) {
|
|
76
|
+
return keyCode === keyToBeTracked;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "sendClickTrackingEvent",
|
|
81
|
+
value: function sendClickTrackingEvent(e) {
|
|
82
|
+
if (e.code && !this.isKeyToBeTracked(e.code)) return;
|
|
83
|
+
var clickActionName = this.props.clickActionName || 'undefined-click-action';
|
|
84
|
+
|
|
85
|
+
var url = _.get(window, 'location.href', 'null');
|
|
86
|
+
|
|
87
|
+
var eventLabel = "[".concat(clickActionName, "]: ").concat(url);
|
|
88
|
+
|
|
89
|
+
if (typeof gtag === 'function') {
|
|
90
|
+
try {
|
|
91
|
+
gtag(hitType, eventAction, {
|
|
92
|
+
event_label: eventLabel
|
|
93
|
+
});
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log('gtag error', err); // eslint-disable-line no-console
|
|
96
|
+
}
|
|
97
|
+
} else if (typeof ga === 'function') {
|
|
98
|
+
try {
|
|
99
|
+
ga('send', {
|
|
100
|
+
hitType: hitType,
|
|
101
|
+
eventAction: eventAction,
|
|
102
|
+
eventLabel: eventLabel
|
|
103
|
+
});
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.log('ga error', err); // eslint-disable-line no-console
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
console.log('No `gtag` or `ga` instance exists to send the link clicked event.'); // eslint-disable-line no-console
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "render",
|
|
113
|
+
value: function render() {
|
|
114
|
+
var _this$props = this.props,
|
|
115
|
+
clickActionName = _this$props.clickActionName,
|
|
116
|
+
href = _this$props.href,
|
|
117
|
+
to = _this$props.to,
|
|
118
|
+
rel = _this$props.rel,
|
|
119
|
+
target = _this$props.target,
|
|
120
|
+
elseProps = _objectWithoutProperties(_this$props, _excluded);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
/*#__PURE__*/
|
|
124
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
125
|
+
_react["default"].createElement("a", _extends({
|
|
126
|
+
href: href || to,
|
|
127
|
+
onMouseDown: this.sendClickTrackingEvent,
|
|
128
|
+
onKeyDown: this.sendClickTrackingEvent,
|
|
129
|
+
rel: rel || (target === '_blank' ? 'noopener noreferrer' : ''),
|
|
130
|
+
target: target
|
|
131
|
+
}, elseProps))
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}]);
|
|
135
|
+
|
|
136
|
+
return TrackedLink;
|
|
137
|
+
}(_react.PureComponent);
|
|
138
|
+
|
|
139
|
+
exports["default"] = TrackedLink;
|
|
140
|
+
TrackedLink.propTypes = {
|
|
141
|
+
clickActionName: _propTypes["default"].string,
|
|
142
|
+
href: _propTypes["default"].string,
|
|
143
|
+
to: _propTypes["default"].string,
|
|
144
|
+
rel: _propTypes["default"].string,
|
|
145
|
+
target: _propTypes["default"].string
|
|
146
|
+
};
|
|
147
|
+
TrackedLink.defaultProps = {
|
|
148
|
+
clickActionName: '',
|
|
149
|
+
href: '',
|
|
150
|
+
to: '',
|
|
151
|
+
rel: '',
|
|
152
|
+
target: '_self'
|
|
153
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _storageUrlProcessor = require("@twreporter/core/lib/utils/storage-url-processor");
|
|
17
|
+
|
|
18
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
+
|
|
24
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
|
+
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
27
|
+
|
|
28
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
+
|
|
30
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
+
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
+
|
|
34
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
|
+
|
|
36
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
+
|
|
42
|
+
var LogoIcon = function LogoIcon(props) {
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement("svg", props, /*#__PURE__*/_react["default"].createElement("title", null, "Fill 1"), /*#__PURE__*/_react["default"].createElement("path", {
|
|
44
|
+
d: "M5 112.563a5.001 5.001 0 0 1-5-5V4.999C0 3.298.866 1.713 2.298.794A5.003 5.003 0 0 1 7.08.451l42.724 19.521a5 5 0 0 1-4.156 9.097L10 12.783V99.78l49.843-22.775V32.014a5 5 0 0 1 3.669-4.82l37.105-10.247a4.999 4.999 0 0 1 6.331 4.819v67.44a5.003 5.003 0 0 1-6.142 4.868l-20.106-4.716a5 5 0 0 1 2.284-9.736l13.965 3.275V28.332L69.844 35.82v44.4a5 5 0 0 1-2.922 4.549L7.078 112.11a4.996 4.996 0 0 1-2.079.451",
|
|
45
|
+
fill: "#DBDCDC",
|
|
46
|
+
fillRule: "evenodd"
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
LogoIcon.defaultProps = {
|
|
51
|
+
width: "107",
|
|
52
|
+
height: "113",
|
|
53
|
+
viewBox: "0 0 107 113",
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
55
|
+
};
|
|
56
|
+
var _ = {
|
|
57
|
+
get: _get["default"]
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var ImgContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
61
|
+
displayName: "image__ImgContainer",
|
|
62
|
+
componentId: "iof1ou-0"
|
|
63
|
+
})(["width:100%;height:100%;position:relative;"]);
|
|
64
|
+
|
|
65
|
+
var ImgObjectFit = /*#__PURE__*/(0, _styledComponents["default"])(ImgContainer).withConfig({
|
|
66
|
+
displayName: "image__ImgObjectFit",
|
|
67
|
+
componentId: "iof1ou-1"
|
|
68
|
+
})(["opacity:", ";transition:opacity 1s ease;> img{width:100%;height:100%;object-fit:cover;}"], function (props) {
|
|
69
|
+
return props.opacity;
|
|
70
|
+
});
|
|
71
|
+
var ImgFallback = /*#__PURE__*/(0, _styledComponents["default"])(ImgContainer).withConfig({
|
|
72
|
+
displayName: "image__ImgFallback",
|
|
73
|
+
componentId: "iof1ou-2"
|
|
74
|
+
})(["background-size:cover;background-image:", ";background-position:center center;"], function (props) {
|
|
75
|
+
return "url(".concat((0, _storageUrlProcessor.replaceGCSUrlOrigin)(_.get(props, 'url')), ")");
|
|
76
|
+
}); // Vertically and horizontally centering
|
|
77
|
+
|
|
78
|
+
var LogoCenteringBlock = /*#__PURE__*/(0, _styledComponents["default"])(ImgContainer).withConfig({
|
|
79
|
+
displayName: "image__LogoCenteringBlock",
|
|
80
|
+
componentId: "iof1ou-3"
|
|
81
|
+
})(["position:absolute;justify-content:center;align-items:center;background-color:#fff;display:", ";"], function (props) {
|
|
82
|
+
return props.display;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var Image = /*#__PURE__*/function (_React$PureComponent) {
|
|
86
|
+
_inherits(Image, _React$PureComponent);
|
|
87
|
+
|
|
88
|
+
var _super = _createSuper(Image);
|
|
89
|
+
|
|
90
|
+
function Image(props) {
|
|
91
|
+
var _this;
|
|
92
|
+
|
|
93
|
+
_classCallCheck(this, Image);
|
|
94
|
+
|
|
95
|
+
_this = _super.call(this, props);
|
|
96
|
+
_this.state = {
|
|
97
|
+
isObjectFit: true,
|
|
98
|
+
isImgOnLoad: false
|
|
99
|
+
};
|
|
100
|
+
_this.handleImgOnLoad = _this._handleImgOnLoad.bind(_assertThisInitialized(_this));
|
|
101
|
+
_this.imgNode = null;
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_createClass(Image, [{
|
|
106
|
+
key: "componentDidMount",
|
|
107
|
+
value: function componentDidMount() {
|
|
108
|
+
this.setState({
|
|
109
|
+
isObjectFit: 'objectFit' in _.get(document, 'documentElement.style')
|
|
110
|
+
}); // Check if img is already loaded, and cached on the browser.
|
|
111
|
+
// If cached, React.img won't trigger onLoad event.
|
|
112
|
+
// Hence, we need to trigger re-rendering.
|
|
113
|
+
|
|
114
|
+
if (this.imgNode) {
|
|
115
|
+
this.setState({
|
|
116
|
+
isImgOnLoad: this.imgNode.complete
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "componentWillUnMount",
|
|
122
|
+
value: function componentWillUnMount() {
|
|
123
|
+
this.imgNode = null;
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "_handleImgOnLoad",
|
|
127
|
+
value: function _handleImgOnLoad() {
|
|
128
|
+
this.setState({
|
|
129
|
+
isImgOnLoad: true
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "render",
|
|
134
|
+
value: function render() {
|
|
135
|
+
var _this2 = this;
|
|
136
|
+
|
|
137
|
+
var _this$props = this.props,
|
|
138
|
+
src = _this$props.src,
|
|
139
|
+
alt = _this$props.alt,
|
|
140
|
+
srcSet = _this$props.srcSet;
|
|
141
|
+
var _this$state = this.state,
|
|
142
|
+
isObjectFit = _this$state.isObjectFit,
|
|
143
|
+
isImgOnLoad = _this$state.isImgOnLoad;
|
|
144
|
+
var logoDisplay = 'flex';
|
|
145
|
+
|
|
146
|
+
if (!isObjectFit) {
|
|
147
|
+
logoDisplay = 'none';
|
|
148
|
+
} else if (isImgOnLoad) {
|
|
149
|
+
logoDisplay = 'none';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var ImgJSX = isObjectFit ? /*#__PURE__*/_react["default"].createElement(ImgObjectFit, {
|
|
153
|
+
opacity: isImgOnLoad ? 1 : 0
|
|
154
|
+
}, /*#__PURE__*/_react["default"].createElement("img", {
|
|
155
|
+
ref: function ref(node) {
|
|
156
|
+
_this2.imgNode = node;
|
|
157
|
+
},
|
|
158
|
+
alt: alt,
|
|
159
|
+
src: (0, _storageUrlProcessor.replaceGCSUrlOrigin)(src),
|
|
160
|
+
srcSet: srcSet,
|
|
161
|
+
onLoad: this.handleImgOnLoad
|
|
162
|
+
})) : /*#__PURE__*/_react["default"].createElement(ImgFallback, {
|
|
163
|
+
url: (0, _storageUrlProcessor.replaceGCSUrlOrigin)(src)
|
|
164
|
+
});
|
|
165
|
+
return /*#__PURE__*/_react["default"].createElement(ImgContainer, null, /*#__PURE__*/_react["default"].createElement(LogoCenteringBlock, {
|
|
166
|
+
display: logoDisplay
|
|
167
|
+
}, /*#__PURE__*/_react["default"].createElement(LogoIcon, null)), ImgJSX);
|
|
168
|
+
}
|
|
169
|
+
}]);
|
|
170
|
+
|
|
171
|
+
return Image;
|
|
172
|
+
}(_react["default"].PureComponent);
|
|
173
|
+
|
|
174
|
+
Image.defaultProps = {
|
|
175
|
+
alt: '',
|
|
176
|
+
src: '',
|
|
177
|
+
srcSet: ''
|
|
178
|
+
};
|
|
179
|
+
Image.propTypes = {
|
|
180
|
+
alt: _propTypes["default"].string,
|
|
181
|
+
src: _propTypes["default"].string.isRequired,
|
|
182
|
+
srcSet: _propTypes["default"].string
|
|
183
|
+
};
|
|
184
|
+
var _default = Image;
|
|
185
|
+
exports["default"] = _default;
|