@comicrelief/component-library 7.20.0 → 7.22.0

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 (101) hide show
  1. package/cypress/{integration/components/atoms/button.spec.js → e2e/components/atoms/button.cy.js} +4 -15
  2. package/cypress/{integration/components/atoms/buttonWithStates.spec.js → e2e/components/atoms/buttonWithStates.cy.js} +5 -11
  3. package/cypress/{integration/components/atoms/checkbox.spec.js → e2e/components/atoms/checkbox.cy.js} +2 -0
  4. package/cypress/{integration/components/atoms/confetti.spec.js → e2e/components/atoms/confetti.cy.js} +2 -8
  5. package/cypress/{integration/components/atoms/errorText.spec.js → e2e/components/atoms/errorText.cy.js} +1 -7
  6. package/cypress/{integration/components/atoms/input.spec.js → e2e/components/atoms/input.cy.js} +4 -14
  7. package/cypress/{integration/components/atoms/label.spec.js → e2e/components/atoms/label.cy.js} +3 -14
  8. package/cypress/{integration/components/atoms/link.spec.js → e2e/components/atoms/link.cy.js} +4 -21
  9. package/cypress/{integration/components/atoms/logo.spec.js → e2e/components/atoms/logo.cy.js} +4 -21
  10. package/cypress/{integration/components/atoms/pagination.spec.js → e2e/components/atoms/pagination.cy.js} +5 -28
  11. package/cypress/{integration/components/atoms/picture.spec.js → e2e/components/atoms/picture.cy.js} +4 -21
  12. package/cypress/{integration/components/atoms/radioButton.spec.js → e2e/components/atoms/radioButton.cy.js} +2 -7
  13. package/cypress/{integration/components/atoms/richText.spec.js → e2e/components/atoms/richText.cy.js} +2 -7
  14. package/cypress/{integration/components/atoms/select.spec.js → e2e/components/atoms/select.cy.js} +2 -7
  15. package/cypress/{integration/components/atoms/socialIcons.spec.js → e2e/components/atoms/socialIcons.cy.js} +4 -21
  16. package/cypress/{integration/components/atoms/text.spec.js → e2e/components/atoms/text.cy.js} +3 -14
  17. package/cypress/{integration/components/atoms/textArea.spec.js → e2e/components/atoms/textArea.cy.js} +2 -4
  18. package/cypress/{integration/components/atoms/textInputWithDrop.spec.js → e2e/components/atoms/textInputWithDrop.cy.js} +2 -4
  19. package/cypress/{integration/components/molecules/accordion.spec.js → e2e/components/molecules/accordion.cy.js} +2 -7
  20. package/cypress/{integration/components/molecules/articleTeaser.spec.js → e2e/components/molecules/articleTeaser.cy.js} +2 -7
  21. package/cypress/{integration/components/molecules/banner.spec.js → e2e/components/molecules/banner.cy.js} +2 -7
  22. package/cypress/{integration/components/molecules/box.spec.js → e2e/components/molecules/box.cy.js} +3 -11
  23. package/cypress/{integration/components/molecules/card.spec.js → e2e/components/molecules/card.cy.js} +3 -11
  24. package/cypress/{integration/components/molecules/cardDs.spec.js → e2e/components/molecules/cardDs.cy.js} +5 -30
  25. package/cypress/{integration/components/molecules/chip.spec.js → e2e/components/molecules/chip.cy.js} +2 -4
  26. package/cypress/{integration/components/molecules/countdown.spec.js → e2e/components/molecules/countdown.cy.js} +2 -4
  27. package/cypress/{integration/components/molecules/descriptor.spec.js → e2e/components/molecules/descriptor.cy.js} +3 -8
  28. package/cypress/{integration/components/molecules/doubleCopy.spec.js → e2e/components/molecules/doubleCopy.cy.js} +2 -4
  29. package/cypress/{integration/components/molecules/heroBanner.spec.js → e2e/components/molecules/heroBanner.cy.js} +2 -4
  30. package/cypress/{integration/components/molecules/infoBanner.spec.js → e2e/components/molecules/infoBanner.cy.js} +2 -4
  31. package/cypress/{integration/components/molecules/partnerLink.spec.js → e2e/components/molecules/partnerLink.cy.js} +2 -4
  32. package/cypress/{integration/components/molecules/promo.spec.js → e2e/components/molecules/promo.cy.js} +2 -4
  33. package/cypress/{integration/components/molecules/schoolLookup.spec.js → e2e/components/molecules/schoolLookup.cy.js} +3 -4
  34. package/cypress/{integration/components/molecules/searchInput.spec.js → e2e/components/molecules/searchInput.cy.js} +2 -4
  35. package/cypress/{integration/components/molecules/searchResult.spec.js → e2e/components/molecules/searchResult.cy.js} +5 -16
  36. package/cypress/{integration/components/molecules/shareButton.spec.js → e2e/components/molecules/shareButton.cy.js} +2 -4
  37. package/cypress/{integration/components/molecules/simpleSchoolLookup.spec.js → e2e/components/molecules/simpleSchoolLookup.cy.js} +3 -4
  38. package/cypress/{integration/components/molecules/singleMessage.spec.js → e2e/components/molecules/singleMessage.cy.js} +14 -49
  39. package/cypress/{integration/components/molecules/singleMessageDs.spec.js → e2e/components/molecules/singleMessageDs.cy.js} +6 -20
  40. package/cypress/{integration/components/molecules/typeahead.spec.js → e2e/components/molecules/typeahead.cy.js} +3 -4
  41. package/cypress/{integration/components/molecules/videoBanner.spec.js → e2e/components/molecules/videoBanner.cy.js} +4 -12
  42. package/cypress/{integration/components/organisms/cookieBanner.spec.js → e2e/components/organisms/cookieBanner.cy.js} +2 -4
  43. package/cypress/{integration/components/organisms/donate.spec.js → e2e/components/organisms/donate.cy.js} +5 -16
  44. package/cypress/{integration/components/organisms/emailSignUp.spec.js → e2e/components/organisms/emailSignUp.cy.js} +1 -4
  45. package/cypress/{integration/components/organisms/footer.spec.js → e2e/components/organisms/footer.cy.js} +2 -0
  46. package/cypress/{integration/components/organisms/header.spec.js → e2e/components/organisms/header.cy.js} +3 -8
  47. package/cypress/{integration/components/organisms/marketingPreferencesDSForm.spec.js → e2e/components/organisms/marketingPreferencesDSForm.cy.js} +44 -56
  48. package/cypress/{integration/components/organisms/membership.spec.js → e2e/components/organisms/membership.cy.js} +3 -8
  49. package/cypress.config.js +15 -0
  50. package/dist/components/Atoms/Link/Link.js +5 -5
  51. package/dist/components/Molecules/Promo/Promo.js +87 -12
  52. package/dist/components/Molecules/Promo/Promo.md +266 -4
  53. package/dist/components/Molecules/Promo/Promo.style.js +24 -6
  54. package/dist/components/Molecules/Promo/Promo.test.js +2 -2
  55. package/dist/components/Molecules/Promo/_ProgressRing.js +57 -0
  56. package/dist/components/Molecules/Promo/_PromoVideo.js +116 -0
  57. package/dist/components/Molecules/Promo/_PromoVideoButton.js +31 -0
  58. package/dist/components/Molecules/Promo/_PromoVideoButton.style.js +110 -0
  59. package/dist/components/Molecules/Promo/assets/Pause--black.svg +3 -0
  60. package/dist/components/Molecules/Promo/assets/Pause--white.svg +3 -0
  61. package/dist/components/Molecules/Promo/assets/Play--black.svg +3 -0
  62. package/dist/components/Molecules/Promo/assets/Play--white.svg +3 -0
  63. package/dist/components/Organisms/Footer/Footer.js +1 -1
  64. package/dist/components/Organisms/Footer/Footer.md +2 -2
  65. package/dist/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +2 -2
  66. package/dist/components/Organisms/Footer/data/data.js +2 -2
  67. package/dist/components/Organisms/Header/Nav/Nav.js +2 -2
  68. package/dist/components/Organisms/Header/data/data.js +2 -2
  69. package/dist/index.js +3 -3
  70. package/dist/styleguide/assets/mobileVideoPosterImage.png +0 -0
  71. package/dist/utils/{whiteListed.js → allowListed.js} +4 -4
  72. package/dist/utils/allowListed.test.js +12 -0
  73. package/docs/utils.md +4 -4
  74. package/package.json +2 -2
  75. package/src/components/Atoms/Link/Link.js +5 -5
  76. package/src/components/Molecules/Promo/Promo.js +89 -13
  77. package/src/components/Molecules/Promo/Promo.md +266 -4
  78. package/src/components/Molecules/Promo/Promo.style.js +23 -2
  79. package/src/components/Molecules/Promo/Promo.test.js +2 -2
  80. package/src/components/Molecules/Promo/_ProgressRing.js +43 -0
  81. package/src/components/Molecules/Promo/_PromoVideo.js +105 -0
  82. package/src/components/Molecules/Promo/_PromoVideoButton.js +26 -0
  83. package/src/components/Molecules/Promo/_PromoVideoButton.style.js +121 -0
  84. package/src/components/Molecules/Promo/assets/Pause--black.svg +3 -0
  85. package/src/components/Molecules/Promo/assets/Pause--white.svg +3 -0
  86. package/src/components/Molecules/Promo/assets/Play--black.svg +3 -0
  87. package/src/components/Molecules/Promo/assets/Play--white.svg +3 -0
  88. package/src/components/Organisms/Footer/Footer.js +2 -2
  89. package/src/components/Organisms/Footer/Footer.md +2 -2
  90. package/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +2 -2
  91. package/src/components/Organisms/Footer/data/data.js +2 -2
  92. package/src/components/Organisms/Header/Nav/Nav.js +2 -2
  93. package/src/components/Organisms/Header/data/data.js +2 -2
  94. package/src/index.js +1 -1
  95. package/src/styleguide/assets/mobileVideoPosterImage.png +0 -0
  96. package/src/utils/{whiteListed.js → allowListed.js} +6 -5
  97. package/src/utils/allowListed.test.js +9 -0
  98. package/cypress.json +0 -6
  99. package/dist/utils/whiteListed.test.js +0 -12
  100. package/src/utils/whiteListed.test.js +0 -9
  101. /package/cypress/support/{index.js → e2e.js} +0 -0
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Icon = exports.PlayButtonWrapper = exports.PlayButton = exports.ProgressRingCircle = exports.ProgressRingSVG = exports.ProgressRingWrapper = void 0;
9
+
10
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
+
12
+ var _PlayWhite = _interopRequireDefault(require("./assets/Play--white.svg"));
13
+
14
+ var _PauseWhite = _interopRequireDefault(require("./assets/Pause--white.svg"));
15
+
16
+ var _PlayBlack = _interopRequireDefault(require("./assets/Play--black.svg"));
17
+
18
+ var _PauseBlack = _interopRequireDefault(require("./assets/Pause--black.svg"));
19
+
20
+ 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); }
21
+
22
+ 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; }
23
+
24
+ var PlayButton = _styledComponents.default.button.withConfig({
25
+ displayName: "_PromoVideoButtonstyle__PlayButton",
26
+ componentId: "sc-17cm3uc-0"
27
+ })(["display:flex;width:50px;height:50px;position:absolute;top:10px;right:10px;align-items:center;justify-content:center;border:0;padding:0;margin:0;border-radius:50%;background:", ";opacity:0.75;transition:opacity 0.2s;&:hover,&:focus{opacity:1.0;}&:focus-visible{outline-style:outset;outline-width:medium;}", " ", " @media ", "{top:20px;right:20px;", "}"], function (_ref) {
28
+ var theme = _ref.theme;
29
+ return theme.color('black');
30
+ }, function (_ref2) {
31
+ var lightColouredVideo = _ref2.lightColouredVideo;
32
+ return !lightColouredVideo && (0, _styledComponents.css)(["background:", ";"], function (_ref3) {
33
+ var theme = _ref3.theme;
34
+ return theme.color('white');
35
+ });
36
+ }, function (_ref4) {
37
+ var copyLeft = _ref4.copyLeft;
38
+ return !copyLeft && (0, _styledComponents.css)(["right:auto;left:10px;"]);
39
+ }, function (_ref5) {
40
+ var theme = _ref5.theme;
41
+ return theme.breakpoint('medium');
42
+ }, function (_ref6) {
43
+ var copyLeft = _ref6.copyLeft;
44
+ return !copyLeft && (0, _styledComponents.css)(["right:auto;left:20px;"]);
45
+ });
46
+
47
+ exports.PlayButton = PlayButton;
48
+
49
+ var PlayButtonWrapper = _styledComponents.default.div.withConfig({
50
+ displayName: "_PromoVideoButtonstyle__PlayButtonWrapper",
51
+ componentId: "sc-17cm3uc-1"
52
+ })(["width:100%;height:100%;position:absolute;top:0;left:0;"]);
53
+
54
+ exports.PlayButtonWrapper = PlayButtonWrapper;
55
+
56
+ var ProgressRingWrapper = _styledComponents.default.span.withConfig({
57
+ displayName: "_PromoVideoButtonstyle__ProgressRingWrapper",
58
+ componentId: "sc-17cm3uc-2"
59
+ })(["position:absolute;width:100%;height:100%;display:flex;"]);
60
+
61
+ exports.ProgressRingWrapper = ProgressRingWrapper;
62
+
63
+ var ProgressRingSVG = _styledComponents.default.svg.withConfig({
64
+ displayName: "_PromoVideoButtonstyle__ProgressRingSVG",
65
+ componentId: "sc-17cm3uc-3"
66
+ })([""]);
67
+
68
+ exports.ProgressRingSVG = ProgressRingSVG;
69
+
70
+ var ProgressRingCircle = _styledComponents.default.circle.withConfig({
71
+ displayName: "_PromoVideoButtonstyle__ProgressRingCircle",
72
+ componentId: "sc-17cm3uc-4"
73
+ })(["z-index:100;transition:stroke-dashoffset 0.5s;transform:rotate(-90deg);transform-origin:50% 50%;stroke-dashoffset:", ";stroke:white;fill:transparent;", " ", ""], function (_ref7) {
74
+ var strokeDashOffsetStyle = _ref7.strokeDashOffsetStyle;
75
+ return strokeDashOffsetStyle;
76
+ }, function (_ref8) {
77
+ var lightColouredVideo = _ref8.lightColouredVideo;
78
+ return !lightColouredVideo && (0, _styledComponents.css)(["stroke:", ";"], function (_ref9) {
79
+ var theme = _ref9.theme;
80
+ return theme.color('black');
81
+ });
82
+ }, function (_ref10) {
83
+ var isRestarting = _ref10.isRestarting;
84
+ return isRestarting && (0, _styledComponents.css)(["transition:none;"]);
85
+ });
86
+
87
+ exports.ProgressRingCircle = ProgressRingCircle;
88
+
89
+ var Icon = _styledComponents.default.span.withConfig({
90
+ displayName: "_PromoVideoButtonstyle__Icon",
91
+ componentId: "sc-17cm3uc-5"
92
+ })(["height:50px;width:50px;background:no-repeat center/50% url(", ") transparent;", " ", " ", " ", ""], _PlayWhite.default, function (_ref11) {
93
+ var lightColouredVideo = _ref11.lightColouredVideo,
94
+ isPlaying = _ref11.isPlaying;
95
+ return lightColouredVideo && !isPlaying && (0, _styledComponents.css)(["background-image:url(", ");"], _PlayWhite.default);
96
+ }, function (_ref12) {
97
+ var lightColouredVideo = _ref12.lightColouredVideo,
98
+ isPlaying = _ref12.isPlaying;
99
+ return lightColouredVideo && isPlaying && (0, _styledComponents.css)(["background-image:url(", ");"], _PauseWhite.default);
100
+ }, function (_ref13) {
101
+ var lightColouredVideo = _ref13.lightColouredVideo,
102
+ isPlaying = _ref13.isPlaying;
103
+ return !lightColouredVideo && !isPlaying && (0, _styledComponents.css)(["background-image:url(", ");"], _PlayBlack.default);
104
+ }, function (_ref14) {
105
+ var lightColouredVideo = _ref14.lightColouredVideo,
106
+ isPlaying = _ref14.isPlaying;
107
+ return !lightColouredVideo && isPlaying && (0, _styledComponents.css)(["background-image:url(", ");"], _PauseBlack.default);
108
+ });
109
+
110
+ exports.Icon = Icon;
@@ -0,0 +1,3 @@
1
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 6C10.8954 6 10 6.89543 10 8V40C10 41.1046 10.8954 42 12 42H17C18.1046 42 19 41.1046 19 40V8C19 6.89543 18.1046 6 17 6H12ZM31 6C29.8954 6 29 6.89543 29 8V40C29 41.1046 29.8954 42 31 42H36C37.1046 42 38 41.1046 38 40V8C38 6.89543 37.1046 6 36 6H31Z" fill="#222222"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 6C10.8954 6 10 6.89543 10 8V40C10 41.1046 10.8954 42 12 42H17C18.1046 42 19 41.1046 19 40V8C19 6.89543 18.1046 6 17 6H12ZM31 6C29.8954 6 29 6.89543 29 8V40C29 41.1046 29.8954 42 31 42H36C37.1046 42 38 41.1046 38 40V8C38 6.89543 37.1046 6 36 6H31Z" fill="#FFFFFF"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M39.6845 22.5846L11.457 6.22056C10.9505 5.92706 10.326 5.92656 9.819 6.21856C9.3125 6.51056 9 7.05156 9 7.63656V40.3641C9 40.9491 9.3125 41.4901 9.8195 41.7821C10.0725 41.9276 10.3545 42.0001 10.6365 42.0001C10.92 42.0001 11.2035 41.9266 11.4575 41.7796L39.685 25.4161C40.189 25.1231 40.5 24.5836 40.5 24.0001C40.5 23.4166 40.189 22.8771 39.6845 22.5846Z" fill="#222222"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M39.6845 22.5846L11.457 6.22056C10.9505 5.92706 10.326 5.92656 9.819 6.21856C9.3125 6.51056 9 7.05156 9 7.63656V40.3641C9 40.9491 9.3125 41.4901 9.8195 41.7821C10.0725 41.9276 10.3545 42.0001 10.6365 42.0001C10.92 42.0001 11.2035 41.9266 11.4575 41.7796L39.685 25.4161C40.189 25.1231 40.5 24.5836 40.5 24.0001C40.5 23.4166 40.189 22.8771 39.6845 22.5846Z" fill="#FFFFFF"/>
3
+ </svg>
@@ -58,7 +58,7 @@ Footer.defaultProps = {
58
58
  navItems: {},
59
59
  footerCopy: '',
60
60
  campaign: 'Comic Relief',
61
- overrideWhiteList: false,
61
+ overrideallowList: false,
62
62
  additionalLegalLine: ''
63
63
  };
