@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,251 @@
|
|
|
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 _date = require("@twreporter/core/lib/utils/date");
|
|
11
|
+
|
|
12
|
+
var _fontWeight = require("@twreporter/core/lib/constants/font-weight");
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("@twreporter/core/lib/constants/prop-types"));
|
|
15
|
+
|
|
16
|
+
var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
17
|
+
|
|
18
|
+
var _imageWrapper = _interopRequireDefault(require("./image-wrapper"));
|
|
19
|
+
|
|
20
|
+
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
21
|
+
|
|
22
|
+
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
27
|
+
|
|
28
|
+
var _truncate = _interopRequireDefault(require("@twreporter/core/lib/utils/truncate"));
|
|
29
|
+
|
|
30
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
33
|
+
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
|
+
|
|
36
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
+
|
|
38
|
+
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); } }
|
|
39
|
+
|
|
40
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
+
|
|
42
|
+
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); }
|
|
43
|
+
|
|
44
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
+
|
|
46
|
+
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); }; }
|
|
47
|
+
|
|
48
|
+
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); }
|
|
49
|
+
|
|
50
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
+
|
|
52
|
+
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; } }
|
|
53
|
+
|
|
54
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
+
|
|
56
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
|
+
|
|
58
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
59
|
+
|
|
60
|
+
var BookmarkIcon = function BookmarkIcon(props) {
|
|
61
|
+
return /*#__PURE__*/_react["default"].createElement("svg", props, /*#__PURE__*/_react["default"].createElement("path", {
|
|
62
|
+
d: "M14.666 23.217l-7.161-4.924-7.16 4.924A.22.22 0 0 1 0 23.036V1.499A1.5 1.5 0 0 1 1.5 0h12.012a1.5 1.5 0 0 1 1.498 1.5v21.536a.22.22 0 0 1-.344.18",
|
|
63
|
+
fill: "#C7000D",
|
|
64
|
+
fillRule: "evenodd"
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
BookmarkIcon.defaultProps = {
|
|
69
|
+
width: "16",
|
|
70
|
+
height: "24",
|
|
71
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
72
|
+
};
|
|
73
|
+
var _ = {
|
|
74
|
+
get: _get["default"]
|
|
75
|
+
};
|
|
76
|
+
var READ_MORE = '閱讀更多...';
|
|
77
|
+
var styles = {
|
|
78
|
+
desktop: {
|
|
79
|
+
imageWidth: 209,
|
|
80
|
+
// px
|
|
81
|
+
imageHeight: 209,
|
|
82
|
+
// px
|
|
83
|
+
imageBoxPadding: [32, 32, 35, 20],
|
|
84
|
+
// px
|
|
85
|
+
textBoxPadding: [32, 32, 35, 0] // px
|
|
86
|
+
|
|
87
|
+
},
|
|
88
|
+
tablet: {
|
|
89
|
+
imageWidth: 181,
|
|
90
|
+
// px
|
|
91
|
+
imageHeight: 181,
|
|
92
|
+
// px
|
|
93
|
+
imageBoxPadding: [32, 32, 35, 20],
|
|
94
|
+
// px
|
|
95
|
+
textBoxPadding: [32, 32, 35, 0] // px
|
|
96
|
+
|
|
97
|
+
},
|
|
98
|
+
mobile: {
|
|
99
|
+
imageHeight: 121,
|
|
100
|
+
// px
|
|
101
|
+
imageBoxPadding: [22, 22, 22, 22],
|
|
102
|
+
// px
|
|
103
|
+
textBoxPadding: [0, 21, 26, 21] // px
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var BookmarkIconComp = /*#__PURE__*/(0, _styledComponents["default"])(BookmarkIcon).withConfig({
|
|
108
|
+
displayName: "bookmark__BookmarkIconComp",
|
|
109
|
+
componentId: "sc-1y8p1w5-0"
|
|
110
|
+
})(["&:hover{path{fill:#99000a;transition:fill 200ms linear;}}"]);
|
|
111
|
+
|
|
112
|
+
var BookmarkFrame = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
113
|
+
displayName: "bookmark__BookmarkFrame",
|
|
114
|
+
componentId: "sc-1y8p1w5-1"
|
|
115
|
+
})(["margin:0;margin-bottom:15px;"]);
|
|
116
|
+
|
|
117
|
+
var BookmarkContentContainer = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
118
|
+
displayName: "bookmark__BookmarkContentContainer",
|
|
119
|
+
componentId: "sc-1y8p1w5-2"
|
|
120
|
+
})(["position:relative;width:100%;background-color:#ffffff;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:flex-start;align-items:flex-start;", " margin:0;:last-of-type{margin-bottom:0;}"], _mediaQuery["default"].mobileOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-direction: column;\n align-items: center;\n "]))));
|
|
121
|
+
|
|
122
|
+
var ImageBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
123
|
+
displayName: "bookmark__ImageBox",
|
|
124
|
+
componentId: "sc-1y8p1w5-3"
|
|
125
|
+
})(["padding:", ";", " ", " flex-basis:auto;flex-grow:0;line-height:1;"], styles.desktop.imageBoxPadding.map(function (value) {
|
|
126
|
+
return "".concat(value, "px");
|
|
127
|
+
}).join(' '), _mediaQuery["default"].tabletOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: ", ";\n "])), styles.tablet.imageBoxPadding.map(function (value) {
|
|
128
|
+
return "".concat(value, "px");
|
|
129
|
+
}).join(' ')), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: ", ";\n width: 100%;\n "])), styles.mobile.imageBoxPadding.map(function (value) {
|
|
130
|
+
return "".concat(value, "px");
|
|
131
|
+
}).join(' ')));
|
|
132
|
+
|
|
133
|
+
var ImageFrame = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
134
|
+
displayName: "bookmark__ImageFrame",
|
|
135
|
+
componentId: "sc-1y8p1w5-4"
|
|
136
|
+
})(["width:", "px;height:", "px;", " ", " line-height:1;"], styles.desktop.imageWidth, styles.desktop.imageHeight, _mediaQuery["default"].tabletOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n "])), styles.tablet.imageWidth, styles.tablet.imageHeight), _mediaQuery["default"].mobileOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n width: 100%;\n height: ", "px;\n "])), styles.mobile.imageHeight));
|
|
137
|
+
|
|
138
|
+
var TextBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
139
|
+
displayName: "bookmark__TextBox",
|
|
140
|
+
componentId: "sc-1y8p1w5-5"
|
|
141
|
+
})(["padding:", ";min-height:", "px;", " ", " position:relative;flex-basis:auto;flex-grow:1;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:flex-start;align-items:flex-start;"], styles.desktop.textBoxPadding.map(function (value) {
|
|
142
|
+
return "".concat(value, "px");
|
|
143
|
+
}).join(' '), styles.desktop.imageHeight + styles.desktop.imageBoxPadding[0] + styles.desktop.imageBoxPadding[2], _mediaQuery["default"].tabletOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: ", ";\n min-height: ", "px;\n "])), styles.tablet.textBoxPadding.map(function (value) {
|
|
144
|
+
return "".concat(value, "px");
|
|
145
|
+
}).join(' '), styles.tablet.imageHeight + styles.tablet.imageBoxPadding[0] + styles.tablet.imageBoxPadding[2]), _mediaQuery["default"].mobileOnly(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: ", ";\n min-height: 0;\n width: 100%;\n "])), styles.mobile.textBoxPadding.map(function (value) {
|
|
146
|
+
return "".concat(value, "px");
|
|
147
|
+
}).join(' ')));
|
|
148
|
+
|
|
149
|
+
var Category = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
150
|
+
displayName: "bookmark__Category",
|
|
151
|
+
componentId: "sc-1y8p1w5-6"
|
|
152
|
+
})(["font-size:16px;", " line-height:1;color:#c4333e;"], _mediaQuery["default"].mobileOnly(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n font-size: 14px;\n "]))));
|
|
153
|
+
|
|
154
|
+
var FirstRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
155
|
+
displayName: "bookmark__FirstRow",
|
|
156
|
+
componentId: "sc-1y8p1w5-7"
|
|
157
|
+
})(["margin-bottom:0.8em;", " width:100%;flex-basis:auto;flex-grow:0;"], _mediaQuery["default"].mobileOnly(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n margin-bottom: .5em;\n "]))));
|
|
158
|
+
|
|
159
|
+
var Title = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
160
|
+
displayName: "bookmark__Title",
|
|
161
|
+
componentId: "sc-1y8p1w5-8"
|
|
162
|
+
})(["font-size:27px;line-height:1.41;margin-bottom:18px;", " font-weight:", ";color:#3e3f3f;flex-basis:auto;flex-grow:0;"], _mediaQuery["default"].mobileOnly(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n font-size: 20px;\n line-height: 1.55;\n margin-bottom: 0;\n "]))), _fontWeight.sourceHanSansTC.bold);
|
|
163
|
+
|
|
164
|
+
var Description = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
165
|
+
displayName: "bookmark__Description",
|
|
166
|
+
componentId: "sc-1y8p1w5-9"
|
|
167
|
+
})(["width:98%;color:#3e3f3f;font-size:18px;", ";flex-basis:auto;flex-grow:0;", ""], (0, _truncate["default"])('relative', 1.57, 2, '#ffffff', 'justify'), _mediaQuery["default"].mobileOnly(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n flex-basis: 0;\n display: none;\n "]))));
|
|
168
|
+
|
|
169
|
+
var LastRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
170
|
+
displayName: "bookmark__LastRow",
|
|
171
|
+
componentId: "sc-1y8p1w5-10"
|
|
172
|
+
})(["margin-top:1em;width:100%;position:relative;"]);
|
|
173
|
+
|
|
174
|
+
var ReadMore = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
175
|
+
displayName: "bookmark__ReadMore",
|
|
176
|
+
componentId: "sc-1y8p1w5-11"
|
|
177
|
+
})(["font-size:14px;text-align:left;color:#8c8c8c;cursor:pointer;display:inline-block;"]);
|
|
178
|
+
|
|
179
|
+
var Date = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
180
|
+
displayName: "bookmark__Date",
|
|
181
|
+
componentId: "sc-1y8p1w5-12"
|
|
182
|
+
})(["vertical-align:top;font-size:16px;font-weight:", ";color:#4a4a4a;float:right;"], _fontWeight.sourceHanSansTC.light);
|
|
183
|
+
|
|
184
|
+
var RemoveBookMarkBtn = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
185
|
+
displayName: "bookmark__RemoveBookMarkBtn",
|
|
186
|
+
componentId: "sc-1y8p1w5-13"
|
|
187
|
+
})(["position:absolute;right:0;top:50%;transform:translateY(-44%);line-height:1;svg{width:15px;height:auto;}cursor:pointer;"]);
|
|
188
|
+
|
|
189
|
+
var Bookmark = /*#__PURE__*/function (_React$PureComponent) {
|
|
190
|
+
_inherits(Bookmark, _React$PureComponent);
|
|
191
|
+
|
|
192
|
+
var _super = _createSuper(Bookmark);
|
|
193
|
+
|
|
194
|
+
function Bookmark(props) {
|
|
195
|
+
var _this;
|
|
196
|
+
|
|
197
|
+
_classCallCheck(this, Bookmark);
|
|
198
|
+
|
|
199
|
+
_this = _super.call(this, props);
|
|
200
|
+
_this.handleDelete = _this.handleDelete.bind(_assertThisInitialized(_this));
|
|
201
|
+
return _this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
_createClass(Bookmark, [{
|
|
205
|
+
key: "handleDelete",
|
|
206
|
+
value: function handleDelete() {
|
|
207
|
+
return this.props.handleDelete(_.get(this.props, 'bookmark.id'));
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "render",
|
|
211
|
+
value: function render() {
|
|
212
|
+
var _$get = _.get(this.props, 'bookmark', {}),
|
|
213
|
+
thumbnail = _$get.thumbnail,
|
|
214
|
+
category = _$get.category,
|
|
215
|
+
title = _$get.title,
|
|
216
|
+
desc = _$get.desc,
|
|
217
|
+
published_date = _$get.published_date,
|
|
218
|
+
slug = _$get.slug,
|
|
219
|
+
is_external = _$get.is_external,
|
|
220
|
+
host = _$get.host;
|
|
221
|
+
|
|
222
|
+
return /*#__PURE__*/_react["default"].createElement(BookmarkFrame, null, /*#__PURE__*/_react["default"].createElement(BookmarkContentContainer, null, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], {
|
|
223
|
+
isExternal: is_external,
|
|
224
|
+
slug: slug,
|
|
225
|
+
host: host
|
|
226
|
+
}, /*#__PURE__*/_react["default"].createElement(ImageBox, null, /*#__PURE__*/_react["default"].createElement(ImageFrame, null, /*#__PURE__*/_react["default"].createElement(_imageWrapper["default"], {
|
|
227
|
+
src: thumbnail,
|
|
228
|
+
alt: "Bookmark_Image_".concat(title)
|
|
229
|
+
})))), /*#__PURE__*/_react["default"].createElement(TextBox, null, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], {
|
|
230
|
+
isExternal: is_external,
|
|
231
|
+
slug: slug,
|
|
232
|
+
host: host
|
|
233
|
+
}, /*#__PURE__*/_react["default"].createElement(FirstRow, null, /*#__PURE__*/_react["default"].createElement(Category, null, category), /*#__PURE__*/_react["default"].createElement(Date, null, (0, _date.date2yyyymmdd)(published_date * 1000, '.'))), /*#__PURE__*/_react["default"].createElement(Title, null, title), /*#__PURE__*/_react["default"].createElement(Description, null, desc)), /*#__PURE__*/_react["default"].createElement(LastRow, null, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], {
|
|
234
|
+
isExternal: is_external,
|
|
235
|
+
slug: slug,
|
|
236
|
+
host: host
|
|
237
|
+
}, /*#__PURE__*/_react["default"].createElement(ReadMore, null, READ_MORE)), /*#__PURE__*/_react["default"].createElement(RemoveBookMarkBtn, null, /*#__PURE__*/_react["default"].createElement(BookmarkIconComp, {
|
|
238
|
+
onClick: this.handleDelete
|
|
239
|
+
}))))));
|
|
240
|
+
}
|
|
241
|
+
}]);
|
|
242
|
+
|
|
243
|
+
return Bookmark;
|
|
244
|
+
}(_react["default"].PureComponent);
|
|
245
|
+
|
|
246
|
+
exports["default"] = Bookmark;
|
|
247
|
+
|
|
248
|
+
_defineProperty(Bookmark, "propTypes", {
|
|
249
|
+
bookmark: _propTypes["default"].bookmark.isRequired,
|
|
250
|
+
handleDelete: _propTypes2["default"].func.isRequired
|
|
251
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _fontWeight = require("@twreporter/core/lib/constants/font-weight");
|
|
9
|
+
|
|
10
|
+
var _bookmark = _interopRequireDefault(require("./bookmark"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("@twreporter/core/lib/constants/prop-types"));
|
|
13
|
+
|
|
14
|
+
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
15
|
+
|
|
16
|
+
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
|
+
|
|
20
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
21
|
+
|
|
22
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
23
|
+
|
|
24
|
+
var _map = _interopRequireDefault(require("lodash/map"));
|
|
25
|
+
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
|
+
|
|
30
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
31
|
+
|
|
32
|
+
var _ = {
|
|
33
|
+
get: _get["default"],
|
|
34
|
+
map: _map["default"]
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var PageContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
38
|
+
displayName: "bookmarks__PageContainer",
|
|
39
|
+
componentId: "sc-1m95x6z-0"
|
|
40
|
+
})(["padding:50px 0;margin:0;", ""], _mediaQuery["default"].mobileOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 25px 0;\n "]))));
|
|
41
|
+
|
|
42
|
+
var Column = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
43
|
+
displayName: "bookmarks__Column",
|
|
44
|
+
componentId: "sc-1m95x6z-1"
|
|
45
|
+
})(["margin:0 auto;width:97%;max-width:834px;", " ", ""], _mediaQuery["default"].tabletOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n max-width: 707px;\n "]))), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n "]))));
|
|
46
|
+
|
|
47
|
+
var StatusBar = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
48
|
+
displayName: "bookmarks__StatusBar",
|
|
49
|
+
componentId: "sc-1m95x6z-2"
|
|
50
|
+
})(["", " padding-bottom:25px;width:100%;"], _mediaQuery["default"].mobileOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding-left: 1em;\n "]))));
|
|
51
|
+
|
|
52
|
+
var CountTitle = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
53
|
+
displayName: "bookmarks__CountTitle",
|
|
54
|
+
componentId: "sc-1m95x6z-3"
|
|
55
|
+
})(["font-size:20px;", " margin-right:1em;"], _mediaQuery["default"].mobileOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 18px;\n "]))));
|
|
56
|
+
|
|
57
|
+
var CountNumber = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
58
|
+
displayName: "bookmarks__CountNumber",
|
|
59
|
+
componentId: "sc-1m95x6z-4"
|
|
60
|
+
})(["font-size:20px;", " font-weight:", ";"], _mediaQuery["default"].mobileOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-size: 18px;\n "]))), _fontWeight.sourceHanSansTC.bold);
|
|
61
|
+
|
|
62
|
+
var BookmarksContainer = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
63
|
+
displayName: "bookmarks__BookmarksContainer",
|
|
64
|
+
componentId: "sc-1m95x6z-5"
|
|
65
|
+
})(["margin:0;width:100%;padding:0;"]);
|
|
66
|
+
|
|
67
|
+
function Bookmarks(_ref) {
|
|
68
|
+
var total = _ref.total,
|
|
69
|
+
bookmarks = _ref.bookmarks,
|
|
70
|
+
handleDelete = _ref.handleDelete;
|
|
71
|
+
|
|
72
|
+
var buildBookmark = function buildBookmark(bookmark) {
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement(_bookmark["default"], {
|
|
74
|
+
key: "bookmark_".concat(_.get(bookmark, 'id')),
|
|
75
|
+
bookmark: bookmark,
|
|
76
|
+
handleDelete: handleDelete
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return /*#__PURE__*/_react["default"].createElement(PageContainer, null, /*#__PURE__*/_react["default"].createElement(Column, null, /*#__PURE__*/_react["default"].createElement(StatusBar, null, /*#__PURE__*/_react["default"].createElement(CountTitle, null, "\u5168\u90E8"), /*#__PURE__*/_react["default"].createElement(CountNumber, null, total)), /*#__PURE__*/_react["default"].createElement(BookmarksContainer, null, _.map(bookmarks, buildBookmark))));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Bookmarks.defaultProps = {
|
|
84
|
+
bookmarks: [],
|
|
85
|
+
total: 0
|
|
86
|
+
};
|
|
87
|
+
Bookmarks.propTypes = {
|
|
88
|
+
bookmarks: _propTypes2["default"].arrayOf(_propTypes["default"]).isRequired,
|
|
89
|
+
handleDelete: _propTypes2["default"].func.isRequired,
|
|
90
|
+
total: _propTypes2["default"].number
|
|
91
|
+
};
|
|
92
|
+
var _default = Bookmarks;
|
|
93
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _entityPath = _interopRequireDefault(require("@twreporter/core/lib/constants/entity-path"));
|
|
9
|
+
|
|
10
|
+
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
var CustomizedLink = function CustomizedLink(_ref) {
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
isExternal = _ref.isExternal,
|
|
21
|
+
slug = _ref.slug,
|
|
22
|
+
host = _ref.host;
|
|
23
|
+
|
|
24
|
+
if (isExternal) {
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement("a", {
|
|
26
|
+
href: "".concat(host).concat(_entityPath["default"].interactiveArticle).concat(slug)
|
|
27
|
+
}, children);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
|
|
31
|
+
to: "".concat(_entityPath["default"].article).concat(slug)
|
|
32
|
+
}, children);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
CustomizedLink.defaultProps = {
|
|
36
|
+
children: null
|
|
37
|
+
};
|
|
38
|
+
CustomizedLink.propTypes = {
|
|
39
|
+
children: _propTypes["default"].node,
|
|
40
|
+
isExternal: _propTypes["default"].bool.isRequired,
|
|
41
|
+
slug: _propTypes["default"].string.isRequired,
|
|
42
|
+
host: _propTypes["default"].string.isRequired
|
|
43
|
+
};
|
|
44
|
+
var _default = CustomizedLink;
|
|
45
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,119 @@
|
|
|
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 _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
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 _ = {
|
|
43
|
+
get: _get["default"]
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var ImgObjectFit = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
47
|
+
displayName: "image-wrapper__ImgObjectFit",
|
|
48
|
+
componentId: "zom1jf-0"
|
|
49
|
+
})(["width:100%;height:100%;> img{width:100%;height:100%;object-fit:cover;}"]);
|
|
50
|
+
|
|
51
|
+
var ImgFallback = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
52
|
+
displayName: "image-wrapper__ImgFallback",
|
|
53
|
+
componentId: "zom1jf-1"
|
|
54
|
+
})(["width:100%;height:100%;background-size:cover;background-image:", ";background-position:center center;"], function (props) {
|
|
55
|
+
return "url(".concat(_.get(props, 'url'), ")");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var ImgWrapper = /*#__PURE__*/function (_React$Component) {
|
|
59
|
+
_inherits(ImgWrapper, _React$Component);
|
|
60
|
+
|
|
61
|
+
var _super = _createSuper(ImgWrapper);
|
|
62
|
+
|
|
63
|
+
function ImgWrapper(props) {
|
|
64
|
+
var _this;
|
|
65
|
+
|
|
66
|
+
_classCallCheck(this, ImgWrapper);
|
|
67
|
+
|
|
68
|
+
_this = _super.call(this, props);
|
|
69
|
+
_this.state = {
|
|
70
|
+
isObjectFit: true
|
|
71
|
+
};
|
|
72
|
+
return _this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_createClass(ImgWrapper, [{
|
|
76
|
+
key: "componentDidMount",
|
|
77
|
+
value: function componentDidMount() {
|
|
78
|
+
this.setState({
|
|
79
|
+
isObjectFit: 'objectFit' in _.get(document, 'documentElement.style')
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "render",
|
|
84
|
+
value: function render() {
|
|
85
|
+
var _this$props = this.props,
|
|
86
|
+
src = _this$props.src,
|
|
87
|
+
alt = _this$props.alt,
|
|
88
|
+
srcSet = _this$props.srcSet;
|
|
89
|
+
var isObjectFit = this.state.isObjectFit;
|
|
90
|
+
return isObjectFit ? /*#__PURE__*/_react["default"].createElement(ImgObjectFit, null, /*#__PURE__*/_react["default"].createElement("img", {
|
|
91
|
+
alt: alt,
|
|
92
|
+
src: (0, _storageUrlProcessor.replaceGCSUrlOrigin)(src),
|
|
93
|
+
srcSet: srcSet,
|
|
94
|
+
style: {
|
|
95
|
+
transform: 'translateZ(0)'
|
|
96
|
+
}
|
|
97
|
+
}), this.props.children) : /*#__PURE__*/_react["default"].createElement(ImgFallback, {
|
|
98
|
+
url: (0, _storageUrlProcessor.replaceGCSUrlOrigin)(src)
|
|
99
|
+
}, this.props.children);
|
|
100
|
+
}
|
|
101
|
+
}]);
|
|
102
|
+
|
|
103
|
+
return ImgWrapper;
|
|
104
|
+
}(_react["default"].Component);
|
|
105
|
+
|
|
106
|
+
ImgWrapper.defaultProps = {
|
|
107
|
+
alt: '',
|
|
108
|
+
children: null,
|
|
109
|
+
src: '',
|
|
110
|
+
srcSet: ''
|
|
111
|
+
};
|
|
112
|
+
ImgWrapper.propTypes = {
|
|
113
|
+
alt: _propTypes["default"].string,
|
|
114
|
+
children: _propTypes["default"].node,
|
|
115
|
+
src: _propTypes["default"].string.isRequired,
|
|
116
|
+
srcSet: _propTypes["default"].string
|
|
117
|
+
};
|
|
118
|
+
var _default = ImgWrapper;
|
|
119
|
+
exports["default"] = _default;
|