@comicrelief/component-library 7.31.1 → 7.32.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.
@@ -47,6 +47,7 @@ const Donate = _ref => {
47
47
  defaultGivingType,
48
48
  monthlyTitle,
49
49
  monthlySubtitle,
50
+ paddingOption,
50
51
  // Just to keep the function call character length under control
51
52
  monthlyChooseAmountText: monthlyChoose,
52
53
  monthlyOtherAmountText: monthlyOther
@@ -105,7 +106,8 @@ const Donate = _ref => {
105
106
  }) : null, /*#__PURE__*/_react.default.createElement(_Donate.Wrapper, {
106
107
  formAlignRight: formAlignRight,
107
108
  "aria-live": "polite",
108
- noTitlesAtAll: noTitlesAtAll
109
+ noTitlesAtAll: noTitlesAtAll,
110
+ paddingOption: paddingOption
109
111
  }, !noTitlesAtAll && /*#__PURE__*/_react.default.createElement(_Donate.TitleWrapperOuter, {
110
112
  formAlignRight: formAlignRight,
111
113
  "data-test": "this-one-here"
@@ -169,6 +171,7 @@ Donate.defaultProps = {
169
171
  monthlyTitle: '',
170
172
  monthlySubtitle: '',
171
173
  monthlyChooseAmountText: '',
172
- monthlyOtherAmountText: ''
174
+ monthlyOtherAmountText: '',
175
+ paddingOption: null
173
176
  };
174
177
  var _default = exports.default = Donate;
@@ -1,6 +1,6 @@
1
1
  # Donate
2
2
 
3
- ## Form align right, with red desktop overlay and purple mobile background colour, with a blue submit button
3
+ ## Form align right, with red desktop overlay and purple mobile background colour, with a blue submit button and 'no top padding' option
4
4
 
5
5
  ```js
6
6
  import data from './dev-data/data';
@@ -24,10 +24,11 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
24
24
  cartID="default-comicrelief"
25
25
  title="Donate Now"
26
26
  subtitle="Please help us fund life-changing projects in the UK and around the world."
27
+ paddingOption="upper_off"
27
28
  />;
28
29
  ```
29
30
 
30
- ## Form align left, with custom message after choosing an "Other amount" to donate, high value cart.
31
+ ## Form align left, with custom message after choosing an "Other amount" to donate, high value cart, and 'no bottom padding' option
31
32
  ```js
32
33
  import data from './dev-data/data-high-value';
33
34
  const mobilePictures = require('../../../styleguide/data/data').mobileImages;
@@ -50,10 +51,11 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
50
51
  title="Donate Now"
51
52
  subtitle="Please help us fund life-changing projects in the UK and around the world."
52
53
  otherAmountText="Overridden via the 'Other amount text' prop"
54
+ paddingOption="lower_off"
53
55
  />;
54
56
  ```
55
57
 
56
- ## Single Giving
58
+ ## Single Giving, with 'no padding' option
57
59
 
58
60
  ```js
59
61
  import data from './dev-data/data-single';
@@ -76,6 +78,7 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
76
78
  cartID="default-comicrelief"
77
79
  title="Donate Now"
78
80
  subtitle="Please help us fund life-changing projects in the UK and around the world."
81
+ paddingOption="both_off"
79
82
  />;
80
83
  ```
81
84
 
@@ -13,6 +13,7 @@ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
13
13
  var _size = require("../../../theme/shared/size");
14
14
  var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
15
15
  var _zIndex = _interopRequireDefault(require("../../../theme/shared/zIndex"));
16
+ var _utils = _interopRequireDefault(require("../../../utils/_utils"));
16
17
  const Container = exports.Container = _styledComponents.default.div.withConfig({
17
18
  displayName: "Donatestyle__Container",
18
19
  componentId: "sc-8rjm3t-0"
@@ -45,7 +46,7 @@ const BgImage = exports.BgImage = (0, _styledComponents.default)(_Picture.defaul
45
46
  const Wrapper = exports.Wrapper = _styledComponents.default.div.withConfig({
46
47
  displayName: "Donatestyle__Wrapper",
47
48
  componentId: "sc-8rjm3t-3"
48
- })(["position:relative;text-align:center;padding:", " ", ";flex-direction:row;align-items:center;display:block;width:100%;flex-direction:", ";", ";", "{padding:", " ", ";}", "{display:flex;padding:", " 0;}"], (0, _spacing.default)('l'), (0, _spacing.default)('md'), _ref4 => {
49
+ })(["position:relative;text-align:center;padding:", " ", ";flex-direction:row;align-items:center;display:block;width:100%;flex-direction:", ";", ";", "{padding:", " ", ";}", "{display:flex;padding:", " 0;", ";}"], (0, _spacing.default)('l'), (0, _spacing.default)('md'), _ref4 => {
49
50
  let {
50
51
  formAlignRight
51
52
  } = _ref4;
@@ -55,14 +56,19 @@ const Wrapper = exports.Wrapper = _styledComponents.default.div.withConfig({
55
56
  noTitlesAtAll
56
57
  } = _ref5;
57
58
  return noTitlesAtAll === true && (0, _styledComponents.css)(["justify-content:center;"]);
58
- }, (0, _size.media)('small'), (0, _spacing.default)('xl'), (0, _spacing.default)('md'), (0, _size.media)('medium'), (0, _spacing.default)('xl'));
59
+ }, (0, _size.media)('small'), (0, _spacing.default)('xl'), (0, _spacing.default)('md'), (0, _size.media)('medium'), (0, _spacing.default)('xl'), _ref6 => {
60
+ let {
61
+ paddingOption
62
+ } = _ref6;
63
+ return (0, _utils.default)(paddingOption);
64
+ });
59
65
  const TitleWrapperOuter = exports.TitleWrapperOuter = _styledComponents.default.div.withConfig({
60
66
  displayName: "Donatestyle__TitleWrapperOuter",
61
67
  componentId: "sc-8rjm3t-4"
62
- })(["width:100%;display:flex;font-family:", ";", "{width:50%;padding:", ";align-items:center;}"], _ref6 => {
68
+ })(["width:100%;display:flex;font-family:", ";", "{width:50%;padding:", ";align-items:center;}"], _ref7 => {
63
69
  let {
64
70
  theme
65
- } = _ref6;
71
+ } = _ref7;
66
72
  return theme.fontFamilies(theme.font.regular);
67
73
  }, (0, _size.media)('medium'), (0, _spacing.default)('xl'));
68
74
  const TitleWrapperInner = exports.TitleWrapperInner = _styledComponents.default.div.withConfig({
@@ -72,33 +78,33 @@ const TitleWrapperInner = exports.TitleWrapperInner = _styledComponents.default.
72
78
  const FormWrapper = exports.FormWrapper = _styledComponents.default.div.withConfig({
73
79
  displayName: "Donatestyle__FormWrapper",
74
80
  componentId: "sc-8rjm3t-6"
75
- })(["position:relative;font-family:", ";", "{width:50%;}"], _ref7 => {
81
+ })(["position:relative;font-family:", ";", "{width:50%;}"], _ref8 => {
76
82
  let {
77
83
  theme
78
- } = _ref7;
84
+ } = _ref8;
79
85
  return theme.fontFamilies(theme.font.regular);
80
86
  }, (0, _size.media)('medium'));
81
87
  const Error = exports.Error = (0, _styledComponents.default)(_Text.default).withConfig({
82
88
  displayName: "Donatestyle__Error",
83
89
  componentId: "sc-8rjm3t-7"
84
- })(["color:", ";font-size:", ";font-weight:500;margin-top:", ";"], _ref8 => {
90
+ })(["color:", ";font-size:", ";font-weight:500;margin-top:", ";"], _ref9 => {
85
91
  let {
86
92
  theme
87
- } = _ref8;
93
+ } = _ref9;
88
94
  return theme.color('red');
89
- }, _ref9 => {
95
+ }, _ref10 => {
90
96
  let {
91
97
  theme
92
- } = _ref9;
98
+ } = _ref10;
93
99
  return theme.fontSize('s');
94
100
  }, (0, _spacing.default)('l'));
95
101
  const Form = exports.Form = _styledComponents.default.form.withConfig({
96
102
  displayName: "Donatestyle__Form",
97
103
  componentId: "sc-8rjm3t-8"
98
- })(["position:relative;width:100%;background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);border-radius:10px;margin-top:", ";h3{margin-top:", ";}input{max-width:100%;margin:0;}input[type='submit']{margin:", " 0;}", "{width:450px;margin-right:auto;margin-left:auto;}"], _ref10 => {
104
+ })(["position:relative;width:100%;background-color:", ";box-shadow:0px 0px 16px rgba(0,0,0,0.15);border-radius:10px;margin-top:", ";h3{margin-top:", ";}input{max-width:100%;margin:0;}input[type='submit']{margin:", " 0;}", "{width:450px;margin-right:auto;margin-left:auto;}"], _ref11 => {
99
105
  let {
100
106
  theme
101
- } = _ref10;
107
+ } = _ref11;
102
108
  return theme.color('white');
103
109
  }, (0, _spacing.default)('md'), (0, _spacing.default)('md'), (0, _spacing.default)('l'), (0, _size.media)('small'));
104
110
  const OuterFieldset = exports.OuterFieldset = _styledComponents.default.fieldset.withConfig({
@@ -124,20 +130,20 @@ const Label = exports.Label = (0, _styledComponents.default)(_Text.default).with
124
130
  const AmountField = exports.AmountField = (0, _styledComponents.default)(_Input.default).withConfig({
125
131
  displayName: "Donatestyle__AmountField",
126
132
  componentId: "sc-8rjm3t-14"
127
- })(["position:relative;flex-basis:50%;flex-shrink:0;flex-grow:0;font-weight:400;display:block;", "{flex-basis:60%;}span{position:absolute;font-size:20px;top:50%;transform:translateY(-50%);left:0px;font-weight:500;padding:0px 15px;", ";}input{height:48px;border:2px solid ", ";background:", ";border-radius:10px;padding:", " ", " ", " ", ";&:focus{outline:none;border:2px solid ", ";}}"], (0, _size.media)('small'), (0, _zIndex.default)('high'), _ref11 => {
133
+ })(["position:relative;flex-basis:50%;flex-shrink:0;flex-grow:0;font-weight:400;display:block;", "{flex-basis:60%;}span{position:absolute;font-size:20px;top:50%;transform:translateY(-50%);left:0px;font-weight:500;padding:0px 15px;", ";}input{height:48px;border:2px solid ", ";background:", ";border-radius:10px;padding:", " ", " ", " ", ";&:focus{outline:none;border:2px solid ", ";}}"], (0, _size.media)('small'), (0, _zIndex.default)('high'), _ref12 => {
128
134
  let {
129
135
  theme
130
- } = _ref11;
136
+ } = _ref12;
131
137
  return theme.color('grey');
132
- }, _ref12 => {
138
+ }, _ref13 => {
133
139
  let {
134
140
  theme
135
- } = _ref12;
141
+ } = _ref13;
136
142
  return theme.color('grey_light');
137
- }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), (0, _spacing.default)('sm'), (0, _spacing.default)('l'), _ref13 => {
143
+ }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), (0, _spacing.default)('sm'), (0, _spacing.default)('l'), _ref14 => {
138
144
  let {
139
145
  theme
140
- } = _ref13;
146
+ } = _ref14;
141
147
  return theme.color('grey');
142
148
  });