64
64
  var _default = Footer;
@@ -8,12 +8,12 @@ import footerCopy from './data/footerCopy';
8
8
  <p>Standard footer</p>
9
9
  <Footer navItems={data} footerCopy={footerCopy.copy} campaign="Comic Relief" />
10
10
 
11
- <p>Overrides whitelist functionality for external usage</p>
11
+ <p>Overrides allowList functionality for external usage</p>
12
12
  <Footer
13
13
  navItems={data}
14
14
  footerCopy={footerCopy.copy}
15
15
  campaign="Comic Relief"
16
- overrideWhiteList
16
+ overrideallowList
17
17
  />
18
18
 
19
19
  <p>Adding a additionalLegalLine to the top of the footer</p>
@@ -1206,7 +1206,7 @@ exports[`renders correctly 1`] = `
1206
1206
  color="white"
1207
1207
  size="s"
1208
1208
  >
1209
- Test whitelisted external link
1209
+ Test allowListed external link
1210
1210
  </span>
1211
1211
  </a>
1212
1212
  </li>
@@ -1226,7 +1226,7 @@ exports[`renders correctly 1`] = `
1226
1226
  color="white"
1227
1227
  size="s"
1228
1228
  >
1229
- Test non-whitelisted external link
1229
+ Test non-allowListed external link
1230
1230
  </span>
