@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/components/article-page.js +39 -108
  3. package/lib/components/aside/desktop-aside.js +25 -65
  4. package/lib/components/aside/desktop-tools.js +11 -57
  5. package/lib/components/aside/metadata.js +22 -89
  6. package/lib/components/aside/mobile-tool-bar.js +79 -175
  7. package/lib/components/aside/utils/theme.js +5 -11
  8. package/lib/components/body/annotation.js +15 -73
  9. package/lib/components/body/audio/audio-contexts.js +4 -16
  10. package/lib/components/body/audio/audio-provider.js +13 -48
  11. package/lib/components/body/audio/control-button.js +4 -28
  12. package/lib/components/body/audio/index.js +10 -56
  13. package/lib/components/body/audio/seek-bar.js +6 -23
  14. package/lib/components/body/audio/time.js +0 -6
  15. package/lib/components/body/blockquote.js +11 -52
  16. package/lib/components/body/brief.js +10 -55
  17. package/lib/components/body/centered-quote.js +10 -52
  18. package/lib/components/body/embedded-code.js +22 -101
  19. package/lib/components/body/headings.js +6 -23
  20. package/lib/components/body/image-diff.js +13 -66
  21. package/lib/components/body/image.js +11 -46
  22. package/lib/components/body/index.js +21 -118
  23. package/lib/components/body/infobox.js +13 -58
  24. package/lib/components/body/list.js +8 -29
  25. package/lib/components/body/multimedia.js +10 -29
  26. package/lib/components/body/paragraph.js +5 -23
  27. package/lib/components/body/slider/index.js +28 -96
  28. package/lib/components/body/slideshow/index.js +36 -107
  29. package/lib/components/body/tracking-section.js +7 -46
  30. package/lib/components/body/youtube.js +8 -41
  31. package/lib/components/donation-box.js +10 -44
  32. package/lib/components/img-with-placeholder/index.js +34 -106
  33. package/lib/components/leading/extend.js +6 -25
  34. package/lib/components/leading/fullscreen.js +17 -63
  35. package/lib/components/leading/index.js +2 -10
  36. package/lib/components/leading/normal.js +19 -64
  37. package/lib/components/leading/pink.js +20 -59
  38. package/lib/components/leading/small.js +6 -25
  39. package/lib/components/license.js +9 -40
  40. package/lib/components/link.js +8 -37
  41. package/lib/components/related/card.js +20 -73
  42. package/lib/components/related/index.js +25 -71
  43. package/lib/components/related/list.js +16 -70
  44. package/lib/components/related/mockup.js +10 -12
  45. package/lib/components/separation-curve.js +0 -15
  46. package/lib/components/table-of-contents/index.js +17 -46
  47. package/lib/components/table-of-contents/styled.js +10 -38
  48. package/lib/constants/anchor.js +4 -8
  49. package/lib/constants/css.js +2 -15
  50. package/lib/constants/element-alignment.js +2 -3
  51. package/lib/constants/prop-types/article-page.js +2 -7
  52. package/lib/constants/prop-types/aside.js +2 -8
  53. package/lib/constants/prop-types/body.js +4 -9
  54. package/lib/constants/prop-types/img-with-placeholder.js +2 -7
  55. package/lib/constants/prop-types/leading.js +8 -13
  56. package/lib/constants/prop-types/related.js +2 -7
  57. package/lib/constants/theme.js +2 -3
  58. package/lib/constants/typography.js +2 -5
  59. package/lib/contexts/dynamic-components-context.js +2 -8
  60. package/lib/managers/layout-manager.js +13 -28
  61. package/lib/managers/theme-manager.js +13 -32
  62. package/lib/managers/ui-manager.js +14 -26
  63. package/lib/utils/image.js +5 -14
  64. package/package.json +6 -6
@@ -1,54 +1,37 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 _dynamicComponentsContext = _interopRequireDefault(require("../../contexts/dynamic-components-context"));
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
-
18
12
  var _theme = _interopRequireDefault(require("../../constants/theme"));
19
-
20
13
  var _aside = _interopRequireDefault(require("../../constants/prop-types/aside"));
