@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,100 +1,69 @@
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 _theme = _interopRequireDefault(require("../../constants/theme"));
21
-
22
14
  var _anchor = require("../../constants/anchor");
23
-
24
15
  var _theme2 = require("./utils/theme");
25
-
26
16
  var _hook = require("@twreporter/react-components/lib/hook");
27
-
28
17
  var _bookmarkWidget = _interopRequireDefault(require("@twreporter/react-components/lib/bookmark-widget"));
29
-
30
18
  var _icon = require("@twreporter/react-components/lib/icon");
31
-
32
19
  var _button = require("@twreporter/react-components/lib/button");
33
-
34
20
  var _snackBar = require("@twreporter/react-components/lib/snack-bar");
35
-
36
21
  var _zIndex = _interopRequireDefault(require("@twreporter/core/lib/constants/z-index"));
37
-
38
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
-
40
- 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); }
41
-
42
- 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; }
43
-
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
-
46
- 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; }
47
-
23
+ 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); }
24
+ 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; }
25
+ 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; }
26
+ 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; }
48
27
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
49
-
50
- 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; }
51
-
28
+ 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; }
29
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
+ 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); }
52
31
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
53
-
54
32
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
55
-
56
33
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
57
-
58
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
59
-
60
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
61
-
34
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
35
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
62
36
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
63
-
37
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
64
38
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
65
-
66
- 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); }); }; }
67
-
39
+ 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); }); }; } // context
40
+ // constant
41
+ // util
42
+ // @twreporter
68
43
  // global var
69
44
  var ToolBarContext = /*#__PURE__*/(0, _react.createContext)();
70
45
  var defaultFbAppID = '962589903815787';
71
-
72
46
  var defaultFunc = function defaultFunc() {};
73
-
74
47
  var ButtonContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
75
48
  displayName: "mobile-tool-bar__ButtonContainer",
76
49
  componentId: "do65sv-0"
77
50
  })(["display:flex;flex-direction:column;align-items:center;width:50px;margin-right:8px;&:last-child{margin-right:0;}"]);
78
-
79
51
  var ShareContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
80
52
  displayName: "mobile-tool-bar__ShareContainer",
81
53
  componentId: "do65sv-1"
82
54
  })(["display:flex;align-items:center;padding:8px;border-radius:50%;margin-right:8px;&:last-child{margin-right:0;}"]);
83
-
84
55
  var OptionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
85
56
  displayName: "mobile-tool-bar__OptionContainer",
86
57
  componentId: "do65sv-2"
87
58
  })(["z-index:6;opacity:", ";transition:opacity 100ms;position:absolute;top:-55px;left:50%;transform:translateX(-50%);display:flex;"], function (props) {
88
59
  return props.$isShow ? '1' : '0';
89
60
  });
90
-
91
61
  var SnackBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
92
62
  displayName: "mobile-tool-bar__SnackBarContainer",
93
63
  componentId: "do65sv-3"
94
64
  })(["z-index:5;position:absolute;left:50%;transform:translateX(-50%);transition:opacity 100ms;opacity:", ";"], function (props) {
95
65
  return props.$showSnackBar ? 1 : 0;
96
66
  });
97
-
98
67
  var ToolBarWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
99
68
  displayName: "mobile-tool-bar__ToolBarWrapper",
100
69
  componentId: "do65sv-4"
@@ -113,24 +82,20 @@ var ToolBarWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
113
82
  }, SnackBarContainer, function (props) {
114
83
  return props.$hideText ? '48px' : '62px';
115
84
  });
116
-
117
85
  var ToolBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
118
86
  displayName: "mobile-tool-bar__ToolBarContainer",
119
87
  componentId: "do65sv-5"
120
88
  })(["display:flex;width:100%;max-width:560px;justify-content:space-evenly;align-items:center;"]);
