@comicrelief/component-library 7.39.0 → 7.40.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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
@@ -7,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
7
8
  exports.default = void 0;
8
9
  var _react = _interopRequireWildcard(require("react"));
9
10
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
+ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
10
12
  require("lazysizes");
11
13
  require("lazysizes/plugins/blur-up/ls.blur-up");
12
14
  // Transparent pixel png
@@ -29,17 +31,52 @@ const Wrapper = _styledComponents.default.div.withConfig({
29
31
  const Image = _styledComponents.default.img.withConfig({
30
32
  displayName: "Picture__Image",
31
33
  componentId: "sc-1x3z81z-1"
32
- })(["width:", ";height:", ";display:block;object-fit:", ";", ";"], props => props.width ? props.width : '100%', props => props.height ? props.height : 'auto', props => props.objectFit === 'none' && 'none' || props.objectFit === 'cover' && 'cover' || props.objectFit === 'contain' && 'contain', _ref3 => {
34
+ })(["width:", ";height:", ";display:block;object-fit:", ";", ";", " ", " ", ""], props => props.width ? props.width : '100%', props => props.height ? props.height : 'auto', props => props.objectFit === 'none' && 'none' || props.objectFit === 'cover' && 'cover' || props.objectFit === 'contain' && 'contain', _ref3 => {
33
35
  let {
34
36
  objectFit,
35
37
  objFitState
36
38
  } = _ref3;
37
39
  return objectFit !== 'none' && !objFitState && 'visibility: hidden;';
40
+ }, _ref4 => {
41
+ let {
42
+ smallBreakpointRowLayout
43
+ } = _ref4;
44
+ return smallBreakpointRowLayout === true && (0, _styledComponents.css)(["@media ", "{padding:", ";border-radius:", ";width:110px;height:110px;}@media ", "{padding:none;border-radius:none;width:", ";height:", ";}"], _ref5 => {
45
+ let {
46
+ theme
47
+ } = _ref5;
48
+ return theme.allBreakpoints('S');
49
+ }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), _ref6 => {
50
+ let {
51
+ theme
52
+ } = _ref6;
53
+ return theme.allBreakpoints('M');
54
+ }, props => props.width ? props.width : '100%', props => props.height ? props.height : 'auto');
55
+ }, _ref7 => {
56
+ let {
57
+ mediumBreakpointRowLayout
58
+ } = _ref7;
59
+ return mediumBreakpointRowLayout === true && (0, _styledComponents.css)(["@media ", "{padding:", ";border-radius:", ";width:120px;height:120px;}"], _ref8 => {
60
+ let {
61
+ theme
62
+ } = _ref8;
63
+ return theme.allBreakpoints('M');
64
+ }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'));
65
+ }, _ref9 => {
66
+ let {
67
+ smallBreakpointRowLayout,
68
+ mediumBreakpointRowLayout
69
+ } = _ref9;
70
+ return (smallBreakpointRowLayout === true || mediumBreakpointRowLayout === true) && (0, _styledComponents.css)(["@media ", "{padding:none;border-radius:none;width:", ";height:", ";}"], _ref10 => {
71
+ let {
72
+ theme
73
+ } = _ref10;
74
+ return theme.allBreakpoints('L');
75
+ }, props => props.width ? props.width : '100%', props => props.height ? props.height : 'auto');
38
76
  });
39
77
 
40
78
  /** Responsive Picture */
41
-
42
- const Picture = _ref4 => {
79
+ const Picture = _ref11 => {
43
80
  let {
44
81
  images,
45
82
  image,
@@ -49,8 +86,10 @@ const Picture = _ref4 => {
49
86
  objectFit,
50
87
  imageLow,
51
88
  isBackgroundImage,
89
+ smallBreakpointRowLayout,
90
+ mediumBreakpointRowLayout,
52
91
  ...rest
53
- } = _ref4;
92
+ } = _ref11;
54
93
  const document = typeof window !== 'undefined' ? window.document : null;
55
94
  const [objFitState, setObjFitState] = (0, _react.useState)(true);
56
95
  let nonObjFitImage = null;
@@ -108,7 +147,9 @@ const Picture = _ref4 => {
108
147
  "data-sizes": "auto",
109
148
  "data-lowsrc": imageLow,
110
149
  className: "lazyload",
111
- objFitState: objFitState
150
+ objFitState: objFitState,
151
+ smallBreakpointRowLayout: smallBreakpointRowLayout,
152
+ mediumBreakpointRowLayout: mediumBreakpointRowLayout
112
153
  }));
113
154
  };
114
155
  Picture.defaultProps = {
@@ -119,6 +160,8 @@ Picture.defaultProps = {
119
160
  width: '100%',
120
161
  height: 'auto',
121
162
  alt: '',
122
- isBackgroundImage: false
163
+ isBackgroundImage: false,
164
+ smallBreakpointRowLayout: null,
165
+ mediumBreakpointRowLayout: null
123
166
  };
124
167
  var _default = exports.default = (0, _styledComponents.withTheme)(Picture);
@@ -6,7 +6,7 @@ require("jest-styled-components");
6
6
  var _shallowWithTheme = _interopRequireDefault(require("../../../hoc/shallowWithTheme"));
7
7
  var _Picture = _interopRequireDefault(require("./Picture"));
8
8
  var _data = require("../../../styleguide/data/data");
9
- it('renders correctly', () => {
9
+ it("renders correctly", () => {
10
10
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_Picture.default, {
11
11
  images: _data.defaultData.images,
12
12
  image: _data.defaultData.image,
@@ -14,7 +14,7 @@ it('renders correctly', () => {
14
14
  })).toJSON();
15
15
  expect(tree).toMatchInlineSnapshot("\n .c0 {\n display: block;\n width: 100%;\n height: auto;\n position: relative;\n }\n\n .c1 {\n width: 100%;\n height: auto;\n display: block;\n object-fit: none;\n }\n\n <div\n className=\"c0 lazyload\"\n height=\"auto\"\n width=\"100%\"\n >\n <img\n alt=\"Test images\"\n className=\"c1 lazyload\"\n data-lowsrc={null}\n data-sizes=\"auto\"\n data-src=\"http://images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg\"\n data-srcset=\"//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=200&h=150&q=50 200w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=400&h=300&q=50 400w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=800&h=600&q=50 800w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=1200&h=900&q=50 1200w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=1440&h=1080&q=50 1440w\"\n height=\"auto\"\n src=\"http://images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg\"\n srcSet=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n width=\"100%\"\n />\n </div>\n ");
16
16
  });
17
- it('renders correctly with custom props', () => {
17
+ it("renders correctly with custom props", () => {
18
18
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_Picture.default, {
19
19
  images: _data.defaultData.images,
20
20
  image: _data.defaultData.image,
@@ -6,7 +6,7 @@ require("jest-styled-components");
6
6
  var _shallowWithTheme = _interopRequireDefault(require("../../../hoc/shallowWithTheme"));
7
7
  var _ArticleTeaser = _interopRequireDefault(require("./ArticleTeaser"));
8
8
  var _data = require("../../../styleguide/data/data");
9
- it('renders article teaser correctly', () => {
9
+ it("renders article teaser correctly", () => {
10
10
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_ArticleTeaser.default, {
11
11
  href: "/test",
12
12
  images: _data.defaultData.images,
@@ -20,7 +20,7 @@ it('renders article teaser correctly', () => {
20
20
  })).toJSON();
21
21
  expect(tree).toMatchInlineSnapshot("\n .c8 {\n font-size: 0.75rem;\n line-height: 0.75rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c10 {\n font-size: 2rem;\n line-height: 2rem;\n text-transform: uppercase;\n font-weight: normal;\n line-height: 2rem;\n font-family: 'Anton',Impact,sans-serif;\n -webkit-letter-spacing: 0.03rem;\n -moz-letter-spacing: 0.03rem;\n -ms-letter-spacing: 0.03rem;\n letter-spacing: 0.03rem;\n }\n\n .c4 {\n display: block;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .c6 {\n width: 100%;\n height: 100%;\n display: block;\n object-fit: cover;\n }\n\n .c1 {\n position: relative;\n -webkit-text-decoration: none;\n text-decoration: none;\n display: inline;\n line-height: 1.5rem;\n color: #000000;\n font-weight: normal;\n }\n\n .c1:hover {\n color: #000000;\n }\n\n .c0 {\n width: 100%;\n height: 100%;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n background-color: #FFFFFF;\n border-radius: 1rem;\n box-shadow: 0px 0px 20px rgba(0,0,0,0.15);\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n }\n\n .c0:hover {\n box-shadow: 0px 0px 20px rgba(0,0,0,0.3);\n -webkit-transform: translateY(-4px);\n -ms-transform: translateY(-4px);\n transform: translateY(-4px);\n }\n\n .c2 {\n padding: 0;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n height: 100%;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-text-decoration: none;\n text-decoration: none;\n color: inherit;\n width: 100%;\n }\n\n .c3 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -webkit-justify-content: center;\n -ms-flex-pack: center;\n justify-content: center;\n position: relative;\n }\n\n .c3 img {\n border-radius: 1rem 1rem 0 0;\n }\n\n .c7 {\n padding: 2rem;\n height: 100%;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n }\n\n .c11 {\n margin: 0;\n }\n\n .c9 {\n display: block;\n margin-bottom: 1rem;\n }\n\n .c5 {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n }\n\n @media (min-width:740px) {\n .c2 {\n -webkit-flex-direction: row;\n -ms-flex-direction: row;\n flex-direction: row;\n }\n }\n\n @media (min-width:1024px) {\n .c2 {\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n }\n }\n\n @media (min-width:740px) {\n .c3 {\n width: 45%;\n }\n\n .c3 img {\n border-radius: 1rem 0 0 1rem;\n }\n }\n\n @media (min-width:1024px) {\n .c3 {\n width: 100%;\n }\n\n .c3 img {\n border-radius: 1rem 1rem 0 0;\n }\n }\n\n @media (min-width:740px) {\n .c7 {\n width: 55%;\n }\n }\n\n @media (min-width:1024px) {\n .c7 {\n width: 100%;\n }\n }\n\n <article\n className=\"c0\"\n >\n <a\n className=\"c1 c2\"\n color=\"red\"\n href=\"/test\"\n target=\"_self\"\n type=\"standard\"\n >\n <div\n className=\"c3\"\n >\n <div\n className=\"c4 c5\"\n height=\"100%\"\n width=\"100%\"\n >\n <img\n alt=\"Image's description\"\n className=\"c6 lazyload\"\n data-lowsrc={null}\n data-sizes=\"auto\"\n data-src=\"http://images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg\"\n data-srcset=\"//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=200&h=150&q=50 200w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=400&h=300&q=50 400w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=800&h=600&q=50 800w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=1200&h=900&q=50 1200w,//images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg?w=1440&h=1080&q=50 1440w\"\n height=\"100%\"\n src=\"http://images.ctfassets.net/zsfivwzfgl3t/Yq59XdwwQgjNOxky93K1Q/17c2d80dce99067b0b3508f33075cbe3/funding_4-3_2x.jpg\"\n srcSet=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n width=\"100%\"\n />\n </div>\n </div>\n <div\n className=\"c7\"\n >\n <span\n className=\"c8 c9\"\n color=\"inherit\"\n size=\"xs\"\n >\n 01 July 2019\n </span>\n <h3\n className=\"c10 c11\"\n color=\"inherit\"\n height=\"2rem\"\n size=\"xl\"\n >\n News article\n </h3>\n </div>\n </a>\n </article>\n ");
22
22
  });
23
- it('renders press realese correctly', () => {
23
+ it("renders press realese correctly", () => {
24
24
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_ArticleTeaser.default, {
25
25
  href: "/test",
26
26
  category: "",
@@ -6,28 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _styledComponents = _interopRequireDefault(require("styled-components"));
10
9
  var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
11
- var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
12
- const Container = _styledComponents.default.div.withConfig({
13
- displayName: "Card__Container",
14
- componentId: "sc-15nltsw-0"
15
- })(["display:flex;position:relative;flex-direction:column;height:100%;border-radius:", ";overflow:hidden;background:", ";"], props => props.squaredCorners ? '0' : '1rem', _ref => {
16
- let {
17
- theme,
18
- backgroundColor
19
- } = _ref;
20
- return theme.color(backgroundColor);
21
- });
22
- const Image = _styledComponents.default.div.withConfig({
23
- displayName: "Card__Image",
24
- componentId: "sc-15nltsw-1"
25
- })(["height:auto;"]);
26
- const Copy = _styledComponents.default.div.withConfig({
27
- displayName: "Card__Copy",
28
- componentId: "sc-15nltsw-2"
29
- })(["padding:", ";display:flex;flex-direction:column;"], (0, _spacing.default)('l'));
30
- const Card = _ref2 => {
10
+ var _Card = require("./Card.style");
11
+ const Card = _ref => {
31
12
  let {
32
13
  backgroundColor,
33
14
  imageLow,
@@ -38,20 +19,29 @@ const Card = _ref2 => {
38
19
  width,
39
20
  children,
40
21
  squaredCorners,
22
+ smallBreakpointRowLayout,
23
+ mediumBreakpointRowLayout,
41
24
  ...rest
42
- } = _ref2;
43
- return /*#__PURE__*/_react.default.createElement(Container, Object.assign({
25
+ } = _ref;
26
+ return /*#__PURE__*/_react.default.createElement(_Card.Container, Object.assign({
44
27
  backgroundColor: backgroundColor,
45
- squaredCorners: squaredCorners
46
- }, rest), imageLow ? /*#__PURE__*/_react.default.createElement(Image, null, /*#__PURE__*/_react.default.createElement(_Picture.default, {
28
+ squaredCorners: squaredCorners,
29
+ smallBreakpointRowLayout: smallBreakpointRowLayout,
30
+ mediumBreakpointRowLayout: mediumBreakpointRowLayout
31
+ }, rest), imageLow ? /*#__PURE__*/_react.default.createElement(_Card.Wrapper, null, /*#__PURE__*/_react.default.createElement(_Picture.default, {
47
32
  alt: imageAltText,
48
33
  imageLow: imageLow,
49
34
  images: images,
50
35
  image: image,
51
36
  objectFit: "cover",
52
37
  width: width,
53
- height: height
54
- })) : null, children ? /*#__PURE__*/_react.default.createElement(Copy, null, children) : null);
38
+ height: height,
39
+ smallBreakpointRowLayout: smallBreakpointRowLayout,
40
+ mediumBreakpointRowLayout: mediumBreakpointRowLayout
41
+ })) : null, children ? /*#__PURE__*/_react.default.createElement(_Card.Copy, {
42
+ smallBreakpointRowLayout: smallBreakpointRowLayout,
43
+ mediumBreakpointRowLayout: mediumBreakpointRowLayout
44
+ }, children) : null);
55
45
  };
56
46
  Card.defaultProps = {
57
47
  backgroundColor: 'white',
@@ -62,6 +52,8 @@ Card.defaultProps = {
62
52
  imageAltText: '',
63
53
  width: '100%',
64
54
  height: '100%',
65
- squaredCorners: false
55
+ squaredCorners: false,
56
+ smallBreakpointRowLayout: null,
57
+ mediumBreakpointRowLayout: null
66
58
  };
67
59
  var _default = exports.default = Card;
@@ -1,5 +1,4 @@
1
1
  # Card
2
-
3
2
  ```js
4
3
  const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
5
4
  import Link from '../../Atoms/Link/Link';
@@ -7,7 +6,7 @@ import Link from '../../Atoms/Link/Link';
7
6
  <Card
8
7
  imageLow={defaultData.image}
9
8
  images={defaultData.images}
10
- backgroundColor="yellow"
9
+ backgroundColor="grey_light"
11
10
  height="auto"
12
11
  >
13
12
  <Text tag="h3" color="purple" size="xl">
@@ -17,9 +16,78 @@ import Link from '../../Atoms/Link/Link';
17
16
  </Card>;
18
17
  ```
19
18
 
19
+ ### Card - row layout on small breakpoint only
20
+ ```js
21
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
22
+ import Link from '../../Atoms/Link/Link';
23
+
24
+ <Card
25
+ imageLow={defaultData.image}
26
+ images={defaultData.images}
27
+ backgroundColor="grey_light"
28
+ height="auto"
29
+ smallBreakpointRowLayout={true}
30
+ mediumBreakpointRowLayout={false}
31
+ >
32
+ <Text tag="h3" color="purple" size="xl">
33
+ Title
34
+ </Text>
35
+ <Text tag="p">
36
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
37
+ </Text>
38
+ </Card>;
39
+ ```
40
+
41
+ ### Card - row layout on medium breakpoint only
42
+ ```js
43
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
44
+ import Link from '../../Atoms/Link/Link';
45
+
46
+ <Card
47
+ imageLow={defaultData.image}
48
+ images={defaultData.images}
49
+ backgroundColor="grey_light"
50
+ height="auto"
51
+ smallBreakpointRowLayout={false}
52
+ mediumBreakpointRowLayout={true}
53
+ >
54
+ <Text tag="h3" color="purple" size="xl">
55
+ Title
56
+ </Text>
57
+ <Text tag="p">
58
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
59
+ </Text>
60
+ </Card>;
61
+ ```
62
+
63
+ ### Card - row layout on small and medium breakpoints
64
+ ```js
65
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
66
+ import Link from '../../Atoms/Link/Link';
67
+
68
+ <Card
69
+ imageLow={defaultData.image}
70
+ images={defaultData.images}
71
+ backgroundColor="grey_light"
72
+ height="auto"
73
+ smallBreakpointRowLayout={true}
74
+ mediumBreakpointRowLayout={true}
75
+ >
76
+ <Text tag="h3" color="purple" size="xl">
77
+ Title
78
+ </Text>
79
+ <Text tag="p">
80
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
81
+ </Text>
82
+ </Card>;
83
+ ```
84
+
20
85
  ### Card no body
21
86
 
22
87
  ```js
23
88
  const defaultData = require('../../../styleguide/data/data').defaultData;
24
- <Card imageLow={defaultData.image} images={defaultData.image} />;
89
+ <Card
90
+ imageLow={defaultData.image}
91
+ images={defaultData.image}
92
+ />;
25
93
  ```
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Wrapper = exports.Copy = exports.Container = void 0;
9
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
+ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
11
+ const Container = exports.Container = _styledComponents.default.div.withConfig({
12
+ displayName: "Cardstyle__Container",
13
+ componentId: "sc-cxn4co-0"
14
+ })(["position:relative;display:flex;@media ", "{flex-direction:", ";}@media ", "{flex-direction:", ";}@media ", "{flex-direction:column;}height:100%;border-radius:", ";overflow:hidden;background:", ";"], _ref => {
15
+ let {
16
+ theme
17
+ } = _ref;
18
+ return theme.allBreakpoints('S');
19
+ }, props => props.smallBreakpointRowLayout === true ? 'row' : 'column', _ref2 => {
20
+ let {
21
+ theme
22
+ } = _ref2;
23
+ return theme.allBreakpoints('M');
24
+ }, props => props.mediumBreakpointRowLayout === true ? 'row' : 'column', _ref3 => {
25
+ let {
26
+ theme
27
+ } = _ref3;
28
+ return theme.allBreakpoints('L');
29
+ }, props => props.squaredCorners ? '0' : '1rem', _ref4 => {
30
+ let {
31
+ theme,
32
+ backgroundColor
33
+ } = _ref4;
34
+ return theme.color(backgroundColor);
35
+ });
36
+ const Wrapper = exports.Wrapper = _styledComponents.default.div.withConfig({
37
+ displayName: "Cardstyle__Wrapper",
38
+ componentId: "sc-cxn4co-1"
39
+ })(["height:auto;"]);
40
+ const Copy = exports.Copy = _styledComponents.default.div.withConfig({
41
+ displayName: "Cardstyle__Copy",
42
+ componentId: "sc-cxn4co-2"
43
+ })(["display:flex;flex-direction:column;padding:", ";", " ", " ", ""], (0, _spacing.default)('l'), _ref5 => {
44
+ let {
45
+ smallBreakpointRowLayout
46
+ } = _ref5;
47
+ return smallBreakpointRowLayout === true && (0, _styledComponents.css)(["@media ", "{padding:", ";h1,h2,h3,h4,h5{margin:", ";}}"], _ref6 => {
48
+ let {
49
+ theme
50
+ } = _ref6;
51
+ return theme.allBreakpoints('S');
52
+ }, props => props.smallBreakpointRowLayout === true && "".concat((0, _spacing.default)('sm')), props => props.smallBreakpointRowLayout === true && "".concat((0, _spacing.default)('sm'), " 0 ").concat((0, _spacing.default)('sm')));
53
+ }, _ref7 => {
54
+ let {
55
+ mediumBreakpointRowLayout
56
+ } = _ref7;
57
+ return mediumBreakpointRowLayout === true && (0, _styledComponents.css)(["@media ", "{padding:", ";h1,h2,h3,h4,h5{margin:", ";}}"], _ref8 => {
58
+ let {
59
+ theme
60
+ } = _ref8;
61
+ return theme.allBreakpoints('M');
62
+ }, props => props.mediumBreakpointRowLayout === true && "".concat((0, _spacing.default)('sm')), props => props.mediumBreakpointRowLayout === true && "".concat((0, _spacing.default)('sm'), " 0 ").concat((0, _spacing.default)('sm')));
63
+ }, _ref9 => {
64
+ let {
65
+ smallBreakpointRowLayout,
66
+ mediumBreakpointRowLayout
67
+ } = _ref9;
68
+ return (smallBreakpointRowLayout === true || mediumBreakpointRowLayout === true) && (0, _styledComponents.css)(["@media ", "{padding:", ";h1{margin:0 0 1rem 0;}h2{margin-bottom:2rem;}h3,h4,h5{margin-bottom:1rem;}}"], _ref10 => {
69
+ let {
70
+ theme
71
+ } = _ref10;
72
+ return theme.allBreakpoints('L');
73
+ }, (0, _spacing.default)('l'));
74
+ });
@@ -14,6 +14,16 @@ it('renders correctly', () => {
14
14
  }, /*#__PURE__*/_react.default.createElement("h2", null, "Title"), /*#__PURE__*/_react.default.createElement("p", null, "Description"))).toJSON();
15
15
  expect(tree).toMatchSnapshot();
16
16
  });
17
+ it('renders correctly', () => {
18
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_Card.default, {
19
+ image: _data.defaultData.image,
20
+ images: _data.defaultData.image,
21
+ backgroundColor: "yellow",
22
+ smallBreakpointLayout: "Row",
23
+ mediumBreakpointLayout: "Row"
24
+ }, /*#__PURE__*/_react.default.createElement("h2", null, "Title"), /*#__PURE__*/_react.default.createElement("p", null, "Text body copy description. Loads more text test. Loads more text test."))).toJSON();
25
+ expect(tree).toMatchSnapshot();
26
+ });
17
27
  it('renders correctly with no body', () => {
18
28
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_Card.default, {
19
29
  imageLow: _data.defaultData.image,
@@ -2,14 +2,75 @@
2
2
 
3
3
  exports[`renders correctly 1`] = `
4
4
  .c0 {
5
+ position: relative;
6
+ display: -webkit-box;
7
+ display: -webkit-flex;
8
+ display: -ms-flexbox;
9
+ display: flex;
10
+ height: 100%;
11
+ border-radius: 1rem;
12
+ overflow: hidden;
13
+ background: #FFE400;
14
+ }
15
+
16
+ .c1 {
5
17
  display: -webkit-box;
6
18
  display: -webkit-flex;
7
19
  display: -ms-flexbox;
8
20
  display: flex;
9
- position: relative;
10
21
  -webkit-flex-direction: column;
11
22
  -ms-flex-direction: column;
12
23
  flex-direction: column;
24
+ padding: 2rem;
25
+ }
26
+
27
+ @media (min-width:0px) {
28
+ .c0 {
29
+ -webkit-flex-direction: column;
30
+ -ms-flex-direction: column;
31
+ flex-direction: column;
32
+ }
33
+ }
34
+
35
+ @media (min-width:740px) {
36
+ .c0 {
37
+ -webkit-flex-direction: column;
38
+ -ms-flex-direction: column;
39
+ flex-direction: column;
40
+ }
41
+ }
42
+
43
+ @media (min-width:1024px) {
44
+ .c0 {
45
+ -webkit-flex-direction: column;
46
+ -ms-flex-direction: column;
47
+ flex-direction: column;
48
+ }
49
+ }
50
+
51
+ <div
52
+ className="c0"
53
+ >
54
+ <div
55
+ className="c1"
56
+ >
57
+ <h2>
58
+ Title
59
+ </h2>
60
+ <p>
61
+ Description
62
+ </p>
63
+ </div>
64
+ </div>
65
+ `;
66
+
67
+ exports[`renders correctly 2`] = `
68
+ .c0 {
69
+ position: relative;
70
+ display: -webkit-box;
71
+ display: -webkit-flex;
72
+ display: -ms-flexbox;
73
+ display: flex;
13
74
  height: 100%;
14
75
  border-radius: 1rem;
15
76
  overflow: hidden;
@@ -17,7 +78,6 @@ exports[`renders correctly 1`] = `
17
78
  }
18
79
 
19
80
  .c1 {
20
- padding: 2rem;
21
81
  display: -webkit-box;
22
82
  display: -webkit-flex;
23
83
  display: -ms-flexbox;
@@ -25,6 +85,31 @@ exports[`renders correctly 1`] = `
25
85
  -webkit-flex-direction: column;
26
86
  -ms-flex-direction: column;
27
87
  flex-direction: column;
88
+ padding: 2rem;
89
+ }
90
+
91
+ @media (min-width:0px) {
92
+ .c0 {
93
+ -webkit-flex-direction: column;
94
+ -ms-flex-direction: column;
95
+ flex-direction: column;
96
+ }
97
+ }
98
+
99
+ @media (min-width:740px) {
100
+ .c0 {
101
+ -webkit-flex-direction: column;
102
+ -ms-flex-direction: column;
103
+ flex-direction: column;
104
+ }
105
+ }
106
+
107
+ @media (min-width:1024px) {
108
+ .c0 {
109
+ -webkit-flex-direction: column;
110
+ -ms-flex-direction: column;
111
+ flex-direction: column;
112
+ }
28
113
  }
29
114
 
30
115
  <div
@@ -37,7 +122,7 @@ exports[`renders correctly 1`] = `
37
122
  Title
38
123
  </h2>
39
124
  <p>
40
- Description
125
+ Text body copy description. Loads more text test. Loads more text test.
41
126
  </p>
42
127
  </div>
43
128
  </div>
@@ -59,14 +144,11 @@ exports[`renders correctly with no body 1`] = `
59
144
  }
60
145
 
61
146
  .c0 {
147
+ position: relative;
62
148
  display: -webkit-box;
63
149
  display: -webkit-flex;
64
150
  display: -ms-flexbox;
65
151
  display: flex;
66
- position: relative;
67
- -webkit-flex-direction: column;
68
- -ms-flex-direction: column;
69
- flex-direction: column;
70
152
  height: 100%;
71
153
  border-radius: 1rem;
72
154
  overflow: hidden;
@@ -77,6 +159,30 @@ exports[`renders correctly with no body 1`] = `
77
159
  height: auto;
78
160
  }
79
161
 
162
+ @media (min-width:0px) {
163
+ .c0 {
164
+ -webkit-flex-direction: column;
165
+ -ms-flex-direction: column;
166
+ flex-direction: column;
167
+ }
168
+ }
169
+
170
+ @media (min-width:740px) {
171
+ .c0 {
172
+ -webkit-flex-direction: column;
173
+ -ms-flex-direction: column;
174
+ flex-direction: column;
175
+ }
176
+ }
177
+
178
+ @media (min-width:1024px) {
179
+ .c0 {
180
+ -webkit-flex-direction: column;
181
+ -ms-flex-direction: column;
182
+ flex-direction: column;
183
+ }
184
+ }
185
+
80
186
  <div
81
187
  className="c0"
82
188
  >
@@ -7,7 +7,7 @@ var _shallowWithTheme = _interopRequireDefault(require("../../../hoc/shallowWith
7
7
  var _PartnerLink = _interopRequireDefault(require("./PartnerLink"));
8
8
  var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
9
9
  var _data = require("../../../styleguide/data/data");
10
- it('renders correctly', () => {
10
+ it("renders correctly", () => {
11
11
  const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_PartnerLink.default, {
12
12
  link: "https://www.comicrelief.com"
13
13
  }, /*#__PURE__*/_react.default.createElement(_Picture.default, {
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.39.0",
4
+ "version": "7.40.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import styled, { withTheme } from 'styled-components';
2
+ import styled, { css, withTheme } from 'styled-components';
3
3
  import PropTypes from 'prop-types';
4
+ import spacing from '../../../theme/shared/spacing';
4
5
 
5
6
  import 'lazysizes';
6
7
  import 'lazysizes/plugins/blur-up/ls.blur-up';
@@ -23,12 +24,48 @@ const Image = styled.img`
23
24
  display: block;
24
25
  object-fit: ${props => (props.objectFit === 'none' && 'none')
25
26
  || (props.objectFit === 'cover' && 'cover')
26
- || (props.objectFit === 'contain' && 'contain')};
27
+ || (props.objectFit === 'contain' && 'contain')};
27
28
  ${({ objectFit, objFitState }) => (objectFit !== 'none' && !objFitState) && 'visibility: hidden;'}; // Allows image to provide the container height, but make it invisible
29
+
30
+ /* Check for Cards/smallBreakpointRowLayout prop coming from the CMS and adjust styling for row view */
31
+ ${({ smallBreakpointRowLayout }) => (smallBreakpointRowLayout === true) && css`
32
+ @media ${({ theme }) => theme.allBreakpoints('S')} {
33
+ padding: ${spacing('sm')};
34
+ border-radius: ${spacing('md')};
35
+ width: 110px;
36
+ height: 110px;
37
+ }
38
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
39
+ padding: none;
40
+ border-radius: none;
41
+ width: ${props => (props.width ? props.width : '100%')};
42
+ height: ${props => (props.height ? props.height : 'auto')};
43
+ }
44
+ `}
45
+
46
+ /* Check for Cards/mediumBreakpointRowLayout prop coming from the CMS and adjust styling for row view */
47
+ ${({ mediumBreakpointRowLayout }) => (mediumBreakpointRowLayout === true) && css`
48
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
49
+ padding: ${spacing('sm')};
50
+ border-radius: ${spacing('md')};
51
+ width: 120px;
52
+ height: 120px;
53
+ }
54
+ `}
55
+
56
+ /* Check for Cards/smallBreakpointRowLayout or mediumBreakpointRowLayout prop coming from the CMS and adjust styling back to normal */
57
+ ${({ smallBreakpointRowLayout, mediumBreakpointRowLayout }) => ((smallBreakpointRowLayout === true) || (mediumBreakpointRowLayout === true)) && css`
58
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
59
+ padding: none;
60
+ border-radius: none;
61
+ width: ${props => (props.width ? props.width : '100%')};
62
+ height: ${props => (props.height ? props.height : 'auto')};
63
+ }
64
+ `}
65
+
28
66
  `;
29
67
 
30
68
  /** Responsive Picture */
31
-
32
69
  const Picture = ({
33
70
  images,
34
71
  image,
@@ -38,6 +75,8 @@ const Picture = ({
38
75
  objectFit,
39
76
  imageLow,
40
77
  isBackgroundImage,
78
+ smallBreakpointRowLayout,
79
+ mediumBreakpointRowLayout,
41
80
  ...rest
42
81
  }) => {
43
82
  const document = typeof window !== 'undefined' ? window.document : null;
@@ -109,6 +148,8 @@ const Picture = ({
109
148
  data-lowsrc={imageLow}
110
149
  className="lazyload"
111
150
  objFitState={objFitState}
151
+ smallBreakpointRowLayout={smallBreakpointRowLayout}
152
+ mediumBreakpointRowLayout={mediumBreakpointRowLayout}
112
153
  />
113
154
  </Wrapper>
114
155
  );
@@ -128,7 +169,9 @@ Picture.propTypes = {
128
169
  ]),
129
170
  width: PropTypes.string,
130
171
  height: PropTypes.string,
131
- isBackgroundImage: PropTypes.bool
172
+ isBackgroundImage: PropTypes.bool,
173
+ smallBreakpointRowLayout: PropTypes.bool,
174
+ mediumBreakpointRowLayout: PropTypes.bool
132
175
  };
133
176
 
134
177
  Picture.defaultProps = {
@@ -139,7 +182,9 @@ Picture.defaultProps = {
139
182
  width: '100%',
140
183
  height: 'auto',
141
184
  alt: '',
142
- isBackgroundImage: false
185
+ isBackgroundImage: false,
186
+ smallBreakpointRowLayout: null,
187
+ mediumBreakpointRowLayout: null
143
188
  };
144
189
 
145
190
  export default withTheme(Picture);
@@ -1,11 +1,15 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
3
- import renderWithTheme from '../../../hoc/shallowWithTheme';
4
- import Picture from './Picture';
5
- import { defaultData } from '../../../styleguide/data/data';
6
- it('renders correctly', () => {
1
+ import React from "react";
2
+ import "jest-styled-components";
3
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
4
+ import Picture from "./Picture";
5
+ import { defaultData } from "../../../styleguide/data/data";
6
+ it("renders correctly", () => {
7
7
  const tree = renderWithTheme(
8
- <Picture images={defaultData.images} image={defaultData.image} alt="Test images" />
8
+ <Picture
9
+ images={defaultData.images}
10
+ image={defaultData.image}
11
+ alt="Test images"
12
+ />
9
13
  ).toJSON();
10
14
 
11
15
  expect(tree).toMatchInlineSnapshot(`
@@ -44,7 +48,7 @@ it('renders correctly', () => {
44
48
  `);
45
49
  });
46
50
 
47
- it('renders correctly with custom props', () => {
51
+ it("renders correctly with custom props", () => {
48
52
  const tree = renderWithTheme(
49
53
  <Picture
50
54
  images={defaultData.images}
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
3
- import renderWithTheme from '../../../hoc/shallowWithTheme';
4
- import ArticleTeaser from './ArticleTeaser';
5
- import { defaultData } from '../../../styleguide/data/data';
6
- it('renders article teaser correctly', () => {
1
+ import React from "react";
2
+ import "jest-styled-components";
3
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
4
+ import ArticleTeaser from "./ArticleTeaser";
5
+ import { defaultData } from "../../../styleguide/data/data";
6
+ it("renders article teaser correctly", () => {
7
7
  const tree = renderWithTheme(
8
8
  <ArticleTeaser
9
9
  href="/test"
@@ -258,7 +258,7 @@ it('renders article teaser correctly', () => {
258
258
  `);
259
259
  });
260
260
 
261
- it('renders press realese correctly', () => {
261
+ it("renders press realese correctly", () => {
262
262
  const tree = renderWithTheme(
263
263
  <ArticleTeaser
264
264
  href="/test"
@@ -1,28 +1,7 @@
1
1
  import React from 'react';
2
- import styled from 'styled-components';
3
2
  import PropTypes from 'prop-types';
4
3
  import Picture from '../../Atoms/Picture/Picture';
5
- import spacing from '../../../theme/shared/spacing';
6
-
7
- const Container = styled.div`
8
- display: flex;
9
- position: relative;
10
- flex-direction: column;
11
- height: 100%;
12
- border-radius: ${props => (props.squaredCorners ? '0' : '1rem')};
13
- overflow: hidden;
14
- background: ${({ theme, backgroundColor }) => theme.color(backgroundColor)};
15
- `;
16
-
17
- const Image = styled.div`
18
- height: auto;
19
- `;
20
-
21
- const Copy = styled.div`
22
- padding: ${spacing('l')};
23
- display: flex;
24
- flex-direction: column;
25
- `;
4
+ import { Container, Wrapper, Copy } from './Card.style';
26
5
 
27
6
  const Card = ({
28
7
  backgroundColor,
@@ -34,11 +13,19 @@ const Card = ({
34
13
  width,
35
14
  children,
36
15
  squaredCorners,
16
+ smallBreakpointRowLayout,
17
+ mediumBreakpointRowLayout,
37
18
  ...rest
38
19
  }) => (
39
- <Container backgroundColor={backgroundColor} squaredCorners={squaredCorners} {...rest}>
20
+ <Container
21
+ backgroundColor={backgroundColor}
22
+ squaredCorners={squaredCorners}
23
+ smallBreakpointRowLayout={smallBreakpointRowLayout}
24
+ mediumBreakpointRowLayout={mediumBreakpointRowLayout}
25
+ {...rest}
26
+ >
40
27
  {imageLow ? (
41
- <Image>
28
+ <Wrapper>
42
29
  <Picture
43
30
  alt={imageAltText}
44
31
  imageLow={imageLow}
@@ -47,10 +34,20 @@ const Card = ({
47
34
  objectFit="cover"
48
35
  width={width}
49
36
  height={height}
37
+ smallBreakpointRowLayout={smallBreakpointRowLayout}
38
+ mediumBreakpointRowLayout={mediumBreakpointRowLayout}
50
39
  />
51
- </Image>
40
+ </Wrapper>
52
41
  ) : null}
53
- {children ? <Copy>{children}</Copy> : null}
42
+ {children
43
+ ? (
44
+ <Copy
45
+ smallBreakpointRowLayout={smallBreakpointRowLayout}
46
+ mediumBreakpointRowLayout={mediumBreakpointRowLayout}
47
+ >
48
+ {children}
49
+ </Copy>
50
+ ) : null}
54
51
  </Container>
55
52
  );
56
53
 
@@ -63,7 +60,9 @@ Card.propTypes = {
63
60
  height: PropTypes.string,
64
61
  imageAltText: PropTypes.string,
65
62
  children: PropTypes.node,
66
- squaredCorners: PropTypes.bool
63
+ squaredCorners: PropTypes.bool,
64
+ smallBreakpointRowLayout: PropTypes.bool,
65
+ mediumBreakpointRowLayout: PropTypes.bool
67
66
  };
68
67
 
69
68
  Card.defaultProps = {
@@ -75,7 +74,9 @@ Card.defaultProps = {
75
74
  imageAltText: '',
76
75
  width: '100%',
77
76
  height: '100%',
78
- squaredCorners: false
77
+ squaredCorners: false,
78
+ smallBreakpointRowLayout: null,
79
+ mediumBreakpointRowLayout: null
79
80
  };
80
81
 
81
82
  export default Card;
@@ -1,5 +1,4 @@
1
1
  # Card
2
-
3
2
  ```js
4
3
  const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
5
4
  import Link from '../../Atoms/Link/Link';
@@ -7,7 +6,7 @@ import Link from '../../Atoms/Link/Link';
7
6
  <Card
8
7
  imageLow={defaultData.image}
9
8
  images={defaultData.images}
10
- backgroundColor="yellow"
9
+ backgroundColor="grey_light"
11
10
  height="auto"
12
11
  >
13
12
  <Text tag="h3" color="purple" size="xl">
@@ -17,9 +16,78 @@ import Link from '../../Atoms/Link/Link';
17
16
  </Card>;
18
17
  ```
19
18
 
19
+ ### Card - row layout on small breakpoint only
20
+ ```js
21
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
22
+ import Link from '../../Atoms/Link/Link';
23
+
24
+ <Card
25
+ imageLow={defaultData.image}
26
+ images={defaultData.images}
27
+ backgroundColor="grey_light"
28
+ height="auto"
29
+ smallBreakpointRowLayout={true}
30
+ mediumBreakpointRowLayout={false}
31
+ >
32
+ <Text tag="h3" color="purple" size="xl">
33
+ Title
34
+ </Text>
35
+ <Text tag="p">
36
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
37
+ </Text>
38
+ </Card>;
39
+ ```
40
+
41
+ ### Card - row layout on medium breakpoint only
42
+ ```js
43
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
44
+ import Link from '../../Atoms/Link/Link';
45
+
46
+ <Card
47
+ imageLow={defaultData.image}
48
+ images={defaultData.images}
49
+ backgroundColor="grey_light"
50
+ height="auto"
51
+ smallBreakpointRowLayout={false}
52
+ mediumBreakpointRowLayout={true}
53
+ >
54
+ <Text tag="h3" color="purple" size="xl">
55
+ Title
56
+ </Text>
57
+ <Text tag="p">
58
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
59
+ </Text>
60
+ </Card>;
61
+ ```
62
+
63
+ ### Card - row layout on small and medium breakpoints
64
+ ```js
65
+ const defaultData = require('../../../styleguide/data/data').defaultData;import Text from '../../Atoms/Text/Text';
66
+ import Link from '../../Atoms/Link/Link';
67
+
68
+ <Card
69
+ imageLow={defaultData.image}
70
+ images={defaultData.images}
71
+ backgroundColor="grey_light"
72
+ height="auto"
73
+ smallBreakpointRowLayout={true}
74
+ mediumBreakpointRowLayout={true}
75
+ >
76
+ <Text tag="h3" color="purple" size="xl">
77
+ Title
78
+ </Text>
79
+ <Text tag="p">
80
+ Your donations make a very real difference to people in the UK and around the world, whether you donate through Red Nose Day, Sport Relief or to Comic Relief at any other time of year. Here are some of the many stories that show how people are changing their lives with your support.
81
+ </Text>
82
+ </Card>;
83
+ ```
84
+
20
85
  ### Card no body
21
86
 
22
87
  ```js
23
88
  const defaultData = require('../../../styleguide/data/data').defaultData;
24
- <Card imageLow={defaultData.image} images={defaultData.image} />;
89
+ <Card
90
+ imageLow={defaultData.image}
91
+ images={defaultData.image}
92
+ />;
25
93
  ```
@@ -0,0 +1,77 @@
1
+ import styled, { css } from 'styled-components';
2
+ import spacing from '../../../theme/shared/spacing';
3
+
4
+ const Container = styled.div`
5
+ position: relative;
6
+ display: flex;
7
+
8
+ /* Check for Cards/smallBreakpointRowLayout prop coming from the CMS, if so make horizontal layout */
9
+ @media ${({ theme }) => theme.allBreakpoints('S')} {
10
+ flex-direction: ${props => ((props.smallBreakpointRowLayout === true) ? 'row' : 'column')};
11
+ }
12
+
13
+ /* Check for Cards/mediumBreakpointRowLayout prop coming from the CMS, if so make horizontal layout */
14
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
15
+ flex-direction: ${props => ((props.mediumBreakpointRowLayout === true) ? 'row' : 'column')};
16
+ }
17
+
18
+ /* Set desktop and upwards to normal vertical layout */
19
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
20
+ flex-direction: column;
21
+ }
22
+
23
+ height: 100%;
24
+ border-radius: ${props => (props.squaredCorners ? '0' : '1rem')};
25
+ overflow: hidden;
26
+ background: ${({ theme, backgroundColor }) => theme.color(backgroundColor)};
27
+ `;
28
+
29
+ const Wrapper = styled.div`
30
+ height: auto;
31
+ `;
32
+
33
+ const Copy = styled.div`
34
+ display: flex;
35
+ flex-direction: column;
36
+ padding: ${spacing('l')};
37
+
38
+ /* Check for Cards/smallBreakpointRowLayout prop coming from the CMS, adjust text spacing */
39
+ ${({ smallBreakpointRowLayout }) => (smallBreakpointRowLayout
40
+ === true) && css`
41
+ @media ${({ theme }) => theme.allBreakpoints('S')} {
42
+ padding: ${props => ((props.smallBreakpointRowLayout === true) && `${spacing('sm')}`)};
43
+ h1, h2, h3, h4, h5 {
44
+ margin: ${props => ((props.smallBreakpointRowLayout === true) && `${spacing('sm')} 0 ${spacing('sm')}`)};
45
+ }
46
+ }
47
+ `}
48
+
49
+ /* Check for Cards/mediumBreakpointRowLayout prop coming from the CMS, adjust text spacing */
50
+ ${({ mediumBreakpointRowLayout }) => (mediumBreakpointRowLayout
51
+ === true) && css`
52
+ @media ${({ theme }) => theme.allBreakpoints('M')} {
53
+ padding: ${props => ((props.mediumBreakpointRowLayout === true) && `${spacing('sm')}`)};
54
+ h1, h2, h3, h4, h5 {
55
+ margin: ${props => ((props.mediumBreakpointRowLayout === true) && `${spacing('sm')} 0 ${spacing('sm')}`)};
56
+ }
57
+ }
58
+ `}
59
+
60
+ /* Check for Cards/smallBreakpointRowLayout or mediumBreakpointRowLayout prop coming from the CMS and adjust styling back to normal */
61
+ ${({ smallBreakpointRowLayout, mediumBreakpointRowLayout }) => ((smallBreakpointRowLayout === true) || (mediumBreakpointRowLayout === true)) && css`
62
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
63
+ padding: ${spacing('l')};
64
+ h1 {
65
+ margin: 0 0 1rem 0;
66
+ }
67
+ h2 {
68
+ margin-bottom: 2rem;
69
+ }
70
+ h3, h4, h5 {
71
+ margin-bottom: 1rem;
72
+ }
73
+ }
74
+ `}
75
+ `;
76
+
77
+ export { Container, Wrapper, Copy };
@@ -14,6 +14,23 @@ it('renders correctly', () => {
14
14
  expect(tree).toMatchSnapshot();
15
15
  });
16
16
 
17
+ it('renders correctly', () => {
18
+ const tree = renderWithTheme(
19
+ <Card
20
+ image={defaultData.image}
21
+ images={defaultData.image}
22
+ backgroundColor="yellow"
23
+ smallBreakpointLayout="Row"
24
+ mediumBreakpointLayout="Row"
25
+ >
26
+ <h2>Title</h2>
27
+ <p>Text body copy description. Loads more text test. Loads more text test.</p>
28
+ </Card>
29
+ ).toJSON();
30
+
31
+ expect(tree).toMatchSnapshot();
32
+ });
33
+
17
34
  it('renders correctly with no body', () => {
18
35
  const tree = renderWithTheme(
19
36
  <Card imageLow={defaultData.image} images={defaultData.image} backgroundColor="yellow" />
@@ -2,14 +2,75 @@
2
2
 
3
3
  exports[`renders correctly 1`] = `
4
4
  .c0 {
5
+ position: relative;
6
+ display: -webkit-box;
7
+ display: -webkit-flex;
8
+ display: -ms-flexbox;
9
+ display: flex;
10
+ height: 100%;
11
+ border-radius: 1rem;
12
+ overflow: hidden;
13
+ background: #FFE400;
14
+ }
15
+
16
+ .c1 {
5
17
  display: -webkit-box;
6
18
  display: -webkit-flex;
7
19
  display: -ms-flexbox;
8
20
  display: flex;
9
- position: relative;
10
21
  -webkit-flex-direction: column;
11
22
  -ms-flex-direction: column;
12
23
  flex-direction: column;
24
+ padding: 2rem;
25
+ }
26
+
27
+ @media (min-width:0px) {
28
+ .c0 {
29
+ -webkit-flex-direction: column;
30
+ -ms-flex-direction: column;
31
+ flex-direction: column;
32
+ }
33
+ }
34
+
35
+ @media (min-width:740px) {
36
+ .c0 {
37
+ -webkit-flex-direction: column;
38
+ -ms-flex-direction: column;
39
+ flex-direction: column;
40
+ }
41
+ }
42
+
43
+ @media (min-width:1024px) {
44
+ .c0 {
45
+ -webkit-flex-direction: column;
46
+ -ms-flex-direction: column;
47
+ flex-direction: column;
48
+ }
49
+ }
50
+
51
+ <div
52
+ className="c0"
53
+ >
54
+ <div
55
+ className="c1"
56
+ >
57
+ <h2>
58
+ Title
59
+ </h2>
60
+ <p>
61
+ Description
62
+ </p>
63
+ </div>
64
+ </div>
65
+ `;
66
+
67
+ exports[`renders correctly 2`] = `
68
+ .c0 {
69
+ position: relative;
70
+ display: -webkit-box;
71
+ display: -webkit-flex;
72
+ display: -ms-flexbox;
73
+ display: flex;
13
74
  height: 100%;
14
75
  border-radius: 1rem;
15
76
  overflow: hidden;
@@ -17,7 +78,6 @@ exports[`renders correctly 1`] = `
17
78
  }
18
79
 
19
80
  .c1 {
20
- padding: 2rem;
21
81
  display: -webkit-box;
22
82
  display: -webkit-flex;
23
83
  display: -ms-flexbox;
@@ -25,6 +85,31 @@ exports[`renders correctly 1`] = `
25
85
  -webkit-flex-direction: column;
26
86
  -ms-flex-direction: column;
27
87
  flex-direction: column;
88
+ padding: 2rem;
89
+ }
90
+
91
+ @media (min-width:0px) {
92
+ .c0 {
93
+ -webkit-flex-direction: column;
94
+ -ms-flex-direction: column;
95
+ flex-direction: column;
96
+ }
97
+ }
98
+
99
+ @media (min-width:740px) {
100
+ .c0 {
101
+ -webkit-flex-direction: column;
102
+ -ms-flex-direction: column;
103
+ flex-direction: column;
104
+ }
105
+ }
106
+
107
+ @media (min-width:1024px) {
108
+ .c0 {
109
+ -webkit-flex-direction: column;
110
+ -ms-flex-direction: column;
111
+ flex-direction: column;
112
+ }
28
113
  }
29
114
 
30
115
  <div
@@ -37,7 +122,7 @@ exports[`renders correctly 1`] = `
37
122
  Title
38
123
  </h2>
39
124
  <p>
40
- Description
125
+ Text body copy description. Loads more text test. Loads more text test.
41
126
  </p>
42
127
  </div>
43
128
  </div>
@@ -59,14 +144,11 @@ exports[`renders correctly with no body 1`] = `
59
144
  }
60
145
 
61
146
  .c0 {
147
+ position: relative;
62
148
  display: -webkit-box;
63
149
  display: -webkit-flex;
64
150
  display: -ms-flexbox;
65
151
  display: flex;
66
- position: relative;
67
- -webkit-flex-direction: column;
68
- -ms-flex-direction: column;
69
- flex-direction: column;
70
152
  height: 100%;
71
153
  border-radius: 1rem;
72
154
  overflow: hidden;
@@ -77,6 +159,30 @@ exports[`renders correctly with no body 1`] = `
77
159
  height: auto;
78
160
  }
79
161
 
162
+ @media (min-width:0px) {
163
+ .c0 {
164
+ -webkit-flex-direction: column;
165
+ -ms-flex-direction: column;
166
+ flex-direction: column;
167
+ }
168
+ }
169
+
170
+ @media (min-width:740px) {
171
+ .c0 {
172
+ -webkit-flex-direction: column;
173
+ -ms-flex-direction: column;
174
+ flex-direction: column;
175
+ }
176
+ }
177
+
178
+ @media (min-width:1024px) {
179
+ .c0 {
180
+ -webkit-flex-direction: column;
181
+ -ms-flex-direction: column;
182
+ flex-direction: column;
183
+ }
184
+ }
185
+
80
186
  <div
81
187
  className="c0"
82
188
  >
@@ -1,14 +1,18 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
1
+ import React from "react";
2
+ import "jest-styled-components";
3
3
 
4
- import renderWithTheme from '../../../hoc/shallowWithTheme';
5
- import PartnerLink from './PartnerLink';
6
- import Picture from '../../Atoms/Picture/Picture';
7
- import { defaultData } from '../../../styleguide/data/data';
8
- it('renders correctly', () => {
4
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
5
+ import PartnerLink from "./PartnerLink";
6
+ import Picture from "../../Atoms/Picture/Picture";
7
+ import { defaultData } from "../../../styleguide/data/data";
8
+ it("renders correctly", () => {
9
9
  const tree = renderWithTheme(
10
10
  <PartnerLink link="https://www.comicrelief.com">
11
- <Picture alt="test Image" imageLow={defaultData.imageLow} images={defaultData.images} />
11
+ <Picture
12
+ alt="test Image"
13
+ imageLow={defaultData.imageLow}
14
+ images={defaultData.images}
15
+ />
12
16
  </PartnerLink>
13
17
  ).toJSON();
14
18