21
-
22
14
  var _icon = require("@twreporter/react-components/lib/icon");
23
-
24
15
  var _bookmarkWidget = _interopRequireDefault(require("@twreporter/react-components/lib/bookmark-widget"));
25
-
26
16
  var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
27
-
28
17
  var _color = require("@twreporter/core/lib/constants/color");
29
-
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
31
-
32
- 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); }
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
-
18
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; // constants
19
+ // icons
20
+ // @twreporter
21
+ 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); }
22
+ 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
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
-
38
24
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
39
-
40
25
  function changeFontSizeOffsetToPct(fontSizeOffset) {
41
26
  switch (fontSizeOffset) {
42
27
  case 2:
43
28
  {
44
29
  return '110%';
45
30
  }
46
-
47
31
  case 4:
48
32
  {
49
33
  return '120%';
50
34
  }
51
-
52
35
  case 0:
53
36
  default:
54
37
  {
@@ -56,38 +39,31 @@ function changeFontSizeOffsetToPct(fontSizeOffset) {
56
39
  }
57
40
  }
58
41
  }
59
-
60
42
  var iconBlockCSS = /*#__PURE__*/(0, _styledComponents.css)(["position:relative;cursor:pointer;line-height:1;padding:6px;svg{width:18px;height:18px;background-color:", ";}&::after{position:absolute;top:10px;left:34px;color:", ";font-size:10px;visibility:hidden;width:100px;}&:hover{svg{background-color:", ";}&::after{visibility:visible;}}", ""], _color.colorGrayscale.gray600, _color.colorGrayscale.gray800, _color.colorGrayscale.gray800, _mediaQuery["default"].tabletAndBelow(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::after {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n text-align: center;\n }\n "]))));
61
-
62
43
  var TextIconBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
63
44
  displayName: "desktop-tools__TextIconBlock",
64
45
  componentId: "eihdd4-0"
65
46
  })(["", " &::after{content:'\u5B57\u7D1A\u5927\u5C0F", "';}"], iconBlockCSS, function (props) {
66
47
  return changeFontSizeOffsetToPct(props.theme.fontSizeOffset);
67
48
  });
68
-
69
49
  var BackToTopicBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
70
50
  displayName: "desktop-tools__BackToTopicBlock",
71
51
  componentId: "eihdd4-1"
72
52
  })(["", " &::after{content:'\u56DE\u5230\u5C08\u984C';}"], iconBlockCSS);
73
-
74
53
  var PrintIconBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
75
54
  displayName: "desktop-tools__PrintIconBlock",
76
55
  componentId: "eihdd4-2"
77
56
  })(["", " &::after{content:'\u5217\u5370';}"], iconBlockCSS);
78
-
79
57
  var BookmarkIconBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
80
58
  displayName: "desktop-tools__BookmarkIconBlock",
81
59
  componentId: "eihdd4-3"
82
60
  })(["", " &::after{content:'", "';}"], iconBlockCSS, function (props) {
83
61
  return props.$isBookmarked ? '取消收藏' : '收藏';
84
62
  });
85
-
86
63
  var ShareIconBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
87
64
  displayName: "desktop-tools__ShareIconBlock",
88
65
  componentId: "eihdd4-4"
89
66
  })(["svg{width:18px;height:18px;background-color:", ";}background-color:", ";border-radius:50%;padding:6px;cursor:pointer;display:flex;"], _color.colorGrayscale.gray800, _color.colorGrayscale.white);
90
-
91
67
  var ToolsBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
92
68
  displayName: "desktop-tools__ToolsBlock",
93
69
  componentId: "eihdd4-5"
@@ -97,22 +73,18 @@ var ToolsBlock = /*#__PURE__*/_styledComponents["default"].div.withConfig({
97
73
  switch (props.theme.name) {
98
74
  case _theme["default"].article.v2.photo:
99
75
  return (0, _styledComponents.css)(["", "{background-color:", ";svg{background-color:", ";}}", ",", ",", ",", "{svg{background-color:", ";}&::after{color:", ";}&:hover svg{background-color:", ";}}"], ShareIconBlock, _color.colorPhoto.heavy, _color.colorGrayscale.gray100, TextIconBlock, BackToTopicBlock, PrintIconBlock, BookmarkIconBlock, _color.colorGrayscale.gray100, _color.colorSupportive.pastel, _color.colorSupportive.pastel);
100
-
101
76
  default:
102
77
  return '';
103
78
  }
104
79
  });
