@comicrelief/component-library 7.12.1 → 7.13.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.
@@ -33,12 +33,14 @@ var Container = _styledComponents.default.div.withConfig({
33
33
  return theme.color('white');
34
34
  });
35
35
 
36
- var ChevAnima = (0, _styledComponents.keyframes)(["0%{margin-top:0rem;}50%{margin-top:0.5rem;}100%{margin-top:0rem;}"]);
36
+ var ChevronKeyframes = (0, _styledComponents.keyframes)(["0%{margin-top:0rem;}50%{margin-top:0.5rem;}100%{margin-top:0rem;}"]);
37
37
 
38
38
  var Button = _styledComponents.default.button.withConfig({
39
39
  displayName: "Accordion__Button",
40
40
  componentId: "sc-19u0s0h-1"
41
- })(["display:flex;justify-content:space-between;align-items:center;width:100%;background:none;border:none;transition:bottom 0.1s linear;cursor:pointer;&:focus,&:hover{color:inherit;outline:none;> div{animation-name:", ";animation-duration:0.4s;}}padding:", ";@media ", "{padding:", " ", ";}"], ChevAnima, (0, _spacing.default)('l'), function (_ref2) {
41
+ })(["display:flex;justify-content:space-between;align-items:center;width:100%;background:none;border:none;transition:bottom 0.1s linear;cursor:pointer;&:focus,&:hover{color:inherit;outline:none;> div{animation-name:", ";animation-duration:0.4s;}}padding:", ";@media ", "{padding:", " ", ";}"], function (props) {
42
+ return props.ChevronKeyframes;
43
+ }, (0, _spacing.default)('l'), function (_ref2) {
42
44
  var theme = _ref2.theme;
43
45
  return theme.breakpoint('small');
44
46
  }, (0, _spacing.default)('l'), (0, _spacing.default)('lg'));
