@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.
- package/dist/index.cjs.js +879 -829
- package/dist/index.es.js +4924 -4862
- package/package.json +1 -1
- package/src/components/Atoms/Icons/ArrowExample.jsx +8 -5
- package/src/components/Atoms/Icons/AtSign.js +4 -4
- package/src/components/Atoms/Icons/GiftAidLogo.js +13 -7
- package/src/components/Atoms/Icons/IconsExample.jsx +3 -1
- package/src/components/Atoms/Icons/Internal.js +4 -4
- package/src/components/Atoms/Icons/Post.js +4 -4
- package/src/components/Atoms/Link/Link.test.js +0 -2
- package/src/components/Molecules/Accordion/AccordionExample.jsx +11 -9
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +1 -1
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
- package/src/components/Molecules/Banner/Banner.js +2 -2
- package/src/components/Molecules/Banner/__snapshots__/Banner.test.js.snap +0 -1
- package/src/components/Molecules/Box/Box.js +1 -1
- package/src/components/Molecules/Box/__snapshots__/Box.test.js.snap +0 -1
- package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +0 -4
- package/src/components/Molecules/LogoLinked/LogoLinked.js +4 -4
- package/src/components/Molecules/LogoLinked/LogoLinked.style.js +2 -2
- package/src/components/Molecules/Lookup/Lookup.js +0 -2
- package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAid.js +36 -7
- package/src/components/Molecules/PopUp/PopUpGiftAid/PopUpGiftAidExample.jsx +34 -33
- package/src/components/Molecules/PopUp/PopUpGiftAid/__snapshots__/PopUpGiftAid.test.js.snap +48 -36
- package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePayment.js +19 -3
- package/src/components/Molecules/PopUp/PopUpSecurePayment/PopUpSecurePaymentExample.jsx +23 -37
- package/src/components/Molecules/PopUp/PopUpShared.style.js +47 -1
- package/src/components/Molecules/SearchResult/SearchResult.js +4 -4
- package/src/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
- package/src/components/Organisms/Donate/Donate.js +1 -1
- package/src/components/Organisms/Donate/Form/Form.js +2 -2
- package/src/components/Organisms/Donate/MoneyBuy/MoneyBuy.js +1 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -7
- package/src/components/Organisms/DonateBanner/Form/Form.js +2 -2
- package/src/components/Organisms/DonateBanner/MoneyBuy/MoneyBuy.js +1 -1
- package/src/components/Organisms/DonateBanner/__snapshots__/DonateBanner.test.js.snap +0 -7
- package/src/components/Organisms/DynamicGallery/_DynamicGalleryColumn.js +1 -1
- package/src/components/Organisms/DynamicGallery/__snapshots__/DynamicGallery.test.js.snap +0 -3
- package/src/components/Organisms/Footer/Footer.js +2 -2
- package/src/components/Organisms/Footer/FooterExample.jsx +3 -3
- package/src/components/Organisms/Footer/Nav/Nav.js +3 -3
- package/src/components/Organisms/Footer/__snapshots__/Footer.test.js.snap +0 -49
- package/src/components/Organisms/Header/Burger/BurgerMenu.js +1 -1
- package/src/components/Organisms/Header/Header.js +1 -1
- package/src/components/Organisms/Header/HeaderNav/HeaderNav.js +3 -3
- package/src/components/Organisms/Header/Nav/Nav.js +2 -2
- package/src/components/Organisms/Header2025/Burger/BurgerMenu.js +1 -1
- package/src/components/Organisms/Header2025/Header2025.js +2 -2
- package/src/components/Organisms/Header2025/Header2025Example.jsx +2 -2
- package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.js +2 -2
- package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNavItem2025.js +4 -4
- package/src/components/Organisms/Header2025/HeaderNav2025/MoreNav.js +2 -2
- package/src/components/Organisms/MarketingPreferencesDS/_OptInCheckbox.js +1 -1
- package/src/components/Organisms/Membership/Form/Form.js +3 -3
- package/src/components/Organisms/Membership/Membership.test.js +0 -9
- package/src/components/Organisms/Membership/MoneyBox/MoneyBox.js +1 -1
package/package.json
CHANGED
|
@@ -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>
|
|
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,
|
|
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={
|
|
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
|
>
|
|
@@ -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
|
|
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
|
|
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"
|
|
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>
|
|
@@ -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
|
-
<
|
|
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=
|
|
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
|
|
89
|
+
<GiftAidLogo colour={textColour} />
|
|
64
90
|
</LogoWrapper>
|
|
65
91
|
</PopUpWindow>
|
|
66
92
|
</Trigger>
|
|
67
93
|
|
|
68
94
|
{isRendered && (
|
|
69
|
-
<
|
|
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
|
-
</
|
|
116
|
+
</OpenPopUpWindow>
|
|
90
117
|
)}
|
|
91
|
-
</
|
|
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
|
-
|
|
7
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
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
|
}
|