105
-
106
80
  function FBShareBT(props) {
107
81
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
108
82
  var releaseBranch = themeContext.releaseBranch;
109
-
110
83
  var handleClick = function handleClick() {
111
84
  var currentURL = window.location.href;
112
85
  var location = 'https://www.facebook.com/dialog/feed?' + 'display=page' + "&app_id=".concat(props.appID) + "&link=".concat(encodeURIComponent(currentURL)) + "&redirect_uri=".concat(encodeURIComponent('https://www.facebook.com/'));
113
86
  window.open(location, '_blank');
114
87
  };
115
-
116
88
  return /*#__PURE__*/_react["default"].createElement(ShareIconBlock, {
117
89
  id: "fb-share"
118
90
  }, /*#__PURE__*/_react["default"].createElement(_icon.Facebook, {
@@ -120,21 +92,17 @@ function FBShareBT(props) {
120
92
  releaseBranch: releaseBranch
121
93
  }));
122
94
  }
123
-
124
95
  FBShareBT.propTypes = {
125
96
  appID: _propTypes["default"].string.isRequired
126
97
  };
127
-
128
98
  function TwitterShareBT(props) {
129
99
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
130
100
  var releaseBranch = themeContext.releaseBranch;
131
-
132
101
  var handleClick = function handleClick() {
133
102
  var currentURL = window.location.href;
134
103
  var location = 'https://twitter.com/intent/tweet?' + "url=".concat(encodeURIComponent(currentURL), "&text=").concat(encodeURIComponent(document.title + ' #報導者'));
135
104
  window.open(location, '_blank');
136
105
  };
137
-
138
106
  return /*#__PURE__*/_react["default"].createElement(ShareIconBlock, {
139
107
  id: "twitter-share"
140
108
  }, /*#__PURE__*/_react["default"].createElement(_icon.Twitter, {
@@ -142,17 +110,14 @@ function TwitterShareBT(props) {
142
110
  releaseBranch: releaseBranch
143
111
  }));
144
112
  }
145
-
146
113
  function LineShareBT(props) {
147
114
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
148
115
  var releaseBranch = themeContext.releaseBranch;
149
-
150
116
  var handleClick = function handleClick() {
151
117
  var currentURL = window.location.href;
152
118
  var location = "https://social-plugins.line.me/lineit/share?url=".concat(encodeURIComponent(currentURL));
153
119
  window.open(location, '_blank');
154
120
  };
155
-
156
121
  return /*#__PURE__*/_react["default"].createElement(ShareIconBlock, {
157
122
  id: "line-share"
158
123
  }, /*#__PURE__*/_react["default"].createElement(_icon.Line, {
@@ -160,12 +125,10 @@ function LineShareBT(props) {
160
125
  releaseBranch: releaseBranch
161
126
  }));
162
127
  }
163
-
164
128
  var BookmarkBlock = function BookmarkBlock(_ref) {
165
129
  var articleMeta = _ref.articleMeta;
166
130
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
167
131
  var releaseBranch = themeContext.releaseBranch;
168
-
169
132
  var renderIcon = function renderIcon(isBookmarked, addAction, removeAction) {
170
133
  var iconType = isBookmarked ? 'saved' : 'add';
171
134
  var id = isBookmarked ? 'remove-bookmark' : 'add-bookmark';
@@ -178,18 +141,15 @@ var BookmarkBlock = function BookmarkBlock(_ref) {
178
141
  releaseBranch: releaseBranch
179
142
  }));
180
143
  };
181
-
182
144
  return /*#__PURE__*/_react["default"].createElement(_bookmarkWidget["default"], {
183
145
  toAutoCheck: true,
184
146
  articleMeta: articleMeta,
185
147
  renderIcon: renderIcon
186
148
  });
187
149
  };
188
-
189
150
  BookmarkBlock.propTypes = {
190
151
  articleMeta: _aside["default"].tools.articleMetaForBookmark
191
152
  };
192
-
193
153
  var BackToTopic = function BackToTopic(_ref2) {
194
154
  var backToTopic = _ref2.backToTopic;
195
155
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
@@ -203,28 +163,24 @@ var BackToTopic = function BackToTopic(_ref2) {
203
163
  })));