143
149
  const Copy = exports.Copy = (0, _styledComponents.default)(_Text.default).withConfig({
@@ -147,25 +153,25 @@ const Copy = exports.Copy = (0, _styledComponents.default)(_Text.default).withCo
147
153
  const Button = exports.Button = _styledComponents.default.button.withConfig({
148
154
  displayName: "Donatestyle__Button",
149
155
  componentId: "sc-8rjm3t-16"
150
- })(["width:100%;margin:", " 0 ", ";color:", ";font-size:", ";font-weight:bold;cursor:pointer;min-height:48px;background:", ";text-decoration:none;border-radius:2rem;border:none;box-shadow:0px 0px 16px rgba(0,0,0,0.15);appearance:none;:active,:focus,:hover{outline:none;background-color:", ";}", "{padding:", " ", ";}"], (0, _spacing.default)('l'), (0, _spacing.default)('l'), _ref14 => {
156
+ })(["width:100%;margin:", " 0 ", ";color:", ";font-size:", ";font-weight:bold;cursor:pointer;min-height:48px;background:", ";text-decoration:none;border-radius:2rem;border:none;box-shadow:0px 0px 16px rgba(0,0,0,0.15);appearance:none;:active,:focus,:hover{outline:none;background-color:", ";}", "{padding:", " ", ";}"], (0, _spacing.default)('l'), (0, _spacing.default)('l'), _ref15 => {
151
157
  let {
152
158
  theme
153
- } = _ref14;
159
+ } = _ref15;
154
160
  return theme.color('white');
155
- }, _ref15 => {
161
+ }, _ref16 => {
156
162
  let {
157
163
  theme
158
- } = _ref15;
164
+ } = _ref16;
159
165
  return theme.fontSize('s');
160
- }, _ref16 => {
166
+ }, _ref17 => {
161
167
  let {
162
168
  theme,
163
169
  color
164
- } = _ref16;
170
+ } = _ref17;
165
171
  return theme.color(color);
166
- }, _ref17 => {
172
+ }, _ref18 => {
167
173
  let {
168
174
  theme
169
- } = _ref17;
175
+ } = _ref18;
170
176
  return theme.color('coral_dark');
