@comicrelief/component-library 7.38.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.
Files changed (53) hide show
  1. package/dist/components/Atoms/Button/Button.js +9 -5
  2. package/dist/components/Atoms/Button/Button.test.js +2 -2
  3. package/dist/components/Atoms/Picture/Picture.js +49 -6
  4. package/dist/components/Atoms/Picture/Picture.test.js +2 -2
  5. package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +2 -2
  6. package/dist/components/Molecules/Card/Card.js +20 -28
  7. package/dist/components/Molecules/Card/Card.md +71 -3
  8. package/dist/components/Molecules/Card/Card.style.js +74 -0
  9. package/dist/components/Molecules/Card/Card.test.js +10 -0
  10. package/dist/components/Molecules/Card/__snapshots__/Card.test.js.snap +113 -7
  11. package/dist/components/Molecules/Chip/Chip.style.js +26 -22
  12. package/dist/components/Molecules/Chip/Chip.test.js +2 -2
  13. package/dist/components/Molecules/PartnerLink/PartnerLink.test.js +1 -1
  14. package/dist/components/Molecules/Promo/Promo.style.js +65 -20
  15. package/dist/components/Molecules/SearchInput/SearchInput.style.js +7 -3
  16. package/dist/components/Molecules/SingleMessage/SingleMessage.style.js +89 -59
  17. package/dist/components/Organisms/Donate/Donate.style.js +96 -42
  18. package/dist/components/Organisms/Donate/Form/PopUpComponent.js +11 -7
  19. package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.style.js +17 -13
  20. package/dist/components/Organisms/Donate/MoneyBuy/MoneyBuy.js +17 -13
  21. package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +8 -6
  22. package/dist/components/Organisms/Header/Header.style.js +2 -2
  23. package/dist/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDS.style.js +35 -26
  24. package/dist/components/Organisms/Membership/Membership.style.js +43 -24
  25. package/dist/index.js +7 -0
  26. package/dist/theme/shared/allContainers.js +12 -0
  27. package/package.json +1 -1
  28. package/src/components/Atoms/Button/Button.js +1 -2
  29. package/src/components/Atoms/Button/Button.test.js +12 -10
  30. package/src/components/Atoms/Picture/Picture.js +50 -5
  31. package/src/components/Atoms/Picture/Picture.test.js +12 -8
  32. package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +7 -7
  33. package/src/components/Molecules/Card/Card.js +29 -28
  34. package/src/components/Molecules/Card/Card.md +71 -3
  35. package/src/components/Molecules/Card/Card.style.js +77 -0
  36. package/src/components/Molecules/Card/Card.test.js +17 -0
  37. package/src/components/Molecules/Card/__snapshots__/Card.test.js.snap +113 -7
  38. package/src/components/Molecules/Chip/Chip.style.js +1 -2
  39. package/src/components/Molecules/Chip/Chip.test.js +12 -10
  40. package/src/components/Molecules/PartnerLink/PartnerLink.test.js +12 -8
  41. package/src/components/Molecules/Promo/Promo.style.js +10 -10
  42. package/src/components/Molecules/SearchInput/SearchInput.style.js +1 -2
  43. package/src/components/Molecules/SingleMessage/SingleMessage.style.js +7 -7
  44. package/src/components/Organisms/Donate/Donate.style.js +11 -12
  45. package/src/components/Organisms/Donate/Form/PopUpComponent.js +1 -2
  46. package/src/components/Organisms/Donate/GivingSelector/GivingSelector.style.js +1 -2
  47. package/src/components/Organisms/Donate/MoneyBuy/MoneyBuy.js +1 -2
  48. package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +8 -6
  49. package/src/components/Organisms/Header/Header.style.js +1 -1
  50. package/src/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDS.style.js +2 -3
  51. package/src/components/Organisms/Membership/Membership.style.js +4 -5
  52. package/src/index.js +1 -0
  53. package/src/theme/shared/allContainers.js +7 -0
@@ -9,7 +9,6 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
  var _Input = _interopRequireDefault(require("../../Atoms/Input/Input"));
10
10
  var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