121
-
122
89
  var FbShare = function FbShare(_ref) {
123
90
  var appID = _ref.appID;
124
91
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
125
92
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
126
93
  var releaseBranch = themeContext.releaseBranch;
127
-
128
94
  var shareToFb = function shareToFb() {
129
95
  var currentURL = window.location.href;
130
96
  var location = 'https://www.facebook.com/dialog/feed?' + 'display=page' + "&app_id=".concat(appID) + "&link=".concat(encodeURIComponent(currentURL)) + "&redirect_uri=".concat(encodeURIComponent('https://www.facebook.com/'));
131
97
  window.open(location, '_blank');
132
98
  };
133
-
134
99
  return /*#__PURE__*/_react["default"].createElement(ShareContainer, {
135
100
  id: "fb-share",
136
101
  onClick: shareToFb
@@ -141,22 +106,18 @@ var FbShare = function FbShare(_ref) {
141
106
  theme: theme
142
107
  }));
143
108
  };
144
-
145
109
  FbShare.propTypes = {
146
110
  appID: _aside["default"].tools.fbAppID
147
111
  };
148
-
149
112
  var LineShare = function LineShare() {
150
113
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
151
114
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
152
115
  var releaseBranch = themeContext.releaseBranch;
153
-
154
116
  var shareToLine = function shareToLine() {
155
117
  var currentURL = window.location.href;
156
118
  var location = "https://social-plugins.line.me/lineit/share?url=".concat(encodeURIComponent(currentURL));
157
119
  window.open(location, '_blank');
158
120
  };
159
-
160
121
  return /*#__PURE__*/_react["default"].createElement(ShareContainer, {
161
122
  id: "line-share",
162
123
  onClick: shareToLine
@@ -167,18 +128,15 @@ var LineShare = function LineShare() {
167
128
  theme: theme
168
129
  }));
169
130
  };
170
-
171
131
  var TwitterShare = function TwitterShare() {
172
132
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
173
133
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
174
134
  var releaseBranch = themeContext.releaseBranch;
175
-
176
135
  var shareToTwitter = function shareToTwitter() {
177
136
  var currentURL = window.location.href;
178
137
  var location = 'https://twitter.com/intent/tweet?' + "url=".concat(encodeURIComponent(currentURL), "&text=").concat(encodeURIComponent(document.title + ' #報導者'));
179
138
  window.open(location, '_blank');
180
139
  };
181
-
182
140
  return /*#__PURE__*/_react["default"].createElement(ShareContainer, {
183
141
  id: "twitter-share",
184
142
  onClick: shareToTwitter
@@ -189,49 +147,40 @@ var TwitterShare = function TwitterShare() {
189
147
  theme: theme
190
148
  }));
191
149
  };
192
-
193
150
  var CopyUrl = function CopyUrl(_ref2) {
194
151
  var _ref2$onclick = _ref2.onclick,
195
- onclick = _ref2$onclick === void 0 ? defaultFunc : _ref2$onclick;
152
+ onclick = _ref2$onclick === void 0 ? defaultFunc : _ref2$onclick;
196
153
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
197
154
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
198
155
  var releaseBranch = themeContext.releaseBranch;
199
-
200
156
  var copyUrl = /*#__PURE__*/function () {
201
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
157
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
202
158
  var currentURL;
203
- return regeneratorRuntime.wrap(function _callee$(_context) {
204
- while (1) {
205
- switch (_context.prev = _context.next) {
206
- case 0:
207
- _context.prev = 0;
208
- currentURL = window.location.href;
209
- _context.next = 4;
210
- return navigator.clipboard.writeText(currentURL);
211
-
212
- case 4:
213
- onclick(true);
214
- _context.next = 10;
215
- break;
216
-
217
- case 7:
218
- _context.prev = 7;
219
- _context.t0 = _context["catch"](0);
220
- onclick(false);
221
-
222
- case 10:
223
- case "end":
224
- return _context.stop();
225
- }
159
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
160
+ while (1) switch (_context.prev = _context.next) {
161
+ case 0:
162
+ _context.prev = 0;
163
+ currentURL = window.location.href;
164
+ _context.next = 4;
165
+ return navigator.clipboard.writeText(currentURL);
166
+ case 4:
167
+ onclick(true);
168
+ _context.next = 10;
169
+ break;
170
+ case 7:
171
+ _context.prev = 7;
172
+ _context.t0 = _context["catch"](0);
173
+ onclick(false);
174
+ case 10:
175
+ case "end":
176
+ return _context.stop();
226
177
  }
227
178
  }, _callee, null, [[0, 7]]);
228
179
  }));
229
-
230
180
  return function copyUrl() {
231
181
  return _ref3.apply(this, arguments);
232
182
  };
233
183
  }();
