@comicrelief/component-library 8.89.1 → 8.90.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 (56) hide show
  1. package/dist/index.cjs.js +879 -829
  2. package/dist/index.es.js +4924 -4862
  3. package/package.json +1 -1
  4. package/src/components/Atoms/Icons/ArrowExample.jsx +8 -5
  5. package/src/components/Atoms/Icons/AtSign.js +4 -4
  6. package/src/components/Atoms/Icons/GiftAidLogo.js +13 -7
  7. package/src/components/Atoms/Icons/IconsExample.jsx +3 -1
  8. package/src/components/Atoms/Icons/Internal.js +4 -4
  9. package/src/components/Atoms/Icons/Post.js +4 -4
  10. package/src/components/Atoms/Link/Link.test.js +0 -2
  11. package/src/components/Molecules/Accordion/AccordionExample.jsx +11 -9
  12. package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +1 -1
  13. package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
  14. package/src/components/Molecules/Banner/Banner.js +2 -2
  15. package/src/components/Molecules/Banner/__snapshots__/Banner.test.js.snap +0 -1
  16. package/src/components/Molecules/Box/Box.js +1 -1
  17. package/src/components/Molecules/Box/__snapshots__/Box.test.js.snap +0 -1
  18. package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +0 -4
  19. package/src/components/Molecules/LogoLinked/LogoLinked.js +4 -4
  20. package/src/components/Molecules/LogoLinked/LogoLinked.style.js +2 -2
  21. package/src/components/Molecules/Lookup/Lookup.js +0 -2
  22. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.js +36 -7
  23. package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx +34 -33
  24. package/src/components/Molecules/PopUp/PopUpGiftAid/__snapshots__/PopUpGiftAid.test.js.snap +48 -36
  25. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.js +19 -3
  26. package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx +23 -37
  27. package/src/components/Molecules/PopUp/PopUpShared.style.js +47 -1
  28. package/src/components/Molecules/SearchResult/SearchResult.js +4 -4
  29. package/src/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
  30. package/src/components/Organisms/Donate/Donate.js +1 -1
  31. package/src/components/Organisms/Donate/Form/Form.js +2 -2
  32. package/src/components/Organisms/Donate/MoneyBuy/MoneyBuy.js +1 -1
  33. package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -7
  34. package/src/components/Organisms/DonateBanner/Form/Form.js +2 -2
  35. package/src/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +1 -1
  36. package/src/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +0 -7
  37. package/src/components/Organisms/DynamicGallery/_DynamicGalleryColumn.js +1 -1
  38. package/src/components/Organisms/DynamicGallery/__snapshots__/DynamicGallery.test.js.snap +0 -3
  39. package/src/components/Organisms/Footer/Footer.js +2 -2
  40. package/src/components/Organisms/Footer/FooterExample.jsx +3 -3
  41. package/src/components/Organisms/Footer/Nav/Nav.js +3 -3
  42. package/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +0 -49
  43. package/src/components/Organisms/Header/Burger/BurgerMenu.js +1 -1
  44. package/src/components/Organisms/Header/Header.js +1 -1
  45. package/src/components/Organisms/Header/HeaderNav/HeaderNav.js +3 -3
  46. package/src/components/Organisms/Header/Nav/Nav.js +2 -2
  47. package/src/components/Organisms/Header2025/Burger/BurgerMenu.js +1 -1
  48. package/src/components/Organisms/Header2025/Header2025.js +2 -2
  49. package/src/components/Organisms/Header2025/Header2025Example.jsx +2 -2
  50. package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.js +2 -2
  51. package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNavItem2025.js +4 -4
  52. package/src/components/Organisms/Header2025/HeaderNav2025/MoreNav.js +2 -2
  53. package/src/components/Organisms/MarketingPreferencesDS/_OptInCheckbox.js +1 -1
  54. package/src/components/Organisms/Membership/Form/Form.js +3 -3
  55. package/src/components/Organisms/Membership/Membership.test.js +0 -9
  56. package/src/components/Organisms/Membership/MoneyBox/MoneyBox.js +1 -1
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": "8.89.1",
4
+ "version": "8.90.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
7
7
  "files": [
@@ -19,12 +19,12 @@ const IconCard = styled.div`
19
19
  border: 1px solid #e1e2e3;
20
20
  border-radius: 6px;
21
21
  min-width: 100px;
22
- background: ${({ dark }) => dark ? '#222' : '#fff'};
22
+ background: ${({ $dark }) => ($dark ? '#222' : '#fff')};
23
23
  `;
24
24
 
25
25
  const Label = styled.p`
26
26
  font-size: 0.75rem;
27
- color: ${({ dark }) => dark ? '#fff' : '#333'};
27
+ color: ${({ $dark }) => ($dark ? '#fff' : '#333')};
28
28
  margin: 0;
29
29
  text-align: center;
30
30
  `;
@@ -52,9 +52,9 @@ export default function ArrowExample() {
52
52
  <h3>Colours</h3>
53
53
  <Grid>
54
54
  {colours.map(colour => (
55
- <IconCard key={colour} dark={colour === 'white'}>
55
+ <IconCard key={colour} $dark={colour === 'white'}>
56
56
  <Arrow size={48} colour={colour} direction="right" />
57
- <Label dark={colour === 'white'}>{colour}</Label>
57
+ <Label $dark={colour === 'white'}>{colour}</Label>
58
58
  </IconCard>
59
59
  ))}
60
60
  </Grid>
@@ -66,7 +66,10 @@ export default function ArrowExample() {
66
66
  {[16, 24, 32, 48, 64].map(size => (
67
67
  <IconCard key={size}>
68
68
  <Arrow size={size} colour="black" direction="right" />
69
- <Label>{size}px</Label>
69
+ <Label>
70
+ {size}
71
+ px
72
+ </Label>
70
73
  </IconCard>
71
74
  ))}
72
75
  </Grid>
@@ -6,11 +6,11 @@ const PATH_DATA = 'M40.811,9.307C36.607,4.664,30.48,2,24,2C11.458,2,2,11.458,2,2
6
6
 
7
7
  const StyledSVG = styled.svg`
8
8
  // Mobile-colour if available, else use standard prop
9
- fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
9
+ fill: ${({ $mobileColour, $colour, theme }) => ($mobileColour ? theme.color($mobileColour) : theme.color($colour))};
10
10
 
11
11
  // Reinstate standard styles for 'desktop', adding a fallback for good measure:
12
12
  @media ${({ theme }) => theme.allBreakpoints('L')} {
13
- fill: ${({ colour, theme }) => (colour ? theme.color(colour) : theme.color('white'))};
13
+ fill: ${({ $colour, theme }) => ($colour ? theme.color($colour) : theme.color('white'))};
14
14
  }
15
15
  `;
16
16
 
@@ -20,8 +20,8 @@ const AtSign = ({
20
20
  <StyledSVG
21
21
  width={size}
22
22
  height={size}
23
- colour={colour}
24
- mobileColour={mobileColour}
23
+ $colour={colour}
24
+ $mobileColour={mobileColour}
25
25
  viewBox="0 0 48 48"
26
26
  {...rest}
27
27
  >
@@ -1,25 +1,31 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled, { withTheme } from 'styled-components';
3
+ import styled, { css, withTheme } from 'styled-components';
4
4
 
5
5
  const StyledSVG = styled.svg`
6
+ display: block;
7
+ ${({ $fluid }) => $fluid && css`
8
+ width: 100%;
9
+ height: auto;
10
+ `}
6
11
  fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
7
12
 
8
13
  @media ${({ theme }) => theme.allBreakpoints('L')} {
9
- fill: ${({ colour, theme }) => (colour ? theme.color(colour) : theme.color('white'))};
14
+ fill: ${({ $colour, theme }) => ($colour ? theme.color($colour) : theme.color('white'))};
10
15
  }
11
16
  `;
12
17
 
13
18
  const GiftAidLogo = ({
14
- colour = 'black', mobileColour = null, theme, size = 24, ...rest
19
+ colour = 'black', mobileColour = null, size = null, theme, ...rest
15
20
  }) => (
16
21
  <StyledSVG
17
22
  {...rest}
18
- width={size}
19
- height={(size * 124) / 350}
23
+ width={size || undefined}
24
+ height={size ? (size * 124) / 350 : undefined}
25
+ $fluid={!size}
20
26
  fill={theme.color(colour)}
21
- colour={colour}
22
- mobileColour={mobileColour}
27
+ $colour={colour}
28
+ $mobileColour={mobileColour}
23
29
  xmlns="http://www.w3.org/2000/svg"
24
30
  viewBox="0 0 350 124"
25
31
  >
@@ -4,6 +4,7 @@ import {
4
4
  Arrow, AtSign, Chevron, CtaArrow, Download, External, Favourite, GiftAidLogo, Internal, Post, Filter, Undo
5
5
  } from './index';
6
6
  import Cross from './Cross';
7
+ import CrossRoundedCorners from './CrossRoundedCorners';
7
8
  import Padlock from './Padlock';
8
9
  import Curve from './Curve';
9
10
  import { ExampleContainer } from '../../../demos/SharedStyles';
@@ -51,10 +52,11 @@ export default function IconsExample() {
51
52
  ['Internal', <Internal size={48} colour="black" />],
52
53
  ['AtSign', <AtSign size={48} colour="black" />],
53
54
  ['Cross', <Cross size={48} colour="black" />],
55
+ ['CrossRoundedCorners', <CrossRoundedCorners size={48} colour="black" />],
54
56
  ['Padlock', <Padlock size={48} colour="black" />],
55
57
  ['Post', <Post size={48} colour="black" />],
56
58
  ['Filter', <Filter size={48} colour="black" />],
57
- ['GiftAidLogo', <GiftAidLogo size={96} colour="black" />],
59
+ ['GiftAidLogo', <GiftAidLogo size={130} colour="black" />],
58
60
  ['Undo', <Undo size={48} colour="black" />]
59
61
  ].map(([name, icon]) => (
60
62
  <IconCard key={name}>
@@ -4,11 +4,11 @@ import styled, { withTheme } from 'styled-components';
4
4
 
5
5
  const StyledSVG = styled.svg`
6
6
  // Mobile-colour if available, else use standard prop
7
- fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
7
+ fill: ${({ $mobileColour, $colour, theme }) => ($mobileColour ? theme.color($mobileColour) : theme.color($colour))};
8
8
 
9
9
  // Reinstate standard styles for 'desktop', adding a fallback for good measure:
10
10
  @media ${({ theme }) => theme.allBreakpoints('L')} {
11
- fill: ${({ colour, theme }) => (colour ? theme.color(colour) : theme.color('white'))};
11
+ fill: ${({ $colour, theme }) => ($colour ? theme.color($colour) : theme.color('white'))};
12
12
  }
13
13
  `;
14
14
 
@@ -20,8 +20,8 @@ const Internal = ({
20
20
  width={size}
21
21
  height={size}
22
22
  fill={theme.color(colour)}
23
- colour={colour}
24
- mobileColour={mobileColour}
23
+ $colour={colour}
24
+ $mobileColour={mobileColour}
25
25
  xmlns="http://www.w3.org/2000/svg"
26
26
  viewBox="0 0 15 15"
27
27
  >
@@ -3,10 +3,10 @@ import PropTypes from 'prop-types';
3
3
  import styled, { withTheme } from 'styled-components';
4
4
 
5
5
  const StyledSVG = styled.svg`
6
- fill: ${({ mobileColour, colour, theme }) => (mobileColour ? theme.color(mobileColour) : theme.color(colour))};
6
+ fill: ${({ $mobileColour, $colour, theme }) => ($mobileColour ? theme.color($mobileColour) : theme.color($colour))};
7
7
 
8
8
  @media ${({ theme }) => theme.allBreakpoints('L')} {
9
- fill: ${({ colour, theme }) => (colour ? theme.color(colour) : theme.color('white'))};
9
+ fill: ${({ $colour, theme }) => ($colour ? theme.color($colour) : theme.color('white'))};
10
10
  }
11
11
  `;
12
12
 
@@ -18,8 +18,8 @@ const Post = ({
18
18
  width={size}
19
19
  height={size}
20
20
  fill={theme.color(colour)}
21
- colour={colour}
22
- mobileColour={mobileColour}
21
+ $colour={colour}
22
+ $mobileColour={mobileColour}
23
23
  xmlns="http://www.w3.org/2000/svg"
24
24
  viewBox="0 0 24 24"
25
25
  >
@@ -112,10 +112,8 @@ it('renders a button with an icon', () => {
112
112
  >
113
113
  <svg
114
114
  className="c2"
115
- colour="white"
116
115
  fill="#FFFFFF"
117
116
  height={20}
118
- mobileColour={null}
119
117
  viewBox="0 0 15 15"
120
118
  width={20}
121
119
  xmlns="http://www.w3.org/2000/svg"
@@ -12,10 +12,11 @@ export default function AccordionExample() {
12
12
  <>
13
13
  <Wrapper>
14
14
  <Accordion
15
- title={
15
+ title={(
16
16
  <Text family="Anton" size="l" uppercase>
17
17
  I am the title
18
- </Text>}
18
+ </Text>
19
+ )}
19
20
  >
20
21
  <Text tag="p" size="s">
21
22
  Name, surname, email and billing address We need these to process your payment,
@@ -32,7 +33,8 @@ export default function AccordionExample() {
32
33
  >
33
34
  <Text tag="p" size="s">Customised bottom padding here!</Text>
34
35
  <Text tag="p" size="s">
35
- <a href="https://www.google.com">A plain anchor link, made to resemble a Link component</a>.
36
+ <a href="https://www.google.com">A plain anchor link, made to resemble a Link component</a>
37
+ .
36
38
  </Text>
37
39
  </Accordion>
38
40
  </Wrapper>
@@ -40,11 +42,11 @@ export default function AccordionExample() {
40
42
  <Wrapper>
41
43
  <Accordion
42
44
  contentBottomPadding="100px"
43
- title={
44
- <Text textTag="p" weight="700">
45
+ title={(
46
+ <Text tag="p" weight="700">
45
47
  I am a title with an overridden text type and weight, to 'p' 700 which is the new donate preference
46
48
  </Text>
47
- }
49
+ )}
48
50
  >
49
51
  <Text tag="p" size="s">lorem ipsum</Text>
50
52
  </Accordion>
@@ -53,11 +55,11 @@ export default function AccordionExample() {
53
55
  <Wrapper>
54
56
  <div style={{ width: '752px' }}>
55
57
  <Accordion
56
- title={
57
- <Text textTag="p" weight="700">
58
+ title={(
59
+ <Text tag="p" weight="700">
58
60
  I am in a width simulating our real world use on desktop (NB because width is fixed, this is only to demonstrate desktop mode, don't use for examining mobile view)
59
61
  </Text>
60
- }
62
+ )}
61
63
  >
62
64
  <Text tag="p" size="s">
63
65
  A STAR template answer is a structured way of responding to behavioural interview questions. Here's what it stands for:
@@ -45,7 +45,7 @@ const ArticleTeaser = ({
45
45
 
46
46
  return (
47
47
  <OuterWrapper>
48
- <Link href={href} type="standard" category={category} $isNewsTeaser={isNewsTeaser} underline={false}>
48
+ <Link href={href} type="standard" $isNewsTeaser={isNewsTeaser} underline={false}>
49
49
  <InnerWrapper $isNewsTeaser={isNewsTeaser}>
50
50
  <ImageWrapper $isNewsTeaser={isNewsTeaser}>
51
51
  <Image
@@ -374,7 +374,6 @@ it('renders article teaser correctly', () => {
374
374
  className="c0"
375
375
  >
376
376
  <a
377
- category={null}
378
377
  className="c1 c2"
379
378
  href="/test"
380
379
  target="_self"
@@ -802,7 +801,6 @@ it('renders press realese correctly', () => {
802
801
  className="c0"
803
802
  >
804
803
  <a
805
- category=""
806
804
  className="c1 c2"
807
805
  href="/test"
808
806
  target="_self"
@@ -6,7 +6,7 @@ import spacing from '../../../theme/shared/spacing';
6
6
  import { breakpointValues } from '../../../theme/shared/allBreakpoints';
7
7
 
8
8
  const Wrapper = styled.div`
9
- background: ${({ theme, backgroundColor }) => theme.color(backgroundColor)};
9
+ background: ${({ theme, $backgroundColor }) => theme.color($backgroundColor)};
10
10
  `;
11
11
 
12
12
  const Container = styled.div`
@@ -25,7 +25,7 @@ const Container = styled.div`
25
25
  `;
26
26
 
27
27
  const Banner = ({ children, backgroundColor = 'grey_dark' }) => (
28
- <Wrapper backgroundColor={backgroundColor}>
28
+ <Wrapper $backgroundColor={backgroundColor}>
29
29
  <Container>
30
30
  { children }
31
31
  </Container>
@@ -59,7 +59,6 @@ exports[`renders correctly 1`] = `
59
59
  }
60
60
 
61
61
  <div
62
- backgroundColor="purple_dark"
63
62
  className="c0"
64
63
  >
65
64
  <div
@@ -63,7 +63,7 @@ const Box = ({
63
63
  image={image}
64
64
  width={width}
65
65
  height="auto"
66
- squaredCorners={squaredCorners}
66
+ $squaredCorners={squaredCorners}
67
67
  />
68
68
  </Image>
69
69
  ) : null}
@@ -74,7 +74,6 @@ exports[`renders correctly 1`] = `
74
74
  <div
75
75
  className="c2 lazyload"
76
76
  data-testid="PictureWrapper"
77
- squaredCorners={false}
78
77
  >
79
78
  <img
80
79
  alt=""
@@ -253,10 +253,8 @@ exports[`renders Column view correctly 1`] = `
253
253
  >
254
254
  <svg
255
255
  className="c10"
256
- colour="white"
257
256
  fill="#FFFFFF"
258
257
  height={20}
259
- mobileColour={null}
260
258
  viewBox="0 0 15 15"
261
259
  width={20}
262
260
  xmlns="http://www.w3.org/2000/svg"
@@ -555,10 +553,8 @@ exports[`renders correctly 1`] = `
555
553
  >
556
554
  <svg
557
555
  className="c10"
558
- colour="white"
559
556
  fill="#FFFFFF"
560
557
  height={20}
561
- mobileColour={null}
562
558
  viewBox="0 0 15 15"
563
559
  width={20}
564
560
  xmlns="http://www.w3.org/2000/svg"
@@ -19,7 +19,7 @@ const LogoLinked = ({
19
19
  href={url}
20
20
  title="Go to Sport Relief homepage"
21
21
  target={newTab ? '_blank' : '_self'}
22
- animateRotate={animateRotate}
22
+ $animateRotate={animateRotate}
23
23
  >
24
24
  <Logo
25
25
  rotate={false}
@@ -40,7 +40,7 @@ const LogoLinked = ({
40
40
  href={url}
41
41
  title="Go to Comic Relief homepage"
42
42
  target={newTab ? '_blank' : '_self'}
43
- animateRotate={animateRotate}
43
+ $animateRotate={animateRotate}
44
44
  >
45
45
  <Logo
46
46
  rotate={false}
@@ -63,7 +63,7 @@ const LogoLinked = ({
63
63
  href={url}
64
64
  title="Go to Comic Relief homepage"
65
65
  target={newTab ? '_blank' : '_self'}
66
- animatePulse={animatePulse}
66
+ $animatePulse={animatePulse}
67
67
  >
68
68
  <Logo
69
69
  rotate={false}
@@ -83,7 +83,7 @@ const LogoLinked = ({
83
83
  href={url}
84
84
  title={title}
85
85
  target={newTab ? '_blank' : '_self'}
86
- animateRotate={animateRotate}
86
+ $animateRotate={animateRotate}
87
87
  >
88
88
  <Logo
89
89
  rotate={false}
@@ -8,9 +8,9 @@ const TitleLabel = styled.span`
8
8
  `;
9
9
 
10
10
  const LogoLink = styled.a`
11
- ${({ animateRotate }) => logoRotateAnimation(animateRotate)}
11
+ ${({ $animateRotate }) => logoRotateAnimation($animateRotate)}
12
12
 
13
- ${({ animatePulse }) => animatePulse && css`
13
+ ${({ $animatePulse }) => $animatePulse && css`
14
14
  img {
15
15
  ${pulseOutAnimation};
16
16
  }
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import TextInputWithDropdown from '../../Atoms/TextInputWithDropdown/TextInputWithDropdown';
4
- import spacing from '../../../theme/shared/spacing';
5
4
  import ButtonWithStates from '../../Atoms/ButtonWithStates/ButtonWithStates';
6
5
 
7
6
  const KEY_CODE_ENTER = 13;
@@ -70,7 +69,6 @@ const Lookup = ({
70
69
  return (
71
70
  <div {...rest}>
72
71
  <TextInputWithDropdown
73
- css={{ marginBottom: spacing('md') }}
74
72
  name={name}
75
73
  id={name}
76
74
  value={query}
@@ -5,7 +5,7 @@ import styled, { css } from 'styled-components';
5
5
  import Cross from '../../../Atoms/Icons/CrossRoundedCorners';
6
6
  import GiftAidLogo from '../../../Atoms/Icons/GiftAidLogo';
7
7
  import {
8
- Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText
8
+ Container, Trigger, CloseButton, PopUpWindow, PopUpHeading, PopUpBodyText, PageOverlay
9
9
  } from '../PopUpShared.style';
10
10
  import { usePopUpOpen } from '../PopUpShared.utils';
11
11
 
@@ -17,7 +17,29 @@ const DEFAULT_PARAGRAPHS = [
17
17
  'In short, £1 + Gift Aid = £1.25, at no extra cost to you.'
18
18
  ];
19
19
 
20
+ /**
21
+ * Not positioned itself, so the open popup is absolutely positioned against
22
+ * the parent container and centred within it
23
+ */
24
+ const GiftAidContainer = styled(Container)`
25
+ position: static;
26
+ `;
27
+
28
+ /**
29
+ * The open popup is positioned over the parent container, so its width is set
30
+ * independently of the trigger's width (via openWindowWidth) and centred within it
31
+ */
32
+ const OpenPopUpWindow = styled(PopUpWindow)`
33
+ width: ${({ $openWindowWidth }) => $openWindowWidth};
34
+ left: 50%;
35
+ right: auto;
36
+ margin-left: ${({ $openWindowWidth }) => `calc(${$openWindowWidth} / -2)`};
37
+ `;
38
+
20
39
  const LogoWrapper = styled.button`
40
+ display: block;
41
+ width: 100%;
42
+ padding: 0;
21
43
  border: none;
22
44
  background: none;
23
45
  cursor: pointer;
@@ -32,6 +54,8 @@ const LogoWrapper = styled.button`
32
54
  const PopUpGiftAid = ({
33
55
  textColour = 'black',
34
56
  hoverColour = 'red',
57
+ backgroundColour = 'transparent',
58
+ openWindowWidth = '20rem',
35
59
  heading = DEFAULT_HEADING,
36
60
  paragraphs = DEFAULT_PARAGRAPHS,
37
61
  onOpenChange,
@@ -42,15 +66,17 @@ const PopUpGiftAid = ({
42
66
  } = usePopUpOpen(onOpenChange);
43
67
 
44
68
  return (
45
- <Container
69
+ <GiftAidContainer
46
70
  ref={containerRef}
47
71
  data-testid="pop-up-gift-aid"
48
72
  data-open={isOpen ? 'true' : 'false'}
49
73
  {...rest}
50
74
  >
75
+ {isRendered && <PageOverlay aria-hidden="true" />}
76
+
51
77
  <Trigger $hidden={isRendered}>
52
78
  <PopUpWindow
53
- $backgroundColour="white"
79
+ $backgroundColour={backgroundColour}
54
80
  $textColour={textColour}
55
81
  >
56
82
  <LogoWrapper
@@ -60,17 +86,18 @@ const PopUpGiftAid = ({
60
86
  aria-label="What is Gift Aid?"
61
87
  $hoverColour={hoverColour}
62
88
  >
63
- <GiftAidLogo size={140} colour={textColour} />
89
+ <GiftAidLogo colour={textColour} />
64
90
  </LogoWrapper>
65
91
  </PopUpWindow>
66
92
  </Trigger>
67
93
 
68
94
  {isRendered && (
69
- <PopUpWindow
95
+ <OpenPopUpWindow
70
96
  $backgroundColour="white"
71
97
  $textColour={textColour}
72
98
  $isOpen={isRendered}
73
99
  $isClosing={isClosing}
100
+ $openWindowWidth={openWindowWidth}
74
101
  >
75
102
  <CloseButton
76
103
  type="button"
@@ -86,15 +113,17 @@ const PopUpGiftAid = ({
86
113
  {paragraphs.map(paragraph => (
87
114
  <PopUpBodyText key={paragraph}>{paragraph}</PopUpBodyText>
88
115
  ))}
89
- </PopUpWindow>
116
+ </OpenPopUpWindow>
90
117
  )}
91
- </Container>
118
+ </GiftAidContainer>
92
119
  );
93
120
  };
94
121
 
95
122
  PopUpGiftAid.propTypes = {
96
123
  textColour: PropTypes.string,
97
124
  hoverColour: PropTypes.string,
125
+ backgroundColour: PropTypes.string,
126
+ openWindowWidth: PropTypes.string,
98
127
  heading: PropTypes.string,
99
128
  paragraphs: PropTypes.arrayOf(PropTypes.string),
100
129
  onOpenChange: PropTypes.func
@@ -1,46 +1,47 @@
1
1
  import React, { useState } from 'react';
2
- import PopUpGiftAid from './PopUpGiftAid';
3
2
  import styled from 'styled-components';
3
+ import PopUpGiftAid from './PopUpGiftAid';
4
+ import { ExampleContainer } from '../PopUpShared.style';
4
5
 
5
- /**
6
- * Parent styling from the JS state (onOpenChange) uses data-open attribute
7
- * on the popup's container to fire CSS styles via :has()
8
- */
9
- const Wrapper = styled.div`
10
- position: relative;
11
- background: ${({ $isOpen }) => ($isOpen ? 'orange' : 'green')};
12
- padding: 1rem;
13
-
14
- &:has([data-open="true"]) {
15
- outline: 2px solid black;
16
- }
17
-
18
- /* Shade over the wrapper's content while the popup is open */
19
- &::before {
20
- content: '';
21
- position: absolute;
22
- top: 0;
23
- right: 0;
24
- bottom: 0;
25
- left: 0;
26
- background-color: rgba(0, 0, 0, 0.4);
27
- pointer-events: none;
28
- display: ${({ $isOpen }) => ($isOpen ? 'block' : 'none')};
29
- }
6
+ const GiftExampleContainer = styled(ExampleContainer)`
7
+ display: flex;
8
+ justify-content: space-between;
30
9
  `;
31
10
 
32
- const Status = styled.p`
33
- margin: 0 0 0.5rem;
34
- color: white;
11
+ const PopUpExampleWrapper = styled.div`
12
+ width: 150px;
13
+ height: auto;
35
14
  `;
36
15
 
37
16
  export default function PopUpGiftAidExample() {
38
17
  const [isOpen, setIsOpen] = useState(false);
39
18
 
40
19
  return (
41
- <Wrapper $isOpen={isOpen}>
42
- <Status>{isOpen ? 'Popup is open' : 'Popup is closed'}</Status>
43
- <PopUpGiftAid onOpenChange={setIsOpen} />
44
- </Wrapper>
20
+ <>
21
+ <GiftExampleContainer $isOpen={isOpen}>
22
+ <h3>Default / no props, isOpen trigger</h3>
23
+ <PopUpExampleWrapper> <PopUpGiftAid onOpenChange={setIsOpen}/> </PopUpExampleWrapper>
24
+ </GiftExampleContainer>
25
+
26
+ <GiftExampleContainer>
27
+ <h3>Props - textColour, backgroundColour, hoverColour, openWindowWidth</h3>
28
+ <PopUpExampleWrapper>
29
+ <PopUpGiftAid textColour="green" backgroundColour="blue_light" hoverColour='coral_light' openWindowWidth='550px'/>
30
+ </PopUpExampleWrapper>
31
+ </GiftExampleContainer>
32
+
33
+ <GiftExampleContainer>
34
+ <h3>Custom heading and paragraphs</h3>
35
+ <PopUpExampleWrapper>
36
+ <PopUpGiftAid
37
+ heading="Why does Gift Aid matter?"
38
+ paragraphs={[
39
+ 'Gift Aid lets charities reclaim the tax you have already paid on your donation.',
40
+ 'Every £1 you give can be worth £1.25 to the charity at no extra cost to you.'
41
+ ]}
42
+ />
43
+ </PopUpExampleWrapper>
44
+ </GiftExampleContainer>
45
+ </>
45
46
  );
46
47
  }