@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
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _layoutManager = _interopRequireDefault(require("./layout-manager"));
9
-
10
8
  var _themeManager = _interopRequireDefault(require("./theme-manager"));
11
-
12
9
  var _get = _interopRequireDefault(require("lodash/get"));
13
-
14
10
  var _theme = _interopRequireDefault(require("../constants/theme"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
12
+ 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); }
18
13
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
-
20
- 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); } }
21
-
14
+ 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); } }
22
15
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
-
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ 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); }
24
18
  var _ = {
25
19
  get: _get["default"]
26
20
  };
@@ -29,12 +23,12 @@ var _heroImageSize = {
29
23
  fullscreen: 'fullscreen',
30
24
  extend: 'extend'
31
25
  };
26
+
32
27
  /**
33
28
  * @module UIManager
34
29
  * @exports
35
30
  */
36
-
37
- var UIManager = /*#__PURE__*/function () {
31
+ var UIManager = exports["default"] = /*#__PURE__*/function () {
38
32
  /**
39
33
  * @param {module:Article:PostObject} post
40
34
  * @param {module:Article:TopicObject} relatedTopic
@@ -42,71 +36,69 @@ var UIManager = /*#__PURE__*/function () {
42
36
  */
43
37
  function UIManager(post, relatedTopic) {
44
38
  _classCallCheck(this, UIManager);
45
-
46
39
  this.post = post || {};
47
40
  this.relatedTopic = relatedTopic || {};
48
41
  this.layoutManager = new _layoutManager["default"](this.post, this.relatedTopic, this.getTheme());
49
42
  this.themeManager = new _themeManager["default"](this.getTheme());
50
43
  }
44
+
51
45
  /**
52
46
  * @returns {string} - Size of leading image
53
47
  */
54
-
55
-
56
48
  _createClass(UIManager, [{
57
49
  key: "getLeadingImageSize",
58
50
  value: function getLeadingImageSize() {
59
51
  return _.get(this.post, 'hero_image_size', _heroImageSize.normal);
60
52
  }
53
+
61
54
  /**
62
55
  * @returns {string} - Style of post
63
56
  */
64
-
65
57
  }, {
66
58
  key: "getTheme",
67
59
  value: function getTheme() {
68
60
  return _.get(this.post, 'style', _theme["default"].article.v2["default"]);
69
61
  }
62
+
70
63
  /**
71
64
  * @returns {Object} - Instance of `LayoutManager`
72
65
  */
73
-
74
66
  }, {
75
67
  key: "getLayoutManager",
76
68
  value: function getLayoutManager() {
77
69
  return this.layoutManager;
78
70
  }
71
+
79
72
  /**
80
73
  * @returns {Object} - Instance of `ThemeManager`
81
74
  */
82
-
83
75
  }, {
84
76
  key: "getThemeManager",
85
77
  value: function getThemeManager() {
86
78
  return this.themeManager;
87
79
  }
80
+
88
81
  /**
89
82
  * @returns {module:ThemeManager:ThemeColors} - A set of colors
90
83
  */
91
-
92
84
  }, {
93
85
  key: "getThemeColors",
94
86
  value: function getThemeColors() {
95
87
  return this.getThemeManager().getColors();
96
88
  }
89
+
97
90
  /**
98
91
  * @returns {Function} - React component
99
92
  */
100
-
101
93
  }, {
102
94
  key: "getLeadingComponent",
103
95
  value: function getLeadingComponent() {
104
96
  return this.getLayoutManager().getLeadingComponent();
105
97
  }
98
+
106
99
  /**
107
100
  * @returns {Object} - props of leading React component
108
101
  */
109
-
110
102
  }, {
111
103
  key: "getLeadingComponentProps",
112
104
  value: function getLeadingComponentProps() {
@@ -118,12 +110,8 @@ var UIManager = /*#__PURE__*/function () {
118
110
  if (this.getTheme() === _theme["default"].article.v2["default"] && this.getLeadingImageSize() !== _heroImageSize.fullscreen && this.getLeadingImageSize() !== _heroImageSize.extend) {
119
111
  return true;
120
112
  }
121
-
122
113
  return false;
123
114
  }
124
115
  }]);
125
-
126
116
  return UIManager;
127
- }();
128
-
129
- exports["default"] = UIManager;
117
+ }();
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getSrcsetString = void 0;
7
-
8
7
  var _get = _interopRequireDefault(require("lodash/get"));
9
-
10
8
  var _map = _interopRequireDefault(require("lodash/map"));
11
-
12
9
  var _storageUrlProcessor = require("@twreporter/core/lib/utils/storage-url-processor");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  // lodash
12
+
17
13
  var _ = {
18
14
  get: _get["default"],
19
15
  map: _map["default"]
20
16
  };
17
+
21
18
  /**
22
19
  * @typedef Image - An image object with its url and width
23
20
  * @property {string} url
@@ -29,25 +26,19 @@ var _ = {
29
26
  * @param {Image} image
30
27
  * @returns
31
28
  */
32
-
33
29
  function buildImageCandidateString(image) {
34
30
  var url = (0, _storageUrlProcessor.replaceGCSUrlOrigin)(_.get(image, 'url'));
35
-
36
31
  var elementRenderedMaxWidth = _.get(image, 'width');
37
-
38
32
  if (url && elementRenderedMaxWidth) {
39
33
  return "".concat(url, " ").concat(elementRenderedMaxWidth, "w");
40
34
  }
41
35
  }
36
+
42
37
  /**
43
38
  * Get srcset for img tag
44
39
  * @param {Image[]} imageSet
45
40
  * @return {string} the value of srcset attribute
46
41
  */
47
-
48
-
49
- var getSrcsetString = function getSrcsetString(imageSet) {
42
+ var getSrcsetString = exports.getSrcsetString = function getSrcsetString(imageSet) {
50
43
  return _.map(imageSet, buildImageCandidateString).filter(Boolean).join(', ');
51
- };
52
-
53
- exports.getSrcsetString = getSrcsetString;
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twreporter/react-article-components",
3
- "version": "2.2.0-rc.0",
3
+ "version": "2.2.0-rc.1",
4
4
  "description": "The Reporter react article components, which are used in article page",
5
5
  "main": "lib/components/article-page.js",
6
6
  "repository": "https://github.com/twreporter/twreporter-npm-packages.git",
@@ -17,7 +17,6 @@
17
17
  "babel-loader": "^8.0.6",
18
18
  "html-webpack-plugin": "^3.2.0",
19
19
  "react-dom": "^18.2.0",
20
- "react-redux": "^6.0.0",
21
20
  "regenerator-runtime": "^0.13.2",
22
21
  "webpack": "^4.38.0",
23
22
  "webpack-cli": "^3.3.6",
@@ -25,14 +24,15 @@
25
24
  },
26
25
  "dependencies": {
27
26
  "@twreporter/core": "^1.22.1",
28
- "@twreporter/react-components": "^9.0.3-rc.0",
29
- "@twreporter/redux": "^8.0.2",
30
- "@twreporter/universal-header": "^3.0.3-rc.0",
27
+ "@twreporter/react-components": "^9.1.0-rc.0",
28
+ "@twreporter/redux": "^8.0.3-rc.0",
29
+ "@twreporter/universal-header": "^3.0.3-rc.1",
31
30
  "howler": "^2.2.3",
32
31
  "lodash": "^4.17.11",
33
32
  "memoize-one": "^5.0.5",
34
33
  "prop-types": "^15.0.0",
35
34
  "react": "^18.2.0",
35
+ "react-redux": "^9.1.2",
36
36
  "react-waypoint": "^10.3.0",
37
37
  "smooth-scroll": "16.1.3",
38
38
  "styled-components": "^6.0.0",
@@ -41,5 +41,5 @@
41
41
  "files": [
42
42
  "lib"
43
43
  ],
44
- "gitHead": "ce3c5ec8cd131df3f79db9cabb6269a1d14c5dbd"
44
+ "gitHead": "df79295a50f202d6ed016de4e91bbbc0899a3882"
45
45
  }