204
164
  });
205
165
  };
206
-
207
166
  BackToTopic.propTypes = {
208
167
  backToTopic: _aside["default"].tools.backToTopic
209
168
  };
210
169
  var defaultFbAppID = '962589903815787';
211
-
212
170
  var Tools = function Tools(_ref3) {
213
171
  var backToTopic = _ref3.backToTopic,
214
- fbAppID = _ref3.fbAppID,
215
- height = _ref3.height,
216
- onFontLevelChange = _ref3.onFontLevelChange,
217
- articleMetaForBookmark = _ref3.articleMetaForBookmark;
172
+ fbAppID = _ref3.fbAppID,
173
+ height = _ref3.height,
174
+ onFontLevelChange = _ref3.onFontLevelChange,
175
+ articleMetaForBookmark = _ref3.articleMetaForBookmark;
218
176
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
219
177
  var releaseBranch = themeContext.releaseBranch;
220
178
  var backToTopicJSX = backToTopic ? /*#__PURE__*/_react["default"].createElement(BackToTopic, {
221
179
  backToTopic: backToTopic
222
180
  }) : null;
223
-
224
181
  var onPrinterClick = function onPrinterClick() {
225
182
  return window.print();
226
183
  };
227
-
228
184
  return /*#__PURE__*/_react["default"].createElement(ToolsBlock, {
229
185
  $height: height
230
186
  }, backToTopicJSX, /*#__PURE__*/_react["default"].createElement(BookmarkBlock, {
@@ -239,7 +195,5 @@ var Tools = function Tools(_ref3) {
239
195
  appID: fbAppID || defaultFbAppID
240
196
  }), /*#__PURE__*/_react["default"].createElement(TwitterShareBT, null), /*#__PURE__*/_react["default"].createElement(LineShareBT, null));
241
197
  };
242
-
243
198
  Tools.propTypes = _aside["default"].tools;
244
- var _default = Tools;
245
- exports["default"] = _default;
199
+ var _default = exports["default"] = Tools;
@@ -1,98 +1,64 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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 _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
15
-
16
11
  var _dynamicComponentsContext = _interopRequireDefault(require("../../contexts/dynamic-components-context"));
17
-
18
12
  var _aside = _interopRequireDefault(require("../../constants/prop-types/aside"));
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 _theme = require("@twreporter/core/lib/constants/theme");
25
-
26
16
  var _color = require("@twreporter/core/lib/constants/color");
27
-
28
17
  var _categorySet = require("@twreporter/core/lib/constants/category-set");
29
-
30
18
  var _button = require("@twreporter/react-components/lib/button");
31
-
32
19
  var _get = _interopRequireDefault(require("lodash/get"));
33
-
34
20
  var _map = _interopRequireDefault(require("lodash/map"));
35
-
36
21
  var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
37
-
38
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
39
-
22
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; // components
23
+ // @twreporter
24
+ // lodash
40
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
41
-
42
- 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); }
43
-
44
- 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; }
45
-
26
+ 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); }
27
+ 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; }
46
28
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
47
-
48
- 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); } }
49
-
29
+ 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); } }
50
30
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
51
-
52
31
  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); }
53
-
54
32
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
55
-
56
33
  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); }; }
57
-
58
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); }
59
-
60
35
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
61
-
62
36
  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; } }
63
-
64
37
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
65
-
66
- 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; }
67
-
38
+ 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; }
39
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
40
+ 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); }
68
41
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
69
-
70
42
  var _ = {
71
43
  get: _get["default"],
72
44
  map: _map["default"],
73
45
  sortBy: _sortBy["default"]
74
46
  };