234
-
235
184
  return /*#__PURE__*/_react["default"].createElement(ShareContainer, {
236
185
  onClick: copyUrl
237
186
  }, /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
@@ -241,49 +190,39 @@ var CopyUrl = function CopyUrl(_ref2) {
241
190
  theme: theme
242
191
  }));
243
192
  };
244
-
245
193
  CopyUrl.propTypes = {
246
194
  onclick: _propTypes["default"].func
247
195
  };
248
-
249
196
  var ShareBy = function ShareBy(_ref4) {
250
197
  var fbAppID = _ref4.fbAppID;
251
-
252
198
  var _useState = (0, _react.useState)(false),
253
- _useState2 = _slicedToArray(_useState, 2),
254
- showOption = _useState2[0],
255
- setShowState = _useState2[1];
256
-
199
+ _useState2 = _slicedToArray(_useState, 2),
200
+ showOption = _useState2[0],
201
+ setShowState = _useState2[1];
257
202
  var _useContext = (0, _react.useContext)(ToolBarContext),
258
- hideText = _useContext.hideText,
259
- toastr = _useContext.toastr,
260
- hideToolBar = _useContext.hideToolBar;
261
-
203
+ hideText = _useContext.hideText,
204
+ toastr = _useContext.toastr,
205
+ hideToolBar = _useContext.hideToolBar;
262
206
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
263
207
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
264
208
  var releaseBranch = themeContext.releaseBranch;
265
-
266
209
  var onCopyUrl = function onCopyUrl(isCopied) {
267
210
  if (!isCopied) {
268
211
  return;
269
212
  }
270
-
271
213
  toastr({
272
214
  text: '已複製',
273
215
  timeout: 3000
274
216
  });
275
217
  };
276
-
277
218
  var onButtonClick = function onButtonClick() {
278
219
  return setShowState(function (prevValue) {
279
220
  return !prevValue;
280
221
  });
281
222
  };
282
-
283
223
  var onClickOutside = function onClickOutside() {
284
224
  return setShowState(false);
285
225
  };
286
-
287
226
  var ref = (0, _hook.useOutsideClick)(onClickOutside);
288
227
  (0, _react.useEffect)(function () {
289
228
  if (hideToolBar) {
@@ -308,17 +247,13 @@ var ShareBy = function ShareBy(_ref4) {
308
247
  onclick: onCopyUrl
309
248
  })));
310
249
  };
311
-
312
250
  ShareBy.propTypes = {
313
251
  fbAppID: _aside["default"].tools.fbAppID
314
252
  };
315
-
316
253
  var FontLevel = function FontLevel(_ref5) {
317
254
  var changeFontLevel = _ref5.changeFontLevel;
318
-
319
255
  var _useContext2 = (0, _react.useContext)(ToolBarContext),
320
- hideText = _useContext2.hideText;
321
-
256
+ hideText = _useContext2.hideText;
322
257
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
323
258
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
324
259
  var releaseBranch = themeContext.releaseBranch;
@@ -333,64 +268,50 @@ var FontLevel = function FontLevel(_ref5) {
333
268
  hideText: hideText
334
269
  }));
335
270
  };
336
-
337
271
  FontLevel.propTypes = {
338
272
  changeFontLevel: _aside["default"].tools.onFontLevelChange
339
273
  };