@@ -78,7 +80,8 @@ var Accordion = function Accordion(_ref6) {
78
80
 
79
81
  return /*#__PURE__*/_react.default.createElement(Container, rest, /*#__PURE__*/_react.default.createElement(Button, {
80
82
  onClick: handleOpen,
81
- "aria-expanded": isOpen ? 'true' : 'false'
83
+ "aria-expanded": isOpen ? 'true' : 'false',
84
+ ChevronKeyframes: ChevronKeyframes
82
85
  }, title, /*#__PURE__*/_react.default.createElement(Icon, null, /*#__PURE__*/_react.default.createElement(_index.Chevron, {
83
86
  colour: "black",
84
87
  direction: isOpen ? 'up' : 'down'
@@ -58,7 +58,7 @@ var SingleMessage = function SingleMessage(_ref) {
58
58
  var _useState5 = (0, _react.useState)(false),
59
59
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
60
60
  onPlay = _useState6[0],
61
- setonPlay = _useState6[1];
61
+ setOnPlay = _useState6[1];
62
62
 
63
63
  var _useState7 = (0, _react.useState)(false),
64
64
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
@@ -118,7 +118,7 @@ var SingleMessage = function SingleMessage(_ref) {
118
118
  }, [hasVideo, isInitialised, uniqueID, videoID, onPlay]);
119
119
 
120
120
  var handlePlay = function handlePlay(thisUniqueID) {
121
- setonPlay(true); // Trigger play and update video state
121
+ setOnPlay(true); // Trigger play and update video state
122
122
 
123
123
  var thisVideoID = "".concat(thisUniqueID, "__video");
124
124
  setTimeout(function () {
@@ -154,6 +154,7 @@ import Download from '../../Atoms/Icons/Download';
154
154
  imageLow={defaultData.image}
155
155
  imageLeft={true}
156
156
  images={defaultData.images}
157
+ subtitle="subTitle"
157
158
  >
158
159
  <Text tag='p'>
159
160
  Whatever you’ve got planned, the Sport Relief shop has everything you need
@@ -179,10 +180,11 @@ import Download from '../../Atoms/Icons/Download';
179
180
  images={defaultData.images}
180
181
  youTubeId="faz0JeBB41M"
181
182
  imageLeft={true}
183
+ subtitle="subTitle"
182
184
  >
183
185
  <Text tag='p'>
184
186
  Some text and stuff.
185
187
  </Text>
186
188
  </SingleMessageDs>
187
189
  </div>;
188
- ```
190
+ ```
@@ -1,5 +1,5 @@
1
1
  ```js
2
- const poster = require('../../../styleguide/assets/poster.png');
2
+ import poster from '../../../styleguide/assets/poster.png';
3
3
  const src =
4
4
  'https://www.comicrelief.com/sites/default/files/downloads/Creativists_Logo_Web_small_V2_0.mp4';
5
5
 
@@ -52,7 +52,8 @@ var Donate = function Donate(_ref) {
52
52
  noMoneyBuys = _ref.noMoneyBuys,
53
53
  PopUpText = _ref.PopUpText,
54
54
  chooseAmountText = _ref.chooseAmountText,
55
- isDesktopOverride = _ref.isDesktopOverride;
55
+ isDesktopOverride = _ref.isDesktopOverride,
56
+ otherAmountValue = _ref.otherAmountValue;
56
57
  var isDesktop = (0, _reactResponsive.useMediaQuery)({
57
58
  query: "(min-width: ".concat(_size.screen.medium, ")")
58
59
  }); // To let us store any updated override, and force a re-render
@@ -63,11 +64,10 @@ var Donate = function Donate(_ref) {
63
64
  setOverrideValue = _useState2[1]; // Store the updated override value
64
65
 
65
66
 
66
- _react.default.useEffect(function () {
67
+ (0, _react.useEffect)(function () {
67
68
  setOverrideValue(isDesktopOverride);
68
69
  }, [isDesktopOverride]); // If a boolean value has been passed, let it replace our 'internal' value
69
70
 
70
-
71
71
  isDesktop = overrideValue !== null ? overrideValue : isDesktop;
72
72
  return /*#__PURE__*/_react.default.createElement(_Donate.Container, {
73
73
  mobileBackgroundColor: mobileBackgroundColor,
@@ -119,7 +119,8 @@ var Donate = function Donate(_ref) {
119
119
  noMoneyBuys: noMoneyBuys,
120
120
  PopUpText: PopUpText,
121
121
  chooseAmountText: chooseAmountText,
122
- submitButtonColor: submitButtonColor
122
+ submitButtonColor: submitButtonColor,
123
+ otherAmountValue: otherAmountValue
123
124
  })));
124
125
  };
125
126
 
@@ -144,7 +145,8 @@ Donate.defaultProps = {
144
145
  noMoneyBuys: false,
145
146
  PopUpText: 'Help us deliver long-term impact by converting your single donation into a monthly gift.',
146
147
  chooseAmountText: '',
147
- isDesktopOverride: null
148
+ isDesktopOverride: null,
149
+ otherAmountValue: null
148
150
  };
149
151
  var _default = Donate;
150
152
  exports.default = _default;
@@ -103,6 +103,102 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
103
103
  />;
104
104
  ```
105
105
 
106
+ ## Single Giving "No Money Buys" with overridden manual input value
107
+
108
+ ```js
109
+ import data from './dev-data/data-single';
110
+ const mobilePictures = require('../../../styleguide/data/data').mobileImages;
111
+ const desktopPictures = require('../../../styleguide/data/data').defaultData;
112
+ import { useState } from 'react';
113
+
114
+ // Simulating default state of a parent componenet
115
+ const [amountDonate, setAmountDonate] = useState(123.45);
116
+
117
+ // Simulating state update of a parent componenet
118
+ setTimeout(()=>{
119
+ setAmountDonate(567.89);
120
+ }, 3000);
121
+
122
+ <Donate
123
+ mobileBackgroundColor="blue_dark"
124
+ desktopOverlayColor="blue_dark"
125
+ formAlignRight={false}
126
+ imageLow={desktopPictures.imageLow}
127
+ images={desktopPictures.images}
128
+ mobileImageLow={mobilePictures.imageLow}
129
+ mobileImages={mobilePictures.images}
130
+ data={data}
131
+ mbshipID="mship-4"
132
+ donateLink="https://donation.comicrelief.com/"
133
+ clientID="donate"
134
+ cartID="default-comicrelief"
135
+ title="Donate Now"
136
+ noMoneyBuys
137
+ subtitle="Please help us fund life-changing projects in the UK and around the world."
138
+ otherAmountValue={amountDonate}
139
+ />;
140
+ ```
141
+
142
+ ## Form align right, with red desktop overlay and purple mobile background colour, with a blue submit button, with overridden manual input value
143
+
144
+ ```js
145
+ import data from './dev-data/data';
146
+ const mobilePictures = require('../../../styleguide/data/data').mobileImages;
147
+ const desktopPictures = require('../../../styleguide/data/data').defaultData;
148
+ import { useState } from 'react';
149
+
150
+ // Simulating default state of a parent componenet
151
+ const [amountDonate, setAmountDonate] = useState(111.22);
152
+
153
+ // Simulating state update of a parent componenet
154
+ setTimeout(()=>{
155
+ setAmountDonate(333.44);
156
+ }, 3000);
157
+
158
+ <Donate
159
+ alt="Background image"
160
+ formAlignRight={true}
161
+ imageLow={desktopPictures.imageLow}
162
+ images={desktopPictures.images}
163
+ mobileImageLow={mobilePictures.imageLow}
164
+ mobileImages={mobilePictures.images}
165
+ data={data}
166
+ mbshipID="mship-1"
167
+ donateLink="https://donation.comicrelief.com/"
168
+ clientID="donate"
169
+ cartID="default-comicrelief"
170
+ title="Donate Now"
171
+ subtitle="Please help us fund life-changing projects in the UK and around the world."
172
+ otherAmountValue={amountDonate}
173
+ />;
174
+ ```
175
+
176
+ ## Form align left, with custom message after choosing an "Other amount" to donate, high value cart.
177
+ ```js
178
+ import data from './dev-data/data-high-value';
179
+ const mobilePictures = require('../../../styleguide/data/data').mobileImages;
180
+ const desktopPictures = require('../../../styleguide/data/data').defaultData;
181
+
182
+ <Donate
183
+ mobileBackgroundColor="blue_dark"
184
+ desktopOverlayColor="blue_dark"
185
+ formAlignRight={false}
186
+ imageLow={desktopPictures.imageLow}
187
+ images={desktopPictures.images}
188
+ mobileImageLow={mobilePictures.imageLow}
189
+ mobileImages={mobilePictures.images}
190
+ data={data}
191
+ mbshipID="mship-2"
192
+ donateLink="https://donation.comicrelief.com/"
193
+ clientID="donate"
194
+ cartID="default-comicrelief"
195
+ title="Donate Now"
196
+ subtitle="Please help us fund life-changing projects in the UK and around the world."
197
+ otherAmountText="Overridden via the 'Other amount text' prop"
198
+ />;
199
+ ```
200
+
201
+
106
202
  ## Form align right - no subtitle
107
203
 
108
204
  ```js
@@ -69,4 +69,23 @@ it('Single donation with no Money Buys renders correctly', function () {
69
69
  chooseAmountText: "Overridden via the 'choose amount text' props"
70
70
  })).toJSON();
71
71
  expect(tree).toMatchSnapshot();
72
+ });
73
+ it('"Single Giving, No Money Buys, with overridden manual input value" renders correctly', function () {
74
+ var tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_Donate.default, {
75
+ mobileBackgroundColor: "blue_dark",
76
+ desktopOverlayColor: "blue_dark",
77
+ formAlignRight: false,
78
+ imageLow: defaultData.pictures.imageLow,
79
+ images: defaultData.pictures.images,
80
+ data: _data.default,
81
+ mbshipID: "mship-4",
82
+ donateLink: "https://donation.comicrelief.com/",
83
+ clientID: "donate",
84
+ cartID: "default-comicrelief",
85
+ title: "Donate Now",
86
+ noMoneyBuys: true,
87
+ subtitle: "Please help us fund life-changing projects in the UK and around the world.",
88
+ otherAmountValue: 345.67
89
+ })).toJSON();
90
+ expect(tree).toMatchSnapshot();
72
91
  });
@@ -25,7 +25,7 @@ var _Donate = require("../Donate.style");
25
25
 
26
26
  var _GivingSelector = _interopRequireDefault(require("../GivingSelector/GivingSelector"));
27
27
 
28
- var _excluded = ["data", "donateLink", "otherAmountText", "clientID", "cartID", "mbshipID", "noMoneyBuys", "PopUpText", "chooseAmountText", "submitButtonColor"];
28
+ var _excluded = ["data", "donateLink", "otherAmountText", "clientID", "cartID", "mbshipID", "noMoneyBuys", "PopUpText", "chooseAmountText", "submitButtonColor", "otherAmountValue"];
29
29
 
30
30
  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); }
31
31
 
@@ -44,6 +44,7 @@ var Signup = function Signup(_ref) {
44
44
  PopUpText = _ref.PopUpText,
45
45
  chooseAmountText = _ref.chooseAmountText,
46
46
  submitButtonColor = _ref.submitButtonColor,
47
+ otherAmountValue = _ref.otherAmountValue,
47
48
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
48
49
 
49
50
  var _useState = (0, _react.useState)('single'),
@@ -78,13 +79,20 @@ var Signup = function Signup(_ref) {
78
79
  setPopUpShown = _useState12[1];
79
80
 
80
81
  (0, _react.useEffect)(function () {
81
- var givingData = givingType === 'single' ? singleGiving : regularGiving; // Check the 2nd moneybuy exists before using it;
82
- // 'philantrophy' carts have been set up to use a single moneybuy.
83
- // See ENG-1685 for more details
82
+ // If a specific 'other amount' has been passed down, use it,
83
+ // otherwise assign based on the associated moneybuys:
84
+ if (otherAmountValue) {
85
+ setAmountDonate(parseFloat(otherAmountValue));
86
+ } else {
87
+ var _givingData = givingType === 'single' ? singleGiving : regularGiving; // Check the 2nd moneybuy exists before using it;
88
+ // 'philantrophy' carts have been set up to use a single moneybuy.
89
+ // See ENG-1685 for more details
90
+
84
91
 
85
- var thisAmount = givingData.moneybuys[1] ? givingData.moneybuys[1].value : givingData.moneybuys[0].value;
86
- setAmountDonate(parseFloat(thisAmount));
87
- }, [givingType, singleGiving, regularGiving]);
92
+ var thisAmount = _givingData.moneybuys[1] ? _givingData.moneybuys[1].value : _givingData.moneybuys[0].value;
93
+ setAmountDonate(parseFloat(thisAmount));
94
+ }
95
+ }, [givingType, singleGiving, regularGiving, otherAmountValue]);
88
96
  (0, _react.useEffect)(function () {
89
97
  var givingData = givingType === 'single' ? singleGiving : regularGiving;
90
98
  var moneyBuyNewDescription = otherAmountText;
@@ -119,9 +127,15 @@ var Signup = function Signup(_ref) {
119
127
  setErrorMsg(true);
120
128
  setMoneyBuyCopy(false);
121
129
  }
122
- }; // Create money buy boxes
130
+ }; // Update the local state if the prop has been set and changed
123
131
 
124
132
 
133
+ (0, _react.useEffect)(function () {
134
+ if (otherAmountValue) {
135
+ setAmountDonate(parseFloat(otherAmountValue));
136
+ }
137
+ }, [otherAmountValue, setAmountDonate]); // Create money buy boxes
138
+
125
139
  var givingData = givingType === 'single' ? singleGiving : regularGiving;
126
140
  var showGivingSelector = singleGiving !== null && regularGiving !== null;
127
141
  return /*#__PURE__*/_react.default.createElement(_Donate.FormWrapper, null, showGivingSelector && /*#__PURE__*/_react.default.createElement(_GivingSelector.default, {
@@ -30,8 +30,10 @@ var fadeOpen = (0, _styledComponents.keyframes)(["0%{opacity:0;max-height:0px;di
30
30
  var StyledPopUp = _styledComponents.default.div.withConfig({
31
31
  displayName: "PopUpComponent__StyledPopUp",
32
32
  componentId: "sc-1d7imlo-0"
33
- })(["display:grid;overflow:hidden;max-height:350px;opacity:1;animation:0.4s ", " ease;", " background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);border-radius:10px;", "{width:450px;margin-right:auto;margin-left:auto;}"], fadeOpen, function (props) {
34
- return props.isClosed && (0, _styledComponents.css)(["animation:", "s ", " ease forwards;"], closeDuration, fadeClose);
33
+ })(["display:grid;overflow:hidden;max-height:350px;opacity:1;animation:0.4s ", " ease;", " background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);border-radius:10px;", "{width:450px;margin-right:auto;margin-left:auto;}"], function (props) {
34
+ return props.fadeOpen;
35
+ }, function (props) {
36
+ return props.isClosed && (0, _styledComponents.css)(["animation:", "s ", " ease forwards;"], closeDuration, props.fadeClose);
35
37
  }, function (_ref) {
36
38
  var theme = _ref.theme;
37
39
  return theme.color('blue_light');
@@ -69,7 +71,9 @@ var PopUpComponent = function PopUpComponent(_ref3) {
69
71
  };
70
72
 
71
73
  return /*#__PURE__*/_react.default.createElement(StyledPopUp, {
72
- isClosed: isClosed
74
+ isClosed: isClosed,
75
+ fadeOpen: fadeOpen,
76
+ fadeClose: fadeClose
73
77
  }, /*#__PURE__*/_react.default.createElement(Button, {
74
78
  onClick: function onClick() {
75
79
  return handleCloser();