75
-
76
47
  var createLine = function createLine(topOrBottom, themeName) {
77
48
  var borderColor = _color.colorGrayscale.gray300;
78
-
79
49
  if (themeName === _theme.ARTICLE_THEME.v2.photo) {
80
50
  borderColor = _color.colorGrayscale.gray400;
81
51
  }
82
-
83
52
  return (0, _styledComponents.css)(["position:relative;border-", ":0.5px solid ", ";padding-", ":10px;&::after{content:'';border-right:0.5px solid ", ";width:1px;height:12px;", ":0;right:0;position:absolute;}"], topOrBottom, borderColor, topOrBottom, borderColor, topOrBottom);
84
53
  };
85
-
86
54
  var CategorySetFlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
87
55
  displayName: "metadata__CategorySetFlexBox",
88
56
  componentId: "sc-1c3910m-0"
89
57
  })(["display:flex;flex-direction:column;"]);
90
-
91
58
  var LinkContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
92
59
  displayName: "metadata__LinkContainer",
93
60
  componentId: "sc-1c3910m-1"
94
61
  })(["display:flex;"]);
95
-
96
62
  var CategorySetFlex = /*#__PURE__*/_styledComponents["default"].div.withConfig({
97
63
  displayName: "metadata__CategorySetFlex",
98
64
  componentId: "sc-1c3910m-2"
@@ -101,99 +67,80 @@ var CategorySetFlex = /*#__PURE__*/_styledComponents["default"].div.withConfig({
101
67
  }, _mediaQuery["default"].tabletAndBelow(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-right: 10px;\n padding-left: 10px;\n "]))), function (props) {
102
68
  return props.$isCategory ? (0, _styledComponents.css)(["min-width:100px;flex-basis:100px;padding-left:10px;padding-right:10px;", " ", ""], _mediaQuery["default"].desktopAndAbove(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-left: 0px;\n padding-right: 5px;\n "]))), _mediaQuery["default"].desktopOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n min-width: 80px;\n flex-basis: 80px;\n "])))) : (0, _styledComponents.css)(["flex-basis:calc(100% - 100px);", " ", ""], _mediaQuery["default"].desktopOnly(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex-basis: calc(100% - 80px);\n "]))), _mediaQuery["default"].desktopAndAbove(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding-left: 10px;\n padding-right: 0px;\n "]))));
103
69
  });
104
-
105
70
  var CategoryText = /*#__PURE__*/_styledComponents["default"].div.withConfig({
106
71
  displayName: "metadata__CategoryText",
107
72
  componentId: "sc-1c3910m-3"
108
73
  })(["display:inline-block;font-size:16px;line-height:1;padding-left:5px;&:hover{padding-bottom:2px;border-width:0 0 1px 0;border-style:solid;}"]);
109
-
110
74
  var DateSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
111
75
  displayName: "metadata__DateSection",
112
76
  componentId: "sc-1c3910m-4"
113
77
  })(["", " font-size:14px;color:", ";margin-left:5px;margin-top:15px;&::before{content:'\u520A\u51FA\u65E5\u671F';margin-right:10px;}"], function (props) {
114
78
  return createLine('top', props.theme.name);
115
79
  }, _color.colorGrayscale.gray500);
116
-
117
80
  var AuthorSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
118
81
  displayName: "metadata__AuthorSection",
119
82
  componentId: "sc-1c3910m-5"
120
83
  })(["margin-top:15px;margin-bottom:45px;"]);
121
-
122
84
  var AuthorRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
123
85
  displayName: "metadata__AuthorRow",
124
86
  componentId: "sc-1c3910m-6"
125
87
  })(["display:flex;align-items:flex-start;margin-bottom:10px;"]);
126
-
127
88
  var AuthorJobTitle = /*#__PURE__*/_styledComponents["default"].div.withConfig({
128
89
  displayName: "metadata__AuthorJobTitle",
129
90
  componentId: "sc-1c3910m-7"
130
91
  })(["font-size:14px;color:", ";margin-left:5px;padding-top:2px;line-height:1;flex-shrink:0;"], _color.colorGrayscale.gray600);
131
-
132
92
  var AuthorNames = /*#__PURE__*/_styledComponents["default"].div.withConfig({
133
93
  displayName: "metadata__AuthorNames",
134
94
  componentId: "sc-1c3910m-8"
135
95
  })(["display:flex;flex-wrap:wrap;"]);