340
-
341
274
  var BookmarkBlock = function BookmarkBlock(_ref6) {
342
275
  var articleMeta = _ref6.articleMeta;
343
-
344
276
  var _useContext3 = (0, _react.useContext)(ToolBarContext),
345
- hideText = _useContext3.hideText,
346
- toastr = _useContext3.toastr;
347
-
277
+ hideText = _useContext3.hideText,
278
+ toastr = _useContext3.toastr;
348
279
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
349
280
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
350
281
  var releaseBranch = themeContext.releaseBranch;
351
-
352
282
  var renderIcon = function renderIcon(isBookmarked, addAction, removeAction) {
353
283
  var iconType = isBookmarked ? 'saved' : 'add';
354
284
  var text = isBookmarked ? '已收藏' : '收藏';
355
285
  var id = isBookmarked ? 'remove-bookmark' : 'add-bookmark';
356
-
357
286
  var handleClick = /*#__PURE__*/function () {
358
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
287
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
359
288
  var action;
360
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
361
- while (1) {
362
- switch (_context2.prev = _context2.next) {
363
- case 0:
364
- action = isBookmarked ? removeAction : addAction;
365
- _context2.prev = 1;
366
- _context2.next = 4;
367
- return action();
368
-
369
- case 4:
370
- _context2.next = 9;
371
- break;
372
-
373
- case 6:
374
- _context2.prev = 6;
375
- _context2.t0 = _context2["catch"](1);
376
- console.error('add bookmark fail', _context2.t0);
377
-
378
- case 9:
379
- onClickButton(isBookmarked);
380
-
381
- case 10:
382
- case "end":
383
- return _context2.stop();
384
- }
289
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
290
+ while (1) switch (_context2.prev = _context2.next) {
291
+ case 0:
292
+ action = isBookmarked ? removeAction : addAction;
293
+ _context2.prev = 1;
294
+ _context2.next = 4;
295
+ return action();
296
+ case 4:
297
+ _context2.next = 9;
298
+ break;
299
+ case 6:
300
+ _context2.prev = 6;
301
+ _context2.t0 = _context2["catch"](1);
302
+ console.error('add bookmark fail', _context2.t0);
303
+ case 9:
304
+ onClickButton(isBookmarked);
305
+ case 10:
306
+ case "end":
307
+ return _context2.stop();
385
308
  }
386
309
  }, _callee2, null, [[1, 6]]);
387
310
  }));
388
-
389
311
  return function handleClick() {
390
312
  return _ref7.apply(this, arguments);
391
313
  };
392
314
  }();
393
-
394
315
  return /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
395
316
  onClick: handleClick,
396
317
  id: id
@@ -404,7 +325,6 @@ var BookmarkBlock = function BookmarkBlock(_ref6) {
404
325
  hideText: hideText
405
326
  }));
406
327
  };
407
-
408
328
  var onClickButton = function onClickButton(isBookmarked) {
409
329
  var text = isBookmarked ? '已取消收藏' : '已收藏';
410
330
  toastr({
@@ -412,24 +332,19 @@ var BookmarkBlock = function BookmarkBlock(_ref6) {
412
332
  timeout: 3000
413
333
  });
414
334
  };
415
-
416
335
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_bookmarkWidget["default"], {
417
336
  toAutoCheck: true,
418
337
  articleMeta: articleMeta,
419
338
  renderIcon: renderIcon
420
339
  }));
421
340
  };
422
-
423
341
  BookmarkBlock.propTypes = {
424
342
  articleMeta: _aside["default"].tools.articleMetaForBookmark
425
343
  };
426
-
427
344
  var BackToTopic = function BackToTopic(_ref8) {
428
345
  var backToTopic = _ref8.backToTopic;
429
-
430
346
  var _useContext4 = (0, _react.useContext)(ToolBarContext),
431
- hideText = _useContext4.hideText;
432
-
347
+ hideText = _useContext4.hideText;
433
348
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
434
349
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
435
350
  var releaseBranch = themeContext.releaseBranch;
@@ -447,21 +362,16 @@ var BackToTopic = function BackToTopic(_ref8) {
447
362
  })));
448
363
  });
449
364
  };
450
-
451
365
  BackToTopic.propTypes = {
452
366
  backToTopic: _aside["default"].tools.backToTopic
453
367
  };
