@twreporter/react-article-components 2.2.0-rc.0 → 2.2.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 +8 -0
- package/lib/components/article-page.js +39 -108
- package/lib/components/aside/desktop-aside.js +25 -65
- package/lib/components/aside/desktop-tools.js +11 -57
- package/lib/components/aside/metadata.js +22 -89
- package/lib/components/aside/mobile-tool-bar.js +79 -175
- package/lib/components/aside/utils/theme.js +5 -11
- package/lib/components/body/annotation.js +15 -73
- package/lib/components/body/audio/audio-contexts.js +4 -16
- package/lib/components/body/audio/audio-provider.js +13 -48
- package/lib/components/body/audio/control-button.js +4 -28
- package/lib/components/body/audio/index.js +10 -56
- package/lib/components/body/audio/seek-bar.js +6 -23
- package/lib/components/body/audio/time.js +0 -6
- package/lib/components/body/blockquote.js +11 -52
- package/lib/components/body/brief.js +10 -55
- package/lib/components/body/centered-quote.js +10 -52
- package/lib/components/body/embedded-code.js +22 -101
- package/lib/components/body/headings.js +6 -23
- package/lib/components/body/image-diff.js +13 -66
- package/lib/components/body/image.js +11 -46
- package/lib/components/body/index.js +21 -118
- package/lib/components/body/infobox.js +13 -58
- package/lib/components/body/list.js +8 -29
- package/lib/components/body/multimedia.js +10 -29
- package/lib/components/body/paragraph.js +5 -23
- package/lib/components/body/slider/index.js +28 -96
- package/lib/components/body/slideshow/index.js +36 -107
- package/lib/components/body/tracking-section.js +7 -46
- package/lib/components/body/youtube.js +8 -41
- package/lib/components/donation-box.js +10 -44
- package/lib/components/img-with-placeholder/index.js +34 -106
- package/lib/components/leading/extend.js +6 -25
- package/lib/components/leading/fullscreen.js +17 -63
- package/lib/components/leading/index.js +2 -10
- package/lib/components/leading/normal.js +19 -64
- package/lib/components/leading/pink.js +20 -59
- package/lib/components/leading/small.js +6 -25
- package/lib/components/license.js +9 -40
- package/lib/components/link.js +8 -37
- package/lib/components/related/card.js +20 -73
- package/lib/components/related/index.js +25 -71
- package/lib/components/related/list.js +16 -70
- package/lib/components/related/mockup.js +10 -12
- package/lib/components/separation-curve.js +0 -15
- package/lib/components/table-of-contents/index.js +17 -46
- package/lib/components/table-of-contents/styled.js +10 -38
- package/lib/constants/anchor.js +4 -8
- package/lib/constants/css.js +2 -15
- package/lib/constants/element-alignment.js +2 -3
- package/lib/constants/prop-types/article-page.js +2 -7
- package/lib/constants/prop-types/aside.js +2 -8
- package/lib/constants/prop-types/body.js +4 -9
- package/lib/constants/prop-types/img-with-placeholder.js +2 -7
- package/lib/constants/prop-types/leading.js +8 -13
- package/lib/constants/prop-types/related.js +2 -7
- package/lib/constants/theme.js +2 -3
- package/lib/constants/typography.js +2 -5
- package/lib/contexts/dynamic-components-context.js +2 -8
- package/lib/managers/layout-manager.js +13 -28
- package/lib/managers/theme-manager.js +13 -32
- package/lib/managers/ui-manager.js +14 -26
- package/lib/utils/image.js +5 -14
- package/package.json +6 -6
|
@@ -1,78 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _imgWithPlaceholder = _interopRequireDefault(require("../img-with-placeholder"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _mockup = _interopRequireDefault(require("./mockup"));
|
|
15
|
-
|
|
16
11
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
17
|
-
|
|
18
12
|
var _related = _interopRequireDefault(require("../../constants/prop-types/related"));
|
|
19
|
-
|
|
20
13
|
var _react = _interopRequireDefault(require("react"));
|
|
21
|
-
|
|
22
14
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
|
-
|
|
24
15
|
var _theme = _interopRequireDefault(require("../../constants/theme"));
|
|
25
|
-
|
|
26
16
|
var _typography = _interopRequireDefault(require("../../constants/typography"));
|
|
27
|
-
|
|
28
17
|
var _color = require("@twreporter/core/lib/constants/color");
|
|
29
|
-
|
|
30
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
36
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
-
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
42
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
43
|
-
|
|
44
|
-
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); } }
|
|
45
|
-
|
|
25
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
46
26
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
47
|
-
|
|
48
27
|
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
49
|
-
|
|
50
28
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
51
|
-
|
|
52
29
|
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); }; }
|
|
53
|
-
|
|
54
30
|
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); }
|
|
55
|
-
|
|
56
31
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
|
-
|
|
58
32
|
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; } }
|
|
59
|
-
|
|
60
33
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
|
|
34
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
36
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
64
37
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
65
|
-
|
|
66
38
|
var StyledImg = /*#__PURE__*/(0, _styledComponents["default"])(_imgWithPlaceholder["default"]).withConfig({
|
|
67
39
|
displayName: "card__StyledImg",
|
|
68
40
|
componentId: "uveoih-0"
|
|
69
41
|
})([""]);
|
|
70
|
-
|
|
71
42
|
var DescBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
72
43
|
displayName: "card__DescBlock",
|
|
73
44
|
componentId: "uveoih-1"
|
|
74
45
|
})(["position:relative;", ""], _mediaQuery["default"].tabletAndBelow(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
75
|
-
|
|
76
46
|
var Desc = /*#__PURE__*/_styledComponents["default"].p.withConfig({
|
|
77
47
|
displayName: "card__Desc",
|
|
78
48
|
componentId: "uveoih-2"
|
|
@@ -83,37 +53,30 @@ var Desc = /*#__PURE__*/_styledComponents["default"].p.withConfig({
|
|
|
83
53
|
}, function (props) {
|
|
84
54
|
return props.$isHovered ? 'static' : 'absolute';
|
|
85
55
|
}, _color.colorGrayscale.gray600);
|
|
86
|
-
|
|
87
56
|
var Thumbnail = /*#__PURE__*/_styledComponents["default"].figure.withConfig({
|
|
88
57
|
displayName: "card__Thumbnail",
|
|
89
58
|
componentId: "uveoih-3"
|
|
90
59
|
})(["margin:0;", " ", " ", " ", " ", ""], _mediaQuery["default"].tabletAndBelow(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n order: 2;\n "]))), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n "])), _mockup["default"].mobile.thumbnail.width, _mockup["default"].mobile.thumbnail.height), _mediaQuery["default"].tabletOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n "])), _mockup["default"].tablet.thumbnail.width, _mockup["default"].tablet.thumbnail.height), _mediaQuery["default"].desktopOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n width: 100%;\n height: ", "px;\n "])), _mockup["default"].desktop.thumbnail.height), _mediaQuery["default"].hdOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: 100%;\n height: ", "px;\n "])), _mockup["default"].hd.thumbnail.height));
|
|
91
|
-
|
|
92
60
|
var DesktopTextBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
93
61
|
displayName: "card__DesktopTextBlock",
|
|
94
62
|
componentId: "uveoih-4"
|
|
95
63
|
})(["padding:10px 19px 45px 5px;", ""], _mediaQuery["default"].tabletAndBelow(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
96
|
-
|
|
97
64
|
var MobileTextBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
98
65
|
displayName: "card__MobileTextBlock",
|
|
99
66
|
componentId: "uveoih-5"
|
|
100
67
|
})(["", " ", ""], _mediaQuery["default"].tabletAndBelow(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n max-width: 62%;\n order: 1;\n padding: 0;\n display: flex;\n flex-direction: column;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
101
|
-
|
|
102
68
|
var Category = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
103
69
|
displayName: "card__Category",
|
|
104
70
|
componentId: "uveoih-6"
|
|
105
71
|
})(["font-size:14px;font-weight:", ";line-height:1.43;margin-right:10px;", ""], _typography["default"].font.weight.bold, _mediaQuery["default"].tabletAndBelow(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n order: 1;\n "]))));
|
|
106
|
-
|
|
107
72
|
var Title = /*#__PURE__*/_styledComponents["default"].h3.withConfig({
|
|
108
73
|
displayName: "card__Title",
|
|
109
74
|
componentId: "uveoih-7"
|
|
110
75
|
})(["font-size:16px;font-weight:", ";font-family:", ";line-height:1.5;margin:5px 0 10px 0;", ""], _typography["default"].font.weight.bold, _typography["default"].font.family.title, _mediaQuery["default"].tabletAndBelow(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n order: 2;\n margin-bottom: 15px;\n "]))));
|
|
111
|
-
|
|
112
76
|
var PublishedDate = /*#__PURE__*/_styledComponents["default"].p.withConfig({
|
|
113
77
|
displayName: "card__PublishedDate",
|
|
114
78
|
componentId: "uveoih-8"
|
|
115
79
|
})(["margin:0;font-size:12px;line-height:2;color:", ";", " ", ""], _color.colorGrayscale.gray500, _mediaQuery["default"].desktopAndAbove(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n position: absolute;\n left: 5px;\n bottom: 15px;\n "]))), _mediaQuery["default"].tabletAndBelow(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n order: 3;\n "]))));
|
|
116
|
-
|
|
117
80
|
var Block = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
118
81
|
displayName: "card__Block",
|
|
119
82
|
componentId: "uveoih-9"
|
|
@@ -122,40 +85,32 @@ var Block = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
122
85
|
}, function (props) {
|
|
123
86
|
return props.$height;
|
|
124
87
|
}, _mediaQuery["default"].tabletAndBelow(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n height: auto;\n width: 100%;\n min-height: 152px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n "]))), _mediaQuery["default"].desktopOnly(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockup["default"].desktop.thumbnail.width), _mediaQuery["default"].hdOnly(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), _mockup["default"].hd.thumbnail.width));
|
|
125
|
-
|
|
126
88
|
function getBlockStyles(themeName) {
|
|
127
89
|
switch (themeName) {
|
|
128
90
|
case _theme["default"].article.v2.photo:
|
|
129
91
|
return (0, _styledComponents.css)(["", "{color:", ";}", "{color:", ";}", "{background-color:", ";}"], Category, _color.colorSupportive.main, Title, _color.colorGrayscale.gray300, StyledImg, _color.colorGrayscale.gray400);
|
|
130
|
-
|
|
131
92
|
case _theme["default"].article.v2.pink:
|
|
132
93
|
return (0, _styledComponents.css)(["", "{color:", ";}", "{color:", ";}", "{background-color:", ";}"], Category, _color.COLOR_PINK_ARTICLE.darkPink, Title, _color.colorGrayscale.gray800, StyledImg, _color.colorGrayscale.gray200);
|
|
133
|
-
|
|
134
94
|
case _theme["default"].article.v2["default"]:
|
|
135
95
|
default:
|
|
136
96
|
return (0, _styledComponents.css)(["", "{color:", ";}", "{color:", ";}", "{background-color:", ";}"], Category, _color.colorSupportive.heavy, Title, _color.colorGrayscale.gray800, StyledImg, _color.colorGrayscale.gray200);
|
|
137
97
|
}
|
|
138
98
|
}
|
|
139
|
-
|
|
140
99
|
var _defaultHeight = '100%';
|
|
141
|
-
|
|
142
100
|
var Card = /*#__PURE__*/function (_React$PureComponent) {
|
|
143
101
|
_inherits(Card, _React$PureComponent);
|
|
144
|
-
|
|
145
102
|
var _super = _createSuper(Card);
|
|
146
|
-
|
|
147
103
|
function Card(props) {
|
|
148
104
|
var _this;
|
|
149
|
-
|
|
150
105
|
_classCallCheck(this, Card);
|
|
106
|
+
_this = _super.call(this, props);
|
|
151
107
|
|
|
152
|
-
|
|
108
|
+
// state.heightBeforeHovering,
|
|
153
109
|
// state.heightAfterHovering,
|
|
154
110
|
// _blockRef,
|
|
155
111
|
// _descRef,
|
|
156
112
|
// are used for computing Card animation details,
|
|
157
113
|
// only for desktop and above layout
|
|
158
|
-
|
|
159
114
|
_this.state = {
|
|
160
115
|
heightBeforeHovering: _defaultHeight,
|
|
161
116
|
heightAfterHovering: _defaultHeight,
|
|
@@ -170,7 +125,6 @@ var Card = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
170
125
|
_this.handleMouseLeaveTextBlock = _this._handleIsHovered.bind(_assertThisInitialized(_this), false);
|
|
171
126
|
return _this;
|
|
172
127
|
}
|
|
173
|
-
|
|
174
128
|
_createClass(Card, [{
|
|
175
129
|
key: "componentDidMount",
|
|
176
130
|
value: function componentDidMount() {
|
|
@@ -195,22 +149,20 @@ var Card = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
195
149
|
key: "render",
|
|
196
150
|
value: function render() {
|
|
197
151
|
var _this$props = this.props,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
152
|
+
category = _this$props.category,
|
|
153
|
+
title = _this$props.title,
|
|
154
|
+
desc = _this$props.desc,
|
|
155
|
+
publishedDate = _this$props.publishedDate,
|
|
156
|
+
thumbnail = _this$props.thumbnail;
|
|
203
157
|
var dateStr = '';
|
|
204
|
-
|
|
205
158
|
if (publishedDate) {
|
|
206
159
|
var date = new Date(publishedDate);
|
|
207
160
|
dateStr = "".concat(date.getFullYear(), "/").concat(date.getMonth() + 1, "/").concat(date.getDate());
|
|
208
161
|
}
|
|
209
|
-
|
|
210
162
|
var _this$state = this.state,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
163
|
+
heightBeforeHovering = _this$state.heightBeforeHovering,
|
|
164
|
+
heightAfterHovering = _this$state.heightAfterHovering,
|
|
165
|
+
isHovered = _this$state.isHovered;
|
|
214
166
|
var categoryJSX = category ? /*#__PURE__*/_react["default"].createElement(Category, null, category) : null;
|
|
215
167
|
var titleJSX = title ? /*#__PURE__*/_react["default"].createElement(Title, null, title) : null;
|
|
216
168
|
var dateJSX = dateStr ? /*#__PURE__*/_react["default"].createElement(PublishedDate, null, dateStr) : null;
|
|
@@ -231,17 +183,12 @@ var Card = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
231
183
|
}, desc)), dateJSX), /*#__PURE__*/_react["default"].createElement(MobileTextBlock, null, categoryJSX, titleJSX, dateJSX));
|
|
232
184
|
}
|
|
233
185
|
}]);
|
|
234
|
-
|
|
235
186
|
return Card;
|
|
236
187
|
}(_react["default"].PureComponent);
|
|
237
|
-
|
|
238
188
|
_defineProperty(Card, "propTypes", _objectSpread(_objectSpread({}, _related["default"].card), {}, {
|
|
239
189
|
handleMounted: _propTypes["default"].func
|
|
240
190
|
}));
|
|
241
|
-
|
|
242
191
|
_defineProperty(Card, "defaultProps", {
|
|
243
192
|
handleMounted: function handleMounted() {}
|
|
244
193
|
});
|
|
245
|
-
|
|
246
|
-
var _default = Card;
|
|
247
|
-
exports["default"] = _default;
|
|
194
|
+
var _default = exports["default"] = Card;
|
|
@@ -1,68 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
15
|
-
|
|
16
11
|
var _list = _interopRequireDefault(require("./list"));
|
|
17
|
-
|
|
18
12
|
var _theme = _interopRequireDefault(require("../../constants/theme"));
|
|
19
|
-
|
|
20
13
|
var _typography = _interopRequireDefault(require("../../constants/typography"));
|
|
21
|
-
|
|
22
14
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
23
|
-
|
|
24
15
|
var _color = require("@twreporter/core/lib/constants/color");
|
|
25
|
-
|
|
26
16
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
27
|
-
|
|
28
17
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
29
|
-
|
|
30
18
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
31
|
-
|
|
32
19
|
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function _interopRequireWildcard(
|
|
39
|
-
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11; // components
|
|
21
|
+
// constants
|
|
22
|
+
// @twreporter
|
|
23
|
+
// lodash
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
40
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
41
|
-
|
|
42
27
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
43
|
-
|
|
44
|
-
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); } }
|
|
45
|
-
|
|
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
46
29
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
47
|
-
|
|
48
30
|
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
49
|
-
|
|
50
31
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
51
|
-
|
|
52
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); }; }
|
|
53
|
-
|
|
54
33
|
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); }
|
|
55
|
-
|
|
56
34
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
|
-
|
|
58
35
|
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; } }
|
|
59
|
-
|
|
60
36
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
|
|
37
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
38
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
39
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
64
40
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
65
|
-
|
|
66
41
|
var _ = {
|
|
67
42
|
debounce: _debounce["default"],
|
|
68
43
|
get: _get["default"],
|
|
@@ -72,12 +47,10 @@ var _ = {
|
|
|
72
47
|
var _articleStyles = {
|
|
73
48
|
interactive: 'interactive'
|
|
74
49
|
};
|
|
75
|
-
|
|
76
50
|
var Block = /*#__PURE__*/_styledComponents["default"].section.withConfig({
|
|
77
51
|
displayName: "related__Block",
|
|
78
52
|
componentId: "sc-1m76x7g-0"
|
|
79
53
|
})(["", " ", " ", ""], _mediaQuery["default"].desktopAndAbove(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n "]))), _mediaQuery["default"].desktopOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-left: 28px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: 53px;\n "]))));
|
|
80
|
-
|
|
81
54
|
var Descriptor = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
82
55
|
displayName: "related__Descriptor",
|
|
83
56
|
componentId: "sc-1m76x7g-1"
|
|
@@ -85,40 +58,33 @@ var Descriptor = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
85
58
|
switch (props.theme.name) {
|
|
86
59
|
case _theme["default"].article.v2.photo:
|
|
87
60
|
return (0, _styledComponents.css)(["color:", ";", ""], _color.colorGrayscale.gray600, _mediaQuery["default"].desktopAndAbove(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-color: ", ";\n &::after {\n border-color: ", ";\n }\n "])), _color.colorGrayscale.gray400, _color.colorGrayscale.gray400));
|
|
88
|
-
|
|
89
61
|
case _theme["default"].article.v2.pink:
|
|
90
62
|
case _theme["default"].article.v2["default"]:
|
|
91
63
|
default:
|
|
92
64
|
return (0, _styledComponents.css)(["color:", ";", ""], _color.colorGrayscale.gray600, _mediaQuery["default"].desktopAndAbove(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-color: ", ";\n &::after {\n border-color: ", ";\n }\n "])), _color.colorGrayscale.gray300, _color.colorGrayscale.gray300));
|
|
93
65
|
}
|
|
94
66
|
}, _mediaQuery["default"].tabletAndBelow(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin: 0 auto 40px auto;\n font-size: 20px;\n font-weigth: ", ";\n\n &:before {\n content: '\u76F8\u95DC\u6587\u7AE0';\n }\n "])), _typography["default"].font.weight.bold), _mediaQuery["default"].mobileOnly(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n width: calc(309/355*100%);\n "]))), _mediaQuery["default"].tabletOnly(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 513px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n font-size: 16px;\n font-weigth: ", ";\n line-height: 1.5;\n letter-spacing: 0.4px;\n margin-right: auto;\n padding-top: 5px;\n border-width: 0.5px 0 0 0;\n border-style: solid;\n position: relative;\n\n &::before {\n content: '\u76F8\u95DC\u6587\u7AE0';\n margin-left: 5px;\n margin-top: 5px;\n }\n\n &::after {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n width: 1px;\n height: 12px;\n border-width: 0 0.5px 0 0;\n border-style: solid;\n }\n "])), _typography["default"].font.weight.bold), _mediaQuery["default"].desktopOnly(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n width: 180px;\n margin-right: 15px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n width: 250px;\n margin-right: 12px;\n "]))));
|
|
95
|
-
|
|
96
67
|
var screen = {
|
|
97
68
|
mobile: 768,
|
|
98
69
|
destkop: 1024,
|
|
99
70
|
hd: 1440
|
|
100
71
|
};
|
|
101
|
-
|
|
102
|
-
var Related = /*#__PURE__*/function (_React$PureComponent) {
|
|
72
|
+
var Related = exports["default"] = /*#__PURE__*/function (_React$PureComponent) {
|
|
103
73
|
_inherits(Related, _React$PureComponent);
|
|
104
|
-
|
|
105
74
|
var _super = _createSuper(Related);
|
|
106
|
-
|
|
107
75
|
function Related(props) {
|
|
108
76
|
var _this;
|
|
109
|
-
|
|
110
77
|
_classCallCheck(this, Related);
|
|
111
|
-
|
|
112
78
|
_this = _super.call(this, props);
|
|
113
|
-
|
|
114
79
|
_defineProperty(_assertThisInitialized(_this), "_handleWindowResize", function () {
|
|
115
80
|
var curWindowWidth = window.innerWidth;
|
|
116
|
-
var lastWindowWidth;
|
|
81
|
+
var lastWindowWidth;
|
|
82
|
+
|
|
83
|
+
// The following conditions are set for performance.
|
|
117
84
|
// Since we only have three different device layout,
|
|
118
85
|
// including mobile, desktop and hd,
|
|
119
86
|
// we are not going to re-render `List` component
|
|
120
87
|
// unless the resize events cause the layout change.
|
|
121
|
-
|
|
122
88
|
if (curWindowWidth < screen.destkop) {
|
|
123
89
|
lastWindowWidth = screen.mobile;
|
|
124
90
|
} else if (curWindowWidth < screen.hd) {
|
|
@@ -126,19 +92,16 @@ var Related = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
126
92
|
} else {
|
|
127
93
|
lastWindowWidth = screen.hd;
|
|
128
94
|
}
|
|
129
|
-
|
|
130
95
|
_this.setState({
|
|
131
96
|
lastWindowWidth: lastWindowWidth
|
|
132
97
|
});
|
|
133
98
|
});
|
|
134
|
-
|
|
135
99
|
_this.state = {
|
|
136
100
|
lastWindowWidth: 0
|
|
137
101
|
};
|
|
138
102
|
_this.handleWindowResize = _.debounce(_this._handleWindowResize, 500).bind(_assertThisInitialized(_this));
|
|
139
103
|
return _this;
|
|
140
104
|
}
|
|
141
|
-
|
|
142
105
|
_createClass(Related, [{
|
|
143
106
|
key: "componentDidMount",
|
|
144
107
|
value: function componentDidMount() {
|
|
@@ -153,17 +116,15 @@ var Related = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
153
116
|
key: "_buildRelated",
|
|
154
117
|
value: function _buildRelated(related) {
|
|
155
118
|
var style = _.get(related, 'style');
|
|
156
|
-
|
|
157
119
|
var prefixPath = style === _articleStyles.interactive ? '/i/' : '/a/';
|
|
158
|
-
var categories = related.categories;
|
|
120
|
+
var categories = related.categories;
|
|
121
|
+
// sort categories in ascending order
|
|
122
|
+
_.sortBy(categories, ['sort_order']);
|
|
159
123
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var imageSet = _.get(related, 'og_image.resized_targets', {}); // use `w400` image set first
|
|
124
|
+
// use og_image first
|
|
125
|
+
var imageSet = _.get(related, 'og_image.resized_targets', {});
|
|
126
|
+
// use `w400` image set first
|
|
164
127
|
// if `w400` is not provided, then use `mobile` image set
|
|
165
|
-
|
|
166
|
-
|
|
167
128
|
var thumbnail = _.get(imageSet, 'w400.url') ? imageSet.w400 : imageSet.mobile;
|
|
168
129
|
return {
|
|
169
130
|
category: _.get(categories, '0.name', ''),
|
|
@@ -182,14 +143,12 @@ var Related = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
182
143
|
key: "render",
|
|
183
144
|
value: function render() {
|
|
184
145
|
var _this$props = this.props,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
146
|
+
data = _this$props.data,
|
|
147
|
+
hasMore = _this$props.hasMore,
|
|
148
|
+
id = _this$props.id,
|
|
149
|
+
loadMore = _this$props.loadMore;
|
|
189
150
|
var lastWindowWidth = this.state.lastWindowWidth;
|
|
190
|
-
|
|
191
151
|
var relateds = _.map(data, this._buildRelated);
|
|
192
|
-
|
|
193
152
|
return /*#__PURE__*/_react["default"].createElement(Block, null, /*#__PURE__*/_react["default"].createElement(Descriptor, null), /*#__PURE__*/_react["default"].createElement(_list["default"], {
|
|
194
153
|
key: "".concat(id, "-with-list-width-").concat(lastWindowWidth),
|
|
195
154
|
data: relateds,
|
|
@@ -198,19 +157,14 @@ var Related = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
198
157
|
}));
|
|
199
158
|
}
|
|
200
159
|
}]);
|
|
201
|
-
|
|
202
160
|
return Related;
|
|
203
161
|
}(_react["default"].PureComponent);
|
|
204
|
-
|
|
205
|
-
exports["default"] = Related;
|
|
206
|
-
|
|
207
162
|
_defineProperty(Related, "propTypes", {
|
|
208
163
|
data: _propTypes["default"].array,
|
|
209
164
|
hasMore: _propTypes["default"].bool,
|
|
210
165
|
id: _propTypes["default"].string,
|
|
211
166
|
loadMore: _propTypes["default"].func.isRequired
|
|
212
167
|
});
|
|
213
|
-
|
|
214
168
|
_defineProperty(Related, "defaultProps", {
|
|
215
169
|
data: [],
|
|
216
170
|
hasMore: false
|