136
-
137
96
  var AuthorName = /*#__PURE__*/_styledComponents["default"].div.withConfig({
138
97
  displayName: "metadata__AuthorName",
139
98
  componentId: "sc-1c3910m-9"
140
99
  })(["font-size:16px;margin-left:5px;line-height:1;padding-bottom:3px;word-break:keep-all;vertical-align:top;&:hover{padding-bottom:2px;border-width:0 0 1px 0;border-style:solid;}", ""], _mediaQuery["default"].mobileOnly(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: inline-block;\n "]))));
141
-
142
100
  var RawAuthorText = /*#__PURE__*/_styledComponents["default"].div.withConfig({
143
101
  displayName: "metadata__RawAuthorText",
144
102
  componentId: "sc-1c3910m-10"
145
103
  })(["font-size:14px;color:", ";padding-left:5px;"], _color.colorGrayscale.gray600);
146
-
147
104
  var AngledSeparationLine = /*#__PURE__*/_styledComponents["default"].div.withConfig({
148
105
  displayName: "metadata__AngledSeparationLine",
149
106
  componentId: "sc-1c3910m-11"
150
107
  })(["border-width:0.5px;border-style:solid;width:15px;transform:translateY(9px) rotate(-45deg);flex-shrink:0;"]);
151
-
152
108
  var TagButton = /*#__PURE__*/_styledComponents["default"].div.withConfig({
153
109
  displayName: "metadata__TagButton",
154
110
  componentId: "sc-1c3910m-12"
155
111
  })(["border-style:solid;border-width:1px;border-radius:50px;padding:5px 10px 5px 10px;font-size:14px;font-weight:", ";margin-bottom:10px;margin-right:10px;&:before{content:'#';}"], _typography["default"].font.weight.normal);
156
-
157
112
  var TagsSection = /*#__PURE__*/_styledComponents["default"].div.withConfig({
158
113
  displayName: "metadata__TagsSection",
159
114
  componentId: "sc-1c3910m-13"
160
115
  })(["display:flex;flex-wrap:wrap;align-content:center;", ""], function (props) {
161
116
  return createLine('bottom', props.theme.name);
162
117
  });
163
-
164
118
  var TextLink = /*#__PURE__*/(0, _styledComponents["default"])(_button.LinkButton).withConfig({
165
119
  displayName: "metadata__TextLink",
166
120
  componentId: "sc-1c3910m-14"
167
121
  })([""]);
168
-
169
122
  var MetadataContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
170
123
  displayName: "metadata__MetadataContainer",
171
124
  componentId: "sc-1c3910m-15"
172
125
  })(["", " letter-spacing:0.4px;", " ", ""], function (props) {
173
126
  return getMetadataContainerStyles(props.theme.name);
174
127
  }, _mediaQuery["default"].mobileOnly(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding-left: 24px;\n padding-right: 24px;\n margin: 0 auto;\n "]))), _mediaQuery["default"].tabletOnly(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 513px;\n margin: 0 auto;\n "]))));