454
-
455
368
  var RelatedPost = function RelatedPost() {
456
369
  var _useContext5 = (0, _react.useContext)(ToolBarContext),
457
- hideText = _useContext5.hideText;
458
-
370
+ hideText = _useContext5.hideText;
459
371
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
460
372
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
461
373
  var releaseBranch = themeContext.releaseBranch;
462
-
463
374
  var anchorScrollAttr = _defineProperty({}, _anchor.ARTICLE_ANCHOR_SCROLL, 'true');
464
-
465
375
  return /*#__PURE__*/_react["default"].createElement(ButtonContainer, null, /*#__PURE__*/_react["default"].createElement("a", _extends({
466
376
  href: "#".concat(_anchor.RELATED_POST_ANCHOR_ID)
467
377
  }, anchorScrollAttr), /*#__PURE__*/_react["default"].createElement(_button.IconWithTextButton, {
@@ -473,28 +383,24 @@ var RelatedPost = function RelatedPost() {
473
383
  hideText: hideText
474
384
  })));
475
385
  };
476
-
477
386
  var ToolBar = function ToolBar(_ref9) {
478
387
  var backToTopic = _ref9.backToTopic,
479
- _ref9$fbAppID = _ref9.fbAppID,
480
- fbAppID = _ref9$fbAppID === void 0 ? defaultFbAppID : _ref9$fbAppID,
481
- articleMetaForBookmark = _ref9.articleMetaForBookmark,
482
- onFontLevelChange = _ref9.onFontLevelChange,
483
- className = _ref9.className,
484
- scrollStage = _ref9.scrollStage;
388
+ _ref9$fbAppID = _ref9.fbAppID,
389
+ fbAppID = _ref9$fbAppID === void 0 ? defaultFbAppID : _ref9$fbAppID,
390
+ articleMetaForBookmark = _ref9.articleMetaForBookmark,
391
+ onFontLevelChange = _ref9.onFontLevelChange,
392
+ className = _ref9.className,
393
+ scrollStage = _ref9.scrollStage;
485
394
  var themeContext = (0, _react.useContext)(_styledComponents.ThemeContext);
486
395
  var theme = themeContext.name === _theme["default"].article.v2.photo ? 'photography' : 'normal';
487
-
488
396
  var _getToolBarTheme = (0, _theme2.getToolBarTheme)(themeContext.name),
489
- bgColor = _getToolBarTheme.bgColor,
490
- borderColor = _getToolBarTheme.borderColor,
491
- shareByBgColor = _getToolBarTheme.shareByBgColor;
492
-
397
+ bgColor = _getToolBarTheme.bgColor,
398
+ borderColor = _getToolBarTheme.borderColor,
399
+ shareByBgColor = _getToolBarTheme.shareByBgColor;
493
400
  var _useSnackBar = (0, _snackBar.useSnackBar)(),
494
- showSnackBar = _useSnackBar.showSnackBar,
495
- snackBarText = _useSnackBar.snackBarText,
496
- toastr = _useSnackBar.toastr;
497
-
401
+ showSnackBar = _useSnackBar.showSnackBar,
402
+ snackBarText = _useSnackBar.snackBarText,
403
+ toastr = _useSnackBar.toastr;
498
404
  var backToTopicJSX = backToTopic ? /*#__PURE__*/_react["default"].createElement(BackToTopic, {
499
405
  backToTopic: backToTopic
500
406
  }) : null;
@@ -528,9 +434,7 @@ var ToolBar = function ToolBar(_ref9) {
528
434
  theme: theme
529
435
  }))));
530
436
  };
531
-
532
437
  ToolBar.propTypes = _objectSpread(_objectSpread({}, _aside["default"].tools), {}, {
533
438
  scrollStage: _propTypes["default"].number
534
439
  });
535
- var _default = ToolBar;
536
- exports["default"] = _default;
440
+ var _default = exports["default"] = ToolBar;
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getToolBarTheme = exports["default"] = void 0;
7
-
8
7
  var _theme = _interopRequireDefault(require("../../../constants/theme"));
9
-
10
8
  var _color = require("@twreporter/core/lib/constants/color");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  // constants
11
+
15
12
  // @twreporter
16
- var getToolBarTheme = function getToolBarTheme(theme) {
13
+
14
+ var getToolBarTheme = exports.getToolBarTheme = function getToolBarTheme(theme) {
17
15
  switch (theme) {
18
16
  case _theme["default"].article.v2.photo:
19
17
  return {
@@ -21,7 +19,6 @@ var getToolBarTheme = function getToolBarTheme(theme) {
21
19
  shareByBgColor: _color.colorPhoto.dark,
22
20
  borderColor: _color.colorPhoto.heavy
23
21
  };
24
-
25
22
  case _theme["default"].article.v2["default"]:
26
23
  default:
27
24
  return {
@@ -31,9 +28,6 @@ var getToolBarTheme = function getToolBarTheme(theme) {
31
28
  };
32
29
  }
33
30
  };
34
-
35
- exports.getToolBarTheme = getToolBarTheme;
36
- var _default = {
31
+ var _default = exports["default"] = {
37
32
  getToolBarTheme: getToolBarTheme
38
- };
39
- exports["default"] = _default;
33
+ };