11
11
  var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
12
- var _size = require("../../../theme/shared/size");
13
12
  var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
14
13
  const Container = exports.Container = _styledComponents.default.div.withConfig({
15
14
  displayName: "Membershipstyle__Container",
@@ -49,7 +48,12 @@ const BgImage = exports.BgImage = (0, _styledComponents.default)(_Picture.defaul
49
48
  const Wrapper = exports.Wrapper = _styledComponents.default.div.withConfig({
50
49
  displayName: "Membershipstyle__Wrapper",
51
50
  componentId: "sc-13acbel-2"
52
- })(["position:relative;max-width:320px;text-align:center;margin-bottom:50%;", "{margin:0 ", ";max-width:420px;}"], (0, _size.media)('medium'), (0, _spacing.default)('xxl'));
51
+ })(["position:relative;max-width:320px;text-align:center;margin-bottom:50%;@media ", "{margin:0 ", ";max-width:420px;}"], _ref6 => {
52
+ let {
53
+ theme
54
+ } = _ref6;
55
+ return theme.allBreakpoints('L');
56
+ }, (0, _spacing.default)('xxl'));
53
57
  const Header = exports.Header = _styledComponents.default.div.withConfig({
54
58
  displayName: "Membershipstyle__Header",
55
59
  componentId: "sc-13acbel-3"
@@ -57,19 +61,24 @@ const Header = exports.Header = _styledComponents.default.div.withConfig({
57
61
  const FormWrapper = exports.FormWrapper = _styledComponents.default.div.withConfig({
58
62
  displayName: "Membershipstyle__FormWrapper",
59
63
  componentId: "sc-13acbel-4"
60
- })(["background-color:", ";box-shadow:0px ", " ", " rgba(0,0,0,0.3);height:450px;", "{height:430px;}"], _ref6 => {
64
+ })(["background-color:", ";box-shadow:0px ", " ", " rgba(0,0,0,0.3);height:450px;@media ", "{height:430px;}"], _ref7 => {
61
65
  let {
62
66
  theme
63
- } = _ref6;
67
+ } = _ref7;
64
68
  return theme.color('white');
65
- }, (0, _spacing.default)('md'), (0, _spacing.default)('xl'), (0, _size.media)('medium'));
69
+ }, (0, _spacing.default)('md'), (0, _spacing.default)('xl'), _ref8 => {
70
+ let {
71
+ theme
72
+ } = _ref8;
73
+ return theme.allBreakpoints('L');
74
+ });
66
75
  const Error = exports.Error = (0, _styledComponents.default)(_Text.default).withConfig({
67
76
  displayName: "Membershipstyle__Error",
68
77
  componentId: "sc-13acbel-5"
69
- })(["color:", ";font-size:", ";font-weight:500;"], _ref7 => {
78
+ })(["color:", ";font-size:", ";font-weight:500;"], _ref9 => {
70
79
  let {
71
80
  theme
72
- } = _ref7;
81
+ } = _ref9;
73
82
  return theme.color('red');
74
83
  }, (0, _spacing.default)('md'));
75
84
  const Form = exports.Form = _styledComponents.default.form.withConfig({
@@ -87,10 +96,10 @@ const Legend = exports.Legend = _styledComponents.default.legend.withConfig({
87
96
  const MoneyBuys = exports.MoneyBuys = _styledComponents.default.div.withConfig({
88
97
  displayName: "Membershipstyle__MoneyBuys",
89
98
  componentId: "sc-13acbel-9"
90
- })(["display:flex;justify-content:space-between;label{flex:0 0 30%;input{cursor:pointer;padding:", ";}:hover input{border-color:", ";}}"], (0, _spacing.default)('md'), _ref8 => {
99
+ })(["display:flex;justify-content:space-between;label{flex:0 0 30%;input{cursor:pointer;padding:", ";}:hover input{border-color:", ";}}"], (0, _spacing.default)('md'), _ref10 => {
91
100
  let {
92
101
  theme
93
- } = _ref8;
102
+ } = _ref10;
94
103
  return theme.color('red');
95
104
  });
96
105
  const FormFieldset = exports.FormFieldset = _styledComponents.default.div.withConfig({
@@ -104,21 +113,26 @@ const Label = exports.Label = (0, _styledComponents.default)(_Text.default).with
104
113
  const AmountField = exports.AmountField = (0, _styledComponents.default)(_Input.default).withConfig({
105
114
  displayName: "Membershipstyle__AmountField",
106
115
  componentId: "sc-13acbel-12"
107
- })(["position:relative;flex:0 0 50%;font-weight:400;display:block;", "{flex:0 0 60%;}span{position:absolute;padding:0px 15px;font-size:20px;top:50%;transform:translateY(-50%);left:0px;font-weight:500;}input{border:2px solid ", ";background:transparent;padding:", " ", " ", " ", ";", " :focus{border:2px solid ", ";}}"], (0, _size.media)('medium'), _ref9 => {
116
+ })(["position:relative;flex:0 0 50%;font-weight:400;display:block;@media ", "{flex:0 0 60%;}span{position:absolute;padding:0px 15px;font-size:20px;top:50%;transform:translateY(-50%);left:0px;font-weight:500;}input{border:2px solid ", ";background:transparent;padding:", " ", " ", " ", ";", " :focus{border:2px solid ", ";}}"], _ref11 => {
108
117
  let {
109
118
  theme
110
- } = _ref9;
119
+ } = _ref11;
120
+ return theme.allBreakpoints('L');
121
+ }, _ref12 => {
122
+ let {
123
+ theme
124
+ } = _ref12;
111
125
  return theme.color('grey_medium');
112
- }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), (0, _spacing.default)('sm'), (0, _spacing.default)('l'), _ref10 => {
126
+ }, (0, _spacing.default)('sm'), (0, _spacing.default)('md'), (0, _spacing.default)('sm'), (0, _spacing.default)('l'), _ref13 => {
113
127
  let {
114
128
  inputBorderColor,
115
129
  theme
116
- } = _ref10;
130
+ } = _ref13;
117
131
  return inputBorderColor && "border: 2px solid ".concat(theme.color('red'), ";");
118
- }, _ref11 => {
132
+ }, _ref14 => {
119
133
  let {
120
134
  theme
121
- } = _ref11;
135
+ } = _ref14;
122
136
  return theme.color('red');
123
137
  });
124
138
  const Copy = exports.Copy = (0, _styledComponents.default)(_Text.default).withConfig({
@@ -128,25 +142,30 @@ const Copy = exports.Copy = (0, _styledComponents.default)(_Text.default).withCo
128
142
  const Button = exports.Button = _styledComponents.default.button.withConfig({
129
143
  displayName: "Membershipstyle__Button",
130
144
  componentId: "sc-13acbel-14"
131
- })(["width:100%;color:", ";font-size:", ";font-weight:bold;cursor:pointer;padding:", " ", ";background:", ";border:none;border-radius:100px;:active,:focus,:hover{background-color:", ";}", "{width:auto;padding:", " ", ";margin:0 auto ", ";}"], _ref12 => {
145
+ })(["width:100%;color:", ";font-size:", ";font-weight:bold;cursor:pointer;padding:", " ", ";background:", ";border:none;border-radius:100px;:active,:focus,:hover{background-color:", ";}@media ", "{width:auto;padding:", " ", ";margin:0 auto ", ";}"], _ref15 => {
132
146
  let {
133
147
  theme
134
- } = _ref12;
148
+ } = _ref15;
135
149
  return theme.color('white');
136
- }, _ref13 => {
150
+ }, _ref16 => {
137
151
  let {
138
152
  theme
139
- } = _ref13;
153
+ } = _ref16;
140
154
  return theme.fontSize('s');
141
- }, (0, _spacing.default)('md'), (0, _spacing.default)('sm'), _ref14 => {
155
+ }, (0, _spacing.default)('md'), (0, _spacing.default)('sm'), _ref17 => {
142
156
  let {
143
157
  theme,
144
158
  color
145
- } = _ref14;
159
+ } = _ref17;
146
160
  return color ? theme.color(color) : theme.color('red');
147
- }, _ref15 => {
161
+ }, _ref18 => {
148
162
  let {
149
163
  theme
150
- } = _ref15;
164
+ } = _ref18;
151
165
  return theme.color('coral_dark');
152
- }, (0, _size.media)('medium'), (0, _spacing.default)('md'), (0, _spacing.default)('l'), (0, _spacing.default)('l'));
166
+ }, _ref19 => {
167
+ let {
168
+ theme
169
+ } = _ref19;
170
+ return theme.allBreakpoints('L');
171
+ }, (0, _spacing.default)('md'), (0, _spacing.default)('l'), (0, _spacing.default)('l'));
package/dist/index.js CHANGED
@@ -328,6 +328,12 @@ Object.defineProperty(exports, "WYMDCarousel", {
328
328
  return _WYMDCarousel.default;
329
329
  }
330
330
  });