175
-
176
128
  function getMetadataContainerStyles(themeName) {
177
129
  switch (themeName) {
178
130
  case _theme.ARTICLE_THEME.v2.photo:
179
131
  return (0, _styledComponents.css)(["", ",", "{color:", ";&:hover{border-color:", ";}}", "{border-color:", ";}", "{border-color:", ";color:", ";&:hover{color:", ";border-color:", ";}}", "{color:", ";}"], CategoryText, AuthorName, _color.colorSupportive.main, _color.colorSupportive.main, AngledSeparationLine, _color.colorSupportive.heavy, TagButton, _color.colorGrayscale.gray600, _color.colorGrayscale.gray600, _color.colorGrayscale.white, _color.colorGrayscale.white, TextLink, _color.colorSupportive.main);
180
-
181
132
  case _theme.ARTICLE_THEME.v2.pink:
182
133
  return (0, _styledComponents.css)(["", ",", "{color:", ";&:hover{border-color:", ";}}", "{border-color:", ";}", "{border-color:", ";color:", ";&:hover{background-color:", ";}}", "{color:", ";}"], CategoryText, AuthorName, _color.COLOR_PINK_ARTICLE.blue, _color.COLOR_PINK_ARTICLE.blue, AngledSeparationLine, _color.COLOR_PINK_ARTICLE.pink, TagButton, _color.colorGrayscale.gray600, _color.colorGrayscale.gray600, _color.colorGrayscale.white, TextLink, _color.COLOR_PINK_ARTICLE.blue);
183
-
184
134
  case _theme.ARTICLE_THEME.v2["default"]:
185
135
  default:
186
136
  return (0, _styledComponents.css)(["", ",", "{color:", ";&:hover{border-color:", ";}}", "{border-color:", ";}", "{border-color:", ";color:", ";&:hover{background-color:", ";}}", "{color:", ";}"], CategoryText, AuthorName, _color.colorSupportive.heavy, _color.colorSupportive.heavy, AngledSeparationLine, _color.colorSupportive.main, TagButton, _color.colorGrayscale.gray600, _color.colorGrayscale.gray600, _color.colorGrayscale.white, TextLink, _color.colorSupportive.heavy);
187
137
  }
188
138
  }
189
-
190
139
  var CategorySet = function CategorySet(_ref) {
191
140
  var _ref$categorySet = _ref.categorySet,
192
- categorySet = _ref$categorySet === void 0 ? [] : _ref$categorySet;
193
-
141
+ categorySet = _ref$categorySet === void 0 ? [] : _ref$categorySet;
194
142
  var categorySetJSX = _.map(categorySet, function (set, index) {
195
143
  var _set$category, _set$subcategory, _set$category2, _set$subcategory2;
196
-
197
144
  var genLink = function genLink(path, name) {
198
145
  var isCategory = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
199
146
  var link = {
@@ -210,32 +157,24 @@ var CategorySet = function CategorySet(_ref) {
210
157
  weight: weight
211
158
  }));
212
159
  };
213
-
214
- var categoryPath = (0, _categorySet.GET_CATEGORY_PATH_FROM_ID)(set === null || set === void 0 ? void 0 : (_set$category = set.category) === null || _set$category === void 0 ? void 0 : _set$category.id);
215
- var subcategoryPath = (0, _categorySet.GET_SUBCATEGORY_PATH_FROM_ID)(set === null || set === void 0 ? void 0 : (_set$subcategory = set.subcategory) === null || _set$subcategory === void 0 ? void 0 : _set$subcategory.id);
160
+ var categoryPath = (0, _categorySet.GET_CATEGORY_PATH_FROM_ID)(set === null || set === void 0 || (_set$category = set.category) === null || _set$category === void 0 ? void 0 : _set$category.id);
161
+ var subcategoryPath = (0, _categorySet.GET_SUBCATEGORY_PATH_FROM_ID)(set === null || set === void 0 || (_set$subcategory = set.subcategory) === null || _set$subcategory === void 0 ? void 0 : _set$subcategory.id);
216
162
  return categoryPath ? /*#__PURE__*/_react["default"].createElement(LinkContainer, {
217
163
  key: "categorySet-".concat(index)
218
- }, genLink("/categories/".concat(categoryPath), set === null || set === void 0 ? void 0 : (_set$category2 = set.category) === null || _set$category2 === void 0 ? void 0 : _set$category2.name, true), subcategoryPath && set !== null && set !== void 0 && (_set$subcategory2 = set.subcategory) !== null && _set$subcategory2 !== void 0 && _set$subcategory2.name ? genLink("/categories/".concat(categoryPath, "/").concat(subcategoryPath), set.subcategory.name) : genLink("/categories/".concat(categoryPath), '全部')) : null;
164
+ }, genLink("/categories/".concat(categoryPath), set === null || set === void 0 || (_set$category2 = set.category) === null || _set$category2 === void 0 ? void 0 : _set$category2.name, true), subcategoryPath && set !== null && set !== void 0 && (_set$subcategory2 = set.subcategory) !== null && _set$subcategory2 !== void 0 && _set$subcategory2.name ? genLink("/categories/".concat(categoryPath, "/").concat(subcategoryPath), set.subcategory.name) : genLink("/categories/".concat(categoryPath), '全部')) : null;
219
165
  });