171
177
  }, (0, _size.media)('small'), (0, _spacing.default)('md'), (0, _spacing.default)('l'));
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const handlePadding = paddingOption => {
8
+ switch (paddingOption) {
9
+ case 'upper_off':
10
+ return 'padding-top: 0;';
11
+ case 'lower_off':
12
+ return 'padding-bottom: 0;';
13
+ case 'both_off':
14
+ return 'padding-top: 0; padding-bottom: 0';
15
+ // To leave pre-existing styles untouched
16
+ case 'both_on':
17
+ return null;
18
+ // Just in case
19
+ default:
20
+ return null;
21
+ }
22
+ };
23
+ var _default = exports.default = handlePadding;
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.31.1",
4
+ "version": "7.32.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -48,6 +48,7 @@ const Donate = ({
48
48
  defaultGivingType,
49
49
  monthlyTitle,
50
50
  monthlySubtitle,
51
+ paddingOption,
51
52
  // Just to keep the function call character length under control
52
53
  monthlyChooseAmountText: monthlyChoose,
53
54
  monthlyOtherAmountText: monthlyOther
@@ -113,7 +114,7 @@ const Donate = ({
113
114
  />
114
115
  ) : null}
115
116
 
116
- <Wrapper formAlignRight={formAlignRight} aria-live="polite" noTitlesAtAll={noTitlesAtAll}>
117
+ <Wrapper formAlignRight={formAlignRight} aria-live="polite" noTitlesAtAll={noTitlesAtAll} paddingOption={paddingOption}>
117
118
 