331
+ Object.defineProperty(exports, "allBreakpoints", {
332
+ enumerable: true,
333
+ get: function () {
334
+ return _allBreakpoints.default;
335
+ }
336
+ });
331
337
  Object.defineProperty(exports, "allowListed", {
332
338
  enumerable: true,
333
339
  get: function () {
@@ -414,6 +420,7 @@ var _zIndex = _interopRequireDefault(require("./theme/shared/zIndex"));
414
420
  var _allowListed = _interopRequireDefault(require("./utils/allowListed"));
415
421
  var _spacing = _interopRequireDefault(require("./theme/shared/spacing"));
416
422
  var _breakpoint = _interopRequireDefault(require("./theme/shared/breakpoint"));
423
+ var _allBreakpoints = _interopRequireDefault(require("./theme/shared/allBreakpoints"));
417
424
  var _size = require("./theme/shared/size");
418
425
  var _Text = _interopRequireDefault(require("./components/Atoms/Text/Text"));
419
426
  var _Logo = _interopRequireDefault(require("./components/Atoms/Logo/Logo"));
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const container = {
8
+ small: '880px',
9
+ medium: '1200px',
10
+ large: '1440px'
11
+ };
12
+ var _default = exports.default = container;
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.38.0",
4
+ "version": "7.40.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
  import spacing from '../../../theme/shared/spacing';
5
- import media from '../../../theme/shared/breakpoint';
6
5
 
7
6
  const StyledButton = styled.button`
8
7
  display: inline-flex;
@@ -27,7 +26,7 @@ const StyledButton = styled.button`
27
26
  width: auto;
28
27
  }
29
28
 
30
- ${media('medium')} {
29
+ @media ${({ theme }) => theme.allBreakpoints('L')} {
31
30
  width: auto;
32
31
  padding: ${spacing('md')} ${spacing('l')};
33
32
  margin: 0 auto ${spacing('l')};
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import 'jest-styled-components';
3
- import renderWithTheme from '../../../hoc/shallowWithTheme';
4
- import Button from './Button';
1
+ import React from "react";
2
+ import "jest-styled-components";
3
+ import renderWithTheme from "../../../hoc/shallowWithTheme";
4
+ import Button from "./Button";
5
5
 
6
- it('renders a standard styled link correctly', () => {
6
+ it("renders a standard styled link correctly", () => {
7
7
  const tree = renderWithTheme(
8
8
  <Button type="submit">A standard link</Button>
9
9
  ).toJSON();
@@ -49,15 +49,17 @@ it('renders a standard styled link correctly', () => {
49
49
  color: #FFFFFF;
50
50
  }
51
51
 
52
- .c0 (min-width:1024px) {
53
- width: auto;
54
- padding: 1rem 2rem;
55
- margin: 0 auto 2rem;
52
+ @media (min-width:740px) {
53
+ .c0 {
54
+ width: auto;
55
+ }
56
56
  }
57
57
 
58
- @media (min-width:740px) {
58
+ @media (min-width:1024px) {
59
59
  .c0 {
60
60
  width: auto;
61
+ padding: 1rem 2rem;
62
+ margin: 0 auto 2rem;
61
63
  }
62
64
  }
63
65
 
@@ -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 };