220
-
221
166
  return /*#__PURE__*/_react["default"].createElement(CategorySetFlexBox, null, categorySetJSX);
222
167
  };
223
-
224
168
  CategorySet.propTypes = {
225
169
  categorySet: _propTypes["default"].array
226
170
  };
227
-
228
171
  var Metadata = /*#__PURE__*/function (_PureComponent) {
229
172
  _inherits(Metadata, _PureComponent);
230
-
231
173
  var _super = _createSuper(Metadata);
232
-
233
174
  function Metadata() {
234
175
  _classCallCheck(this, Metadata);
235
-
236
176
  return _super.apply(this, arguments);
237
177
  }
238
-
239
178
  _createClass(Metadata, [{
240
179
  key: "renderTagsSection",
241
180
  value: function renderTagsSection() {
@@ -255,7 +194,6 @@ var Metadata = /*#__PURE__*/function (_PureComponent) {
255
194
  if (authors.length === 0) {
256
195
  return null;
257
196
  }
258
-
259
197
  return /*#__PURE__*/_react["default"].createElement(AuthorRow, null, /*#__PURE__*/_react["default"].createElement(AuthorJobTitle, null, label), /*#__PURE__*/_react["default"].createElement(AngledSeparationLine, null), /*#__PURE__*/_react["default"].createElement(AuthorNames, null, /*#__PURE__*/_react["default"].createElement(_dynamicComponentsContext["default"].Consumer, null, function (components) {
260
198
  return _.map(authors, function (author) {
261
199
  return /*#__PURE__*/_react["default"].createElement(components.Link, {
@@ -271,19 +209,19 @@ var Metadata = /*#__PURE__*/function (_PureComponent) {
271
209
  key: "renderAuthorsSection",
272
210
  value: function renderAuthorsSection() {
273
211
  var _this$props = this.props,
274
- designers = _this$props.designers,
275
- engineers = _this$props.engineers,
276
- photographers = _this$props.photographers,
277
- writers = _this$props.writers,
278
- rawAutherText = _this$props.rawAutherText;
212
+ designers = _this$props.designers,
213
+ engineers = _this$props.engineers,
214
+ photographers = _this$props.photographers,
215
+ writers = _this$props.writers,
216
+ rawAutherText = _this$props.rawAutherText;
279
217
  return /*#__PURE__*/_react["default"].createElement(AuthorSection, null, this.renderAuthorsRow('文字', writers), this.renderAuthorsRow('攝影', photographers), this.renderAuthorsRow('設計', designers), this.renderAuthorsRow('工程', engineers), /*#__PURE__*/_react["default"].createElement(RawAuthorText, null, rawAutherText));
280
218
  }
281
219
  }, {
282
220
  key: "render",
283
221
  value: function render() {
284
222
  var _this$props2 = this.props,
285
- categorySet = _this$props2.categorySet,
286
- date = _this$props2.date;
223
+ categorySet = _this$props2.categorySet,
224
+ date = _this$props2.date;
287
225
  var dateStr = date ? new Date(date).toLocaleString('zh-hant', {
288
226
  year: 'numeric',
289
227
  month: 'numeric',
@@ -294,12 +232,9 @@ var Metadata = /*#__PURE__*/function (_PureComponent) {
294
232
  }), /*#__PURE__*/_react["default"].createElement(DateSection, null, dateStr), this.renderAuthorsSection(), this.renderTagsSection());
295
233
  }
296
234
  }]);
297
-
298
235
  return Metadata;
299
236
  }(_react.PureComponent);
300
-
301
237
  _defineProperty(Metadata, "propTypes", _aside["default"].metadata);
302
-
303
238
  _defineProperty(Metadata, "defaultProps", {
304
239
  categorySet: [],
305
240
  tags: [],
@@ -309,6 +244,4 @@ _defineProperty(Metadata, "defaultProps", {
309
244
  engineers: [],
310
245
  rawAutherText: ''
311
246
  });
312
-
313
- var _default = Metadata;
314
- exports["default"] = _default;
247
+ var _default = exports["default"] = Metadata;