118
119
  {/* Only render if there is SOME title copy; otherwise,
119
120
  we need to the space to centre-align the form */}
@@ -197,7 +198,8 @@ Donate.propTypes = {
197
198
  monthlyTitle: PropTypes.string,
198
199
  monthlySubtitle: PropTypes.string,
199
200
  monthlyChooseAmountText: PropTypes.string,
200
- monthlyOtherAmountText: PropTypes.string
201
+ monthlyOtherAmountText: PropTypes.string,
202
+ paddingOption: PropTypes.string
201
203
  };
202
204
 
203
205
  Donate.defaultProps = {
@@ -231,7 +233,8 @@ Donate.defaultProps = {
231
233
  monthlyTitle: '',
232
234
  monthlySubtitle: '',
233
235
  monthlyChooseAmountText: '',
234
- monthlyOtherAmountText: ''
236
+ monthlyOtherAmountText: '',
237
+ paddingOption: null
235
238
  };
236
239
 
237
240
  export default Donate;
@@ -1,6 +1,6 @@
1
1
  # Donate
2
2
 
3
- ## Form align right, with red desktop overlay and purple mobile background colour, with a blue submit button
3
+ ## Form align right, with red desktop overlay and purple mobile background colour, with a blue submit button and 'no top padding' option
4
4
 
5
5
  ```js
6
6
  import data from './dev-data/data';
@@ -24,10 +24,11 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
24
24
  cartID="default-comicrelief"
25
25
  title="Donate Now"
26
26
  subtitle="Please help us fund life-changing projects in the UK and around the world."
27
+ paddingOption="upper_off"
27
28
  />;
28
29
  ```
29
30
 
30
- ## Form align left, with custom message after choosing an "Other amount" to donate, high value cart.
31
+ ## Form align left, with custom message after choosing an "Other amount" to donate, high value cart, and 'no bottom padding' option
31
32
  ```js
32
33
  import data from './dev-data/data-high-value';
33
34
  const mobilePictures = require('../../../styleguide/data/data').mobileImages;
@@ -50,10 +51,11 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
50
51
  title="Donate Now"
51
52
  subtitle="Please help us fund life-changing projects in the UK and around the world."
52
53
  otherAmountText="Overridden via the 'Other amount text' prop"
54
+ paddingOption="lower_off"
53
55
  />;
54
56
  ```
55
57
 
56
- ## Single Giving
58
+ ## Single Giving, with 'no padding' option
57
59
 
58
60
  ```js
59
61
  import data from './dev-data/data-single';
@@ -76,6 +78,7 @@ const desktopPictures = require('../../../styleguide/data/data').defaultData;
76
78
  cartID="default-comicrelief"
77
79
  title="Donate Now"
78
80
  subtitle="Please help us fund life-changing projects in the UK and around the world."
81
+ paddingOption="both_off"
79
82
  />;
80
83
  ```
81
84
 
@@ -6,6 +6,7 @@ import spacing from '../../../theme/shared/spacing';
6
6
  import { media } from '../../../theme/shared/size';
7
7
  import Picture from '../../Atoms/Picture/Picture';
8
8
  import zIndex from '../../../theme/shared/zIndex';
9
+ import handlePadding from '../../../utils/_utils';
9
10
 
10
11
  const Container = styled.div`
11
12
  position: relative;
@@ -58,9 +59,11 @@ const Wrapper = styled.div`
58
59
  ${media('small')} {
59
60
  padding: ${spacing('xl')} ${spacing('md')};
60
61
  }
62
+
61
63
  ${media('medium')} {
62
64
  display: flex;
63
65
  padding: ${spacing('xl')} 0;
66
+ ${({ paddingOption }) => handlePadding(paddingOption)};
64
67
  }
65
68
  `;
66
69
 
@@ -0,0 +1,18 @@
1
+ const handlePadding = paddingOption => {
2
+ switch (paddingOption) {
3
+ case 'upper_off':
4
+ return 'padding-top: 0;';
5
+ case 'lower_off':
6
+ return 'padding-bottom: 0;';
7
+ case 'both_off':
8
+ return 'padding-top: 0; padding-bottom: 0';
9
+ // To leave pre-existing styles untouched
10
+ case 'both_on':
11
+ return null;
12
+ // Just in case
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+
18
+ export default handlePadding;