@twreporter/react-article-components 1.5.0-rc.1 → 1.5.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
# [1.5.0-rc.2](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-article-components@1.5.0-rc.1...@twreporter/react-article-components@1.5.0-rc.2) (2022-06-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* address review comment ([839e625](https://github.com/twreporter/twreporter-npm-packages/commit/839e625f0986212e415850f6c9db629be301f817))
|
|
12
|
+
* fix defect ([9345fc3](https://github.com/twreporter/twreporter-npm-packages/commit/9345fc3996427e90b6a3759ab7fd68efaa5f054b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [1.5.0-rc.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-article-components@1.5.0-rc.0...@twreporter/react-article-components@1.5.0-rc.1) (2022-06-14)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @twreporter/react-article-components
|
|
@@ -53,7 +53,7 @@ var _releaseBranch = _interopRequireDefault(require("@twreporter/core/lib/consta
|
|
|
53
53
|
|
|
54
54
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
55
55
|
|
|
56
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20
|
|
56
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20;
|
|
57
57
|
|
|
58
58
|
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); }
|
|
59
59
|
|
|
@@ -128,30 +128,30 @@ var MetadataAndToolsBlock = /*#__PURE__*/_styledComponents["default"].div.withCo
|
|
|
128
128
|
componentId: "sc-1wuywdb-6"
|
|
129
129
|
})(["", " ", " ", ""], _mediaQuery["default"].mobileOnly(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding-top: 40px;\n padding-bottom: 60px;\n "]))), _mediaQuery["default"].tabletOnly(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n padding-top: 60px;\n padding-bottom: 60px;\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
130
130
|
|
|
131
|
-
var
|
|
132
|
-
displayName: "article-
|
|
131
|
+
var DesktopToolsBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
132
|
+
displayName: "article-page__DesktopToolsBlock",
|
|
133
133
|
componentId: "sc-1wuywdb-7"
|
|
134
|
-
})(["", "
|
|
134
|
+
})(["", ""], _mediaQuery["default"].tabletAndBelow(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
135
135
|
|
|
136
136
|
var MobileToolBar = /*#__PURE__*/(0, _styledComponents["default"])(_mobileToolBar["default"]).withConfig({
|
|
137
137
|
displayName: "article-page__MobileToolBar",
|
|
138
138
|
componentId: "sc-1wuywdb-8"
|
|
139
|
-
})(["", ""], _mediaQuery["default"].desktopAndAbove(
|
|
139
|
+
})(["", ""], _mediaQuery["default"].desktopAndAbove(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
140
140
|
|
|
141
141
|
var ContentBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
142
142
|
displayName: "article-page__ContentBlock",
|
|
143
143
|
componentId: "sc-1wuywdb-9"
|
|
144
|
-
})(["margin:0 auto;", " ", " ", ""], _mediaQuery["default"].tabletAndBelow(
|
|
144
|
+
})(["margin:0 auto;", " ", " ", ""], _mediaQuery["default"].tabletAndBelow(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n ", "\n "])), shiftLeftCss), _mediaQuery["default"].desktopOnly(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n width: 550px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n width: 730px;\n "]))));
|
|
145
145
|
|
|
146
146
|
var StyledSeparationCurve = /*#__PURE__*/(0, _styledComponents["default"])(_separationCurve["default"]).withConfig({
|
|
147
147
|
displayName: "article-page__StyledSeparationCurve",
|
|
148
148
|
componentId: "sc-1wuywdb-10"
|
|
149
|
-
})(["", ""], _mediaQuery["default"].desktopAndAbove(
|
|
149
|
+
})(["", ""], _mediaQuery["default"].desktopAndAbove(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
150
150
|
|
|
151
151
|
var RelatedBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
152
152
|
displayName: "article-page__RelatedBlock",
|
|
153
153
|
componentId: "sc-1wuywdb-11"
|
|
154
|
-
})(["margin-left:auto;margin-right:auto;margin-bottom:0;width:100%;", " ", ""], _mediaQuery["default"].desktopOnly(
|
|
154
|
+
})(["margin-left:auto;margin-right:auto;margin-bottom:0;width:100%;", " ", ""], _mediaQuery["default"].desktopOnly(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n max-width: 1024px;\n margin-top: 60px;\n "]))), _mediaQuery["default"].hdOnly(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n max-width: 1440px;\n margin-top: 90px;\n "]))));
|
|
155
155
|
|
|
156
156
|
var BackgroundBlock = /*#__PURE__*/(0, _styledComponents["default"])(BorderBox).withConfig({
|
|
157
157
|
displayName: "article-page__BackgroundBlock",
|
|
@@ -343,7 +343,7 @@ var Article = /*#__PURE__*/function (_PureComponent) {
|
|
|
343
343
|
writers: post.writers,
|
|
344
344
|
engineers: post.engineers,
|
|
345
345
|
rawAutherText: post.extend_byline
|
|
346
|
-
}), /*#__PURE__*/_react["default"].createElement(
|
|
346
|
+
}), /*#__PURE__*/_react["default"].createElement(DesktopToolsBlock, null, /*#__PURE__*/_react["default"].createElement(_desktopTools["default"], {
|
|
347
347
|
articleMetaForBookmark: articleMetaForBookmark,
|
|
348
348
|
backToTopic: backToTopic,
|
|
349
349
|
onFontLevelChange: this.changeFontLevel
|
|
@@ -31,6 +31,8 @@ var _button = require("@twreporter/react-components/lib/button");
|
|
|
31
31
|
|
|
32
32
|
var _snackBar = require("@twreporter/react-components/lib/snack-bar");
|
|
33
33
|
|
|
34
|
+
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
35
|
+
|
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
37
|
|
|
36
38
|
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); }
|
|
@@ -53,7 +55,10 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
53
55
|
|
|
54
56
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
var _ = {
|
|
59
|
+
isNil: _isNil["default"]
|
|
60
|
+
}; // global var
|
|
61
|
+
|
|
57
62
|
var HideTextContext = /*#__PURE__*/(0, _react.createContext)();
|
|
58
63
|
var defaultFbAppID = '962589903815787';
|
|
59
64
|
|
|
@@ -67,7 +72,7 @@ var ButtonContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
67
72
|
var ShareContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
68
73
|
displayName: "mobile-tool-bar__ShareContainer",
|
|
69
74
|
componentId: "do65sv-1"
|
|
70
|
-
})(["display:flex;align-items:center;padding:8px;margin-right:8px
|
|
75
|
+
})(["display:flex;align-items:center;padding:8px;border-radius:50%;margin-right:8px;&:last-child{margin-right:0;}"]);
|
|
71
76
|
|
|
72
77
|
var OptionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
73
78
|
displayName: "mobile-tool-bar__OptionContainer",
|
|
@@ -79,25 +84,44 @@ var OptionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
79
84
|
var SnackBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
80
85
|
displayName: "mobile-tool-bar__SnackBarContainer",
|
|
81
86
|
componentId: "do65sv-3"
|
|
82
|
-
})(["opacity:", ";position:absolute;left:50%;
|
|
87
|
+
})(["opacity:", ";position:absolute;left:50%;transform:translateX(-50%);transition:opacity 100ms;"], function (props) {
|
|
83
88
|
return props.showSnackBar ? '1' : '0';
|
|
84
89
|
});
|
|
85
90
|
|
|
86
91
|
var ToolBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
87
92
|
displayName: "mobile-tool-bar__ToolBarContainer",
|
|
88
93
|
componentId: "do65sv-4"
|
|
89
|
-
})(["display:flex;align-items:center;width:fit-content;background-color:", ";padding:
|
|
94
|
+
})(["display:flex;align-items:center;width:fit-content;background-color:", ";padding:0 16px;border-radius:60px;position:fixed;left:50%;transform:translate(-50%,0);bottom:calc(env(safe-area-inset-bottom,0) + 8px);z-index:999;height:", ";transition:height 100ms;box-shadow:", ";", "{background-color:", ";box-shadow:", ";}", "{bottom:", ";}"], function (props) {
|
|
90
95
|
return props.bgColor;
|
|
91
96
|
}, function (props) {
|
|
92
|
-
return props.hideText ? '
|
|
97
|
+
return props.hideText ? '38px' : '56px';
|
|
93
98
|
}, function (props) {
|
|
94
99
|
return props.shadow;
|
|
95
100
|
}, ShareContainer, function (props) {
|
|
96
101
|
return props.bgColor;
|
|
97
102
|
}, function (props) {
|
|
98
103
|
return props.shadow;
|
|
104
|
+
}, SnackBarContainer, function (props) {
|
|
105
|
+
return props.hideText ? '46px' : '64px';
|
|
99
106
|
});
|
|
100
107
|
|
|
108
|
+
var useOutsideClick = function useOutsideClick(callback) {
|
|
109
|
+
var ref = (0, _react.useRef)();
|
|
110
|
+
(0, _react.useEffect)(function () {
|
|
111
|
+
var handleClick = function handleClick(event) {
|
|
112
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
113
|
+
callback(event);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
document.addEventListener('click', handleClick);
|
|
118
|
+
return function () {
|
|
119
|
+
document.removeEventListener('click', handleClick);
|
|
120
|
+
};
|
|
121
|
+
}, [ref]);
|
|
122
|
+
return ref;
|
|
123
|
+
};
|
|
124
|
+
|
|
101
125
|
var FbShare = function FbShare(_ref) {
|
|
102
126
|
var appID = _ref.appID;
|
|
103
127
|
var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
@@ -260,7 +284,13 @@ var ShareBy = function ShareBy(_ref4) {
|
|
|
260
284
|
});
|
|
261
285
|
};
|
|
262
286
|
|
|
287
|
+
var onClickOutside = function onClickOutside() {
|
|
288
|
+
return setShowState(false);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
var ref = useOutsideClick(onClickOutside);
|
|
263
292
|
return /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
293
|
+
ref: ref,
|
|
264
294
|
onClick: onButtonClick
|
|
265
295
|
}, /*#__PURE__*/_react["default"].createElement(_button.IconWithTextButton, {
|
|
266
296
|
text: "\u5206\u4EAB",
|
|
@@ -318,10 +348,11 @@ var BookmarkBlock = function BookmarkBlock(_ref6) {
|
|
|
318
348
|
|
|
319
349
|
var renderIcon = function renderIcon(isBookmarked, addAction, removeAction) {
|
|
320
350
|
var iconType = isBookmarked ? 'saved' : 'add';
|
|
351
|
+
var text = isBookmarked ? '已儲存' : '加入書籤';
|
|
321
352
|
return /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
322
353
|
onClick: isBookmarked ? removeAction : addAction
|
|
323
354
|
}, /*#__PURE__*/_react["default"].createElement(_button.IconWithTextButton, {
|
|
324
|
-
text:
|
|
355
|
+
text: text,
|
|
325
356
|
iconComponent: /*#__PURE__*/_react["default"].createElement(_icon.Bookmark, {
|
|
326
357
|
type: iconType,
|
|
327
358
|
releaseBranch: releaseBranch
|
|
@@ -374,7 +405,9 @@ var RelatedPost = function RelatedPost() {
|
|
|
374
405
|
var releaseBranch = themeContext.releaseBranch;
|
|
375
406
|
|
|
376
407
|
var scrollToBottom = function scrollToBottom() {
|
|
377
|
-
document.getElementById(_anchor.relatedPostAnchor).scrollIntoView(
|
|
408
|
+
document.getElementById(_anchor.relatedPostAnchor).scrollIntoView({
|
|
409
|
+
behavior: 'smooth'
|
|
410
|
+
});
|
|
378
411
|
};
|
|
379
412
|
|
|
380
413
|
return /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
@@ -410,6 +443,11 @@ var ToolBar = function ToolBar(_ref8) {
|
|
|
410
443
|
var updateScrollDirection = function updateScrollDirection() {
|
|
411
444
|
var scrollY = window.pageYOffset;
|
|
412
445
|
|
|
446
|
+
if (_.isNil(lastScrollY)) {
|
|
447
|
+
ticking = false;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
|
|
413
451
|
if (Math.abs(scrollY - lastScrollY) < threshold) {
|
|
414
452
|
ticking = false;
|
|
415
453
|
return;
|
|
@@ -441,7 +479,9 @@ var ToolBar = function ToolBar(_ref8) {
|
|
|
441
479
|
bgColor = _getToolBarTheme.bgColor,
|
|
442
480
|
shadow = _getToolBarTheme.shadow;
|
|
443
481
|
|
|
444
|
-
var backToTopicJSX = backToTopic ? /*#__PURE__*/_react["default"].createElement(BackToTopic,
|
|
482
|
+
var backToTopicJSX = backToTopic ? /*#__PURE__*/_react["default"].createElement(BackToTopic, {
|
|
483
|
+
backToTopic: backToTopic
|
|
484
|
+
}) : null;
|
|
445
485
|
var hideText = scrollDirection === 'down';
|
|
446
486
|
return /*#__PURE__*/_react["default"].createElement(HideTextContext.Provider, {
|
|
447
487
|
value: hideText
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twreporter/react-article-components",
|
|
3
|
-
"version": "1.5.0-rc.
|
|
3
|
+
"version": "1.5.0-rc.2",
|
|
4
4
|
"description": "The Reporter react article components, which are used in article page",
|
|
5
5
|
"main": "lib/components/article-page.js",
|
|
6
6
|
"repository": "https://github.com/twreporter/twreporter-npm-packages.git",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"files": [
|
|
40
40
|
"lib"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0c1c304760a2d20f3873ccc7d44501a8ba8b661f"
|
|
43
43
|
}
|