@comicrelief/component-library 6.6.1 → 6.6.3

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.
@@ -9,7 +9,7 @@ exports.default = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
12
- var _reactResponsive = _interopRequireDefault(require("react-responsive"));
12
+ var _reactResponsive = require("react-responsive");
13
13
 
14
14
  var _size = require("../../../theme/shared/size");
15
15
 
@@ -42,13 +42,18 @@ var Donate = function Donate(_ref) {
42
42
  mbshipID = _ref.mbshipID,
43
43
  noMoneyBuys = _ref.noMoneyBuys,
44
44
  PopUpText = _ref.PopUpText,
45
- chooseAmountText = _ref.chooseAmountText;
45
+ chooseAmountText = _ref.chooseAmountText,
46
+ isDesktopOverride = _ref.isDesktopOverride;
47
+ // Can't assign this conditionally due to Hook rules..
48
+ var isDesktop = (0, _reactResponsive.useMediaQuery)({
49
+ query: "(min-width: ".concat(_size.screen.medium, ")")
50
+ }); // ... but we can just do this, allowing the parent to control that if IT re-renders
51
+
52
+ if (isDesktopOverride !== null) isDesktop = isDesktopOverride;
46
53
  return /*#__PURE__*/_react.default.createElement(_Donate.Container, {
47
54
  backgroundColor: backgroundColor,
48
55
  id: mbshipID
49
- }, mobileImages && /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
50
- maxWidth: _size.screenPixelValues.medium - 1
51
- }, /*#__PURE__*/_react.default.createElement(_Picture.default, {
56
+ }, !isDesktop && mobileImages ? /*#__PURE__*/_react.default.createElement(_Picture.default, {
52
57
  backgroundColor: backgroundColor,
53
58
  image: mobileImage,
54
59
  images: mobileImages,
@@ -57,9 +62,7 @@ var Donate = function Donate(_ref) {
57
62
  width: "100%",
58
63
  height: "100%",
59
64
  alt: mobileAlt
60
- })), images && /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
61
- minWidth: _size.screenPixelValues.medium
62
- }, /*#__PURE__*/_react.default.createElement(_Donate.BgImage, {
65
+ }) : null, isDesktop && images ? /*#__PURE__*/_react.default.createElement(_Donate.BgImage, {
63
66
  backgroundColor: backgroundColor,
64
67
  image: image,
65
68
  images: images,
@@ -69,7 +72,7 @@ var Donate = function Donate(_ref) {
69
72
  height: "100%",
70
73
  alt: alt,
71
74
  isBackgroundImage: true
72
- })), /*#__PURE__*/_react.default.createElement(_Donate.Wrapper, {
75
+ }) : null, /*#__PURE__*/_react.default.createElement(_Donate.Wrapper, {
73
76
  formAlignRight: formAlignRight,
74
77
  "aria-live": "polite"
75
78
  }, /*#__PURE__*/_react.default.createElement(_Donate.Header, {
@@ -115,7 +118,8 @@ Donate.defaultProps = {
115
118
  subtitle: '',
116
119
  noMoneyBuys: false,
117
120
  PopUpText: 'Help us deliver long-term impact by converting your single donation into a monthly gift.',
118
- chooseAmountText: ''
121
+ chooseAmountText: '',
122
+ isDesktopOverride: null
119
123
  };
120
124
  var _default = Donate;
121
125
  exports.default = _default;
@@ -3,17 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.screenPixelValues = exports.container = exports.screen = exports.media = void 0;
7
- var screenPixelValues = {
8
- small: 740,
9
- medium: 1024,
10
- large: 1440
11
- };
12
- exports.screenPixelValues = screenPixelValues;
6
+ exports.container = exports.screen = exports.media = void 0;
13
7
  var screen = {
14
- small: "".concat(screenPixelValues.small, "px"),
15
- medium: "".concat(screenPixelValues.medium, "px"),
16
- large: "".concat(screenPixelValues.large, "px")
8
+ small: '740px',
9
+ medium: '1024px',
10
+ large: '1440px'
17
11
  };
18
12
  exports.screen = screen;
19
13
 
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": "6.6.1",
4
+ "version": "6.6.3",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import MediaQuery from 'react-responsive';
2
+ import { useMediaQuery } from 'react-responsive';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
- import { screenPixelValues } from '../../../theme/shared/size';
5
+ import { screen } from '../../../theme/shared/size';
6
6
  import Text from '../../Atoms/Text/Text';
7
7
  import Picture from '../../Atoms/Picture/Picture';
8
8
  import Form from './Form/Form';
@@ -35,77 +35,82 @@ const Donate = ({
35
35
  mbshipID,
36
36
  noMoneyBuys,
37
37
  PopUpText,
38
- chooseAmountText
39
- }) => (
40
- <Container backgroundColor={backgroundColor} id={mbshipID}>
41
- {mobileImages && (
42
- <MediaQuery maxWidth={screenPixelValues.medium - 1}>
43
- <Picture
44
- backgroundColor={backgroundColor}
45
- image={mobileImage}
46
- images={mobileImages}
47
- imageLow={mobileImageLow}
48
- objectFit="cover"
49
- width="100%"
50
- height="100%"
51
- alt={mobileAlt}
52
- />
53
- </MediaQuery>
54
- )}
38
+ chooseAmountText,
39
+ isDesktopOverride
40
+ }) => {
41
+ // Can't assign this conditionally due to Hook rules..
42
+ let isDesktop = useMediaQuery({ query: `(min-width: ${screen.medium})` });
55
43
 
56
- {images && (
57
- <MediaQuery minWidth={screenPixelValues.medium}>
58
- <BgImage
59
- backgroundColor={backgroundColor}
60
- image={image}
61
- images={images}
62
- imageLow={imageLow}
63
- objectFit="cover"
64
- width="100%"
65
- height="100%"
66
- alt={alt}
67
- isBackgroundImage
68
- />
69
- </MediaQuery>
70
- )}
44
+ // ... but we can just do this, allowing the parent to control that if IT re-renders
45
+ if (isDesktopOverride !== null) isDesktop = isDesktopOverride;
71
46
 
72
- <Wrapper formAlignRight={formAlignRight} aria-live="polite">
73
- <Header formAlignRight={formAlignRight}>
74
- <HeaderInner>
75
- {subtitle && (
76
- <>
77
- <Text
78
- tag="h2"
79
- color="white"
80
- size="big"
81
- family="Anton"
82
- weight="normal"
83
- uppercase
84
- >
85
- {title}
86
- </Text>
87
- <Text tag="p" color="white" size="m">
88
- {subtitle}
89
- </Text>
90
- </>
91
- )}
92
- </HeaderInner>
93
- </Header>
47
+ return (
48
+ <Container backgroundColor={backgroundColor} id={mbshipID}>
49
+ {!isDesktop && mobileImages ? (
50
+ <Picture
51
+ backgroundColor={backgroundColor}
52
+ image={mobileImage}
53
+ images={mobileImages}
54
+ imageLow={mobileImageLow}
55
+ objectFit="cover"
56
+ width="100%"
57
+ height="100%"
58
+ alt={mobileAlt}
59
+ />
60
+ ) : null}
94
61
 
95
- <Form
96
- data={data}
97
- otherDescription={otherDescription}
98
- cartID={cartID}
99
- clientID={clientID}
100
- mbshipID={mbshipID}
101
- donateLink={donateLink}
102
- noMoneyBuys={noMoneyBuys}
103
- PopUpText={PopUpText}
104
- chooseAmountText={chooseAmountText}
105
- />
106
- </Wrapper>
107
- </Container>
108
- );
62
+ {isDesktop && images ? (
63
+ <BgImage
64
+ backgroundColor={backgroundColor}
65
+ image={image}
66
+ images={images}
67
+ imageLow={imageLow}
68
+ objectFit="cover"
69
+ width="100%"
70
+ height="100%"
71
+ alt={alt}
72
+ isBackgroundImage
73
+ />
74
+ ) : null}
75
+
76
+ <Wrapper formAlignRight={formAlignRight} aria-live="polite">
77
+ <Header formAlignRight={formAlignRight}>
78
+ <HeaderInner>
79
+ {subtitle && (
80
+ <>
81
+ <Text
82
+ tag="h2"
83
+ color="white"
84
+ size="big"
85
+ family="Anton"
86
+ weight="normal"
87
+ uppercase
88
+ >
89
+ {title}
90
+ </Text>
91
+ <Text tag="p" color="white" size="m">
92
+ {subtitle}
93
+ </Text>
94
+ </>
95
+ )}
96
+ </HeaderInner>
97
+ </Header>
98
+
99
+ <Form
100
+ data={data}
101
+ otherDescription={otherDescription}
102
+ cartID={cartID}
103
+ clientID={clientID}
104
+ mbshipID={mbshipID}
105
+ donateLink={donateLink}
106
+ noMoneyBuys={noMoneyBuys}
107
+ PopUpText={PopUpText}
108
+ chooseAmountText={chooseAmountText}
109
+ />
110
+ </Wrapper>
111
+ </Container>
112
+ );
113
+ };
109
114
 
110
115
  Donate.propTypes = {
111
116
  alt: PropTypes.string,
@@ -128,7 +133,8 @@ Donate.propTypes = {
128
133
  mbshipID: PropTypes.string,
129
134
  noMoneyBuys: PropTypes.bool,
130
135
  PopUpText: PropTypes.string,
131
- chooseAmountText: PropTypes.string
136
+ chooseAmountText: PropTypes.string,
137
+ isDesktopOverride: PropTypes.bool
132
138
  };
133
139
 
134
140
  Donate.defaultProps = {
@@ -149,7 +155,8 @@ Donate.defaultProps = {
149
155
  subtitle: '',
150
156
  noMoneyBuys: false,
151
157
  PopUpText: 'Help us deliver long-term impact by converting your single donation into a monthly gift.',
152
- chooseAmountText: ''
158
+ chooseAmountText: '',
159
+ isDesktopOverride: null
153
160
  };
154
161
 
155
162
  export default Donate;
@@ -1,13 +1,7 @@
1
- const screenPixelValues = {
2
- small: 740,
3
- medium: 1024,
4
- large: 1440
5
- };
6
-
7
1
  const screen = {
8
- small: `${screenPixelValues.small}px`,
9
- medium: `${screenPixelValues.medium}px`,
10
- large: `${screenPixelValues.large}px`
2
+ small: '740px',
3
+ medium: '1024px',
4
+ large: '1440px'
11
5
  };
12
6
 
13
7
  const media = size => {
@@ -23,6 +17,4 @@ const container = {
23
17
  large: '1440px'
24
18
  };
25
19
 
26
- export {
27
- media, screen, container, screenPixelValues
28
- };
20
+ export { media, screen, container };