1231
1231
  <span
1232
1232
  className="c24"
@@ -151,13 +151,13 @@ var _default = {
151
151
  type: 'ContentfulComponentLink'
152
152
  }
153
153
  }, {
154
- title: 'Test whitelisted external link',
154
+ title: 'Test allowListed external link',
155
155
  url: 'https://www.sportrelief.com',
156
156
  internal: {
157
157
  type: 'ContentfulComponentLink'
158
158
  }
159
159
  }, {
160
- title: 'Test non-whitelisted external link',
160
+ title: 'Test non-allowListed external link',
161
161
  url: 'https://bing.com',
162
162
  internal: {
163
163
  type: 'ContentfulComponentLink'
@@ -23,7 +23,7 @@ var _navHelper = _interopRequireDefault(require("../../../../utils/navHelper"));
23
23
 
24
24
  var _internalLinkHelper = require("../../../../utils/internalLinkHelper");
25
25
 
26
- var _whiteListed = _interopRequireDefault(require("../../../../utils/whiteListed"));
26
+ var _allowListed = _interopRequireDefault(require("../../../../utils/allowListed"));
27
27
 
28
28
  var _chevronDown = _interopRequireDefault(require("./chevron-down.svg"));
29
29
 
@@ -103,7 +103,7 @@ var MainNav = function MainNav(_ref) {
103
103
  /* Determine which field represents our url path */
104
104
 
105
105
  var thisUrl = (0, _navHelper.default)(thisFirstChild);
106
- var relNoopener = !(0, _whiteListed.default)(thisUrl) && 'noopener';
106
+ var relNoopener = !(0, _allowListed.default)(thisUrl) && 'noopener';
107
107
  var hasSubMenu = group.links && group.links.length > 1;
108
108
  var hasPopUp = hasSubMenu ? 'true' : null;
109
109
  thisUrl = (0, _internalLinkHelper.InternalLinkHelper)(thisUrl);
@@ -126,13 +126,13 @@ var _default = {
126
126
  title: 'External Links (menu group)',
127
127
  id: 'eaec5191-bbb3-5e8d-b966-c53fff34998a',
128
128
  links: [{
129
- title: 'Test whitelisted external link',
129
+ title: 'Test allowListed external link',
130
130
  url: 'https://www.sportrelief.com',
131
131
  internal: {
132
132
  type: 'ContentfulComponentLink'
133
133
  }
134
134
  }, {
135
- title: 'Test non-whitelisted external link',
135
+ title: 'Test non-allowListed external link',
136
136
  url: 'https://bing.com',
137
137
  internal: {
138
138
  type: 'ContentfulComponentLink'
package/dist/index.js CHANGED
@@ -35,10 +35,10 @@ Object.defineProperty(exports, "zIndex", {
35
35
  return _zIndex.default;
36
36
  }
37
37
  });
38
- Object.defineProperty(exports, "whiteListed", {
38
+ Object.defineProperty(exports, "allowListed", {
39
39
  enumerable: true,
40
40
  get: function get() {
41
- return _whiteListed.default;
41
+ return _allowListed.default;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "spacing", {
@@ -406,7 +406,7 @@ var _hideVisually = _interopRequireDefault(require("./theme/shared/hideVisually"
406
406
 
407
407
  var _zIndex = _interopRequireDefault(require("./theme/shared/zIndex"));
408
408
 
409
- var _whiteListed = _interopRequireDefault(require("./utils/whiteListed"));
409
+ var _allowListed = _interopRequireDefault(require("./utils/allowListed"));
410
410
 
411
411
  var _spacing = _interopRequireDefault(require("./theme/shared/spacing"));
412
412
 
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var whiteList = ['https://giftaid.comicrelief.com', 'https://donation.comicrelief.com', 'https://www.comicrelief.com', 'https://www.sportrelief.com', 'https://app.beapplied.com/org/comic-relief', 'stories.comicrelief.com'];
7
+ var allowList = ['https://giftaid.comicrelief.com', 'https://donation.comicrelief.com', 'https://www.comicrelief.com', 'https://www.sportrelief.com', 'https://app.beapplied.com/org/comic-relief', 'stories.comicrelief.com', 'https://form.typeform.com'];
8
8
 
9
- var whiteListed = function whiteListed(url) {
10
- if (url !== undefined && url !== null && whiteList.some(function (v) {
9
+ var allowListed = function allowListed(url) {
10
+ if (url !== undefined && url !== null && allowList.some(function (v) {
11
11
  return url.indexOf(v) >= 0;
12
12
  })) {
13
13
  return true;
@@ -16,5 +16,5 @@ var whiteListed = function whiteListed(url) {
16
16
  return false;
17
17
  };
18
18
 
19
- var _default = whiteListed;
19
+ var _default = allowListed;
20
20
  exports.default = _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _allowListed = _interopRequireDefault(require("./allowListed"));
6
+
7
+ it('link is allowListed', function () {
8
+ expect((0, _allowListed.default)('https://www.comicrelief.com/home')).toBe(true);
9
+ });
10
+ it('link is not allowListed', function () {
11
+ expect((0, _allowListed.default)('https://www.google.co.uk/')).toBe(false);
12
+ });
package/docs/utils.md CHANGED
@@ -5,13 +5,13 @@ _Hide Visually_
5
5
  how to use in your styled component
6
6
  `export const Component = styled.span'${hideVisually};';`
7
7
 
8
- _whiteListed_
8
+ _allowListed_
9
9
 
10
- `import { whiteListed } from '@comicrelief/component-library';`
10
+ `import { allowListed } from '@comicrelief/component-library';`
11
11
 
12
- `whiteListed(url)`
12
+ `allowListed(url)`
13
13
 
14
- Check if a url is whiteListed. Used to check links and change link target.
14
+ Check if a url is allowListed. Used to check links and change link target.
15
15
 
16
16
  _Z Index_
17
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "7.20.0",
4
+ "version": "7.22.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "cross-env": "^7.0.3",
78
- "cypress": "^8.3.0",
78
+ "cypress": "13.2.0",
79
79
  "eslint": "^7.32.0",
80
80
  "eslint-config-airbnb": "^18.2.0",
81
81
  "eslint-plugin-import": "^2.27.5",
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
4
  import StyledLink, { HelperText, IconWrapper } from './Link.style';
5
- import whiteListed from '../../../utils/whiteListed';
5
+ import allowListed from '../../../utils/allowListed';
6
6
  import { getDomain } from '../../../utils/internalLinkHelper';
7
7
 
8
8
  let window = '';
@@ -22,7 +22,7 @@ const Link = ({
22
22
  const [documentHost, setDocumentHost] = useState('');
23
23
  /**
24
24
  * If we haven't specifically set the target via props, check if
25
- * this is an internal link OR on our whitelist before making it a '_self' link
25
+ * this is an internal link OR on our allowList before making it a '_self' link
26
26
  */
27
27
  if (target === null) {
28
28
  // Use our helper function to determine the raw domains to compare
@@ -30,7 +30,7 @@ const Link = ({
30
30
  const linkDomain = getDomain(href);
31
31
 
32
32
  // Additional check for applications that need more control
33
- const isWhiteListOverridden = rest.overrideWhiteList === true;
33
+ const isallowListOverridden = rest.overrideallowList === true;
34
34
 
35
35
  /**
36
36
  * If the link has no domain supplied (likely '/' or '#')
@@ -38,9 +38,9 @@ const Link = ({
38
38
  * in a new tab
39
39
  */
40
40
  const isExternalLink = linkDomain !== '' && (currentDomain !== linkDomain);
41
- const isWhiteListed = whiteListed(href);
41
+ const isallowListed = allowListed(href);
42
42
 
43
- window = isExternalLink && (isWhiteListOverridden || !isWhiteListed) ? '_blank' : '_self';
43
+ window = isExternalLink && (isallowListOverridden || !isallowListed) ? '_blank' : '_self';
44
44
  } else {
45
45
  window = target === 'blank' ? '_blank' : '_self';
46
46
  }
@@ -1,5 +1,8 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import PromoVideo from './_PromoVideo';
4
+ import { sizes } from '../../../theme/shared/breakpoint';
5
+
3
6
  import Picture from '../../Atoms/Picture/Picture';
4
7
 
5
8
  import {
@@ -7,21 +10,60 @@ import {
7
10
  } from './Promo.style';
8
11
 
9
12
  const Promo = ({
10
- copyFirst,
13
+ copyLeft,
11
14
  backgroundColor,
12
15
  imageLow,
13
16
  imageSet,
14
17
  image,
15
18
  imageAltText,
16
19
  children,
17
- position
20
+ position,
21
+ autoPlay,
22
+ loop,
23
+ poster,
24
+ mobilePoster,
25
+ showPosterAfterPlaying,
26
+ videoSrc,
27
+ mobileVideoSrc,
28
+ lightColouredVideo
18
29
  }) => {
19
- const hasImage = imageSet || false;
30
+ // Store the appropriate prop in state, dependent on the breakpoint
31
+ const [thisVideoSrc, setThisVideoSrc] = useState(null);
32
+ const [thisPoster, setThisPoster] = useState(null);
33
+
34
+ // Let either field define this, just in case
35
+ const hasVideo = Boolean(videoSrc || mobileVideoSrc);
36
+ // A 'video-y' Promo will override and ignore any 'non-Video' images;
37
+ // none of these fields are required so we have to handle them accordingly:
38
+ const hasImage = Boolean(imageSet && !hasVideo);
39
+
40
+ // Runs on initial load:
41
+ useEffect(() => {
42
+ if (hasVideo) {
43
+ // Checks size on load ONLY; don't want to mess about with listeners:
44
+ const isDesktop = window.innerWidth >= sizes.nav; // 1024+ px
45
+ let currentPoster; let currentSrc;
46
+
47
+ // If we've got both desktop AND mobile videos, let the
48
+ // *current* screen width define which video src to use:
49
+ if (videoSrc && mobileVideoSrc) {
50
+ currentSrc = isDesktop ? videoSrc : mobileVideoSrc;
51
+ currentPoster = isDesktop ? poster : mobilePoster;
52
+ } else {
53
+ // Else, pick whatever we DO actually have:
54
+ currentSrc = videoSrc || mobileVideoSrc;
55
+ currentPoster = poster || mobilePoster;
56
+ }
57
+
58
+ setThisVideoSrc(currentSrc);
59
+ setThisPoster(currentPoster);
60
+ }
61
+ }, [hasVideo, videoSrc, mobileVideoSrc, mobilePoster, poster]);
20
62
 
21
63
  return (
22
64
  <Container backgroundColor={backgroundColor} position={position}>
23
- {hasImage && (
24
- <Media imageRight={copyFirst}>
65
+ <Media imageRight={copyLeft}>
66
+ {(hasImage && !hasVideo) && (
25
67
  <Picture
26
68
  alt={imageAltText}
27
69
  imageLow={imageLow}
@@ -31,10 +73,28 @@ const Promo = ({
31
73
  width="100%"
32
74
  height="100%"
33
75
  />
76
+ )}
77
+ {/* If no poster image is supplied, it'll gracefully
78
+ fall back to the first frame, so only checking for a src here */}
79
+ {(hasVideo && thisVideoSrc) && (
80
+ <>
81
+ <PromoVideo
82
+ copyLeft={copyLeft}
83
+ lightColouredVideo={lightColouredVideo}
84
+ thisVideoSrc={thisVideoSrc}
85
+ thisPoster={thisPoster}
86
+ showPosterAfterPlaying={showPosterAfterPlaying}
87
+ autoPlay={autoPlay}
88
+ loop={loop}
89
+ />
90
+ </>
91
+ )}
34
92
  </Media>
35
- )}
36
- <Wrapper copyFirst={copyFirst}>
37
- <Copy position={position}>{children}</Copy>
93
+
94
+ <Wrapper copyLeft={copyLeft}>
95
+ <Copy position={position} hasVideo={hasVideo} lightColouredVideo={lightColouredVideo}>
96
+ {children}
97
+ </Copy>
38
98
  </Wrapper>
39
99
  </Container>
40
100
  );
@@ -42,24 +102,40 @@ const Promo = ({
42
102
 
43
103
  Promo.propTypes = {
44
104
  backgroundColor: PropTypes.string,
45
- copyFirst: PropTypes.bool,
105
+ copyLeft: PropTypes.bool,
46
106
  imageLow: PropTypes.string,
47
107
  imageSet: PropTypes.string,
48
108
  image: PropTypes.string,
49
109
  imageAltText: PropTypes.string,
50
110
  children: PropTypes.node,
51
- position: PropTypes.oneOf(['upper', 'lower', 'end', 'none'])
111
+ position: PropTypes.oneOf(['upper', 'lower', 'end', 'none']),
112
+ autoPlay: PropTypes.bool,
113
+ loop: PropTypes.bool,
114
+ videoSrc: PropTypes.string,
115
+ mobileVideoSrc: PropTypes.string,
116
+ poster: PropTypes.string,
117
+ mobilePoster: PropTypes.string,
118
+ showPosterAfterPlaying: PropTypes.bool,
119
+ lightColouredVideo: PropTypes.bool
52
120
  };
53
121
 
54
122
  Promo.defaultProps = {
55
123
  backgroundColor: 'white',
56
- copyFirst: false,
124
+ copyLeft: false,
57
125
  imageSet: null,
58
126
  imageLow: null,
59
127
  image: null,
60
128
  imageAltText: '',
61
129
  children: null,
62
- position: 'none'
130
+ position: 'none',
131
+ autoPlay: true,
132
+ loop: true,
133
+ poster: null,
134
+ mobilePoster: null,
135
+ videoSrc: null,
136
+ mobileVideoSrc: null,
137
+ showPosterAfterPlaying: true,
138
+ lightColouredVideo: false
63
139
  };
64
140
 
65
141
  export default Promo;