@comicrelief/component-library 6.4.1 → 6.6.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.
@@ -68,7 +68,7 @@ const Donate = ({
68
68
  />
69
69
  ) : null}
70
70
 
71
- <Wrapper formAlignRight={formAlignRight}>
71
+ <Wrapper formAlignRight={formAlignRight} aria-live="polite">
72
72
  <Header formAlignRight={formAlignRight}>
73
73
  <HeaderInner>
74
74
  {subtitle && (
@@ -116,18 +116,19 @@ const Signup = ({
116
116
  const givingData = givingType === 'single' ? singleGiving : regularGiving;
117
117
  const showGivingSelector = singleGiving !== null && regularGiving !== null;
118
118
 
119
+ const [popOpen, setPopOpen] = useState(false);
120
+
119
121
  return (
120
122
  <FormWrapper>
121
123
  {showGivingSelector && (
122
124
  <GivingSelector
123
125
  givingType={givingType}
124
126
  changeGivingType={data => setGivingType(data)}
127
+ setPopOpen={setPopOpen}
125
128
  />
126
129
  )}
127
130
 
128
- {(givingType === 'single' && showGivingSelector)
129
- && <PopUpComponent PopUpText={PopUpText} />
130
- }
131
+ { popOpen && <PopUpComponent PopUpText={PopUpText} /> }
131
132
 
132
133
  <Form
133
134
  onSubmit={e => submitDonation(
@@ -1,17 +1,49 @@
1
1
  /* eslint-disable */
2
2
  import React, { useState } from 'react';
3
- import styled from 'styled-components';
3
+ import styled, { css, keyframes } from 'styled-components';
4
4
  import Text from '../../../Atoms/Text/Text';
5
- import spacing from '../../../../theme/shared/spacing';
6
5
  import { media } from '../../../../theme/shared/size';
7
6
  import PropTypes from 'prop-types';
8
7
  import CloseCross from '../assets/close.svg';
9
8
 
9
+ const fadeClose = keyframes`
10
+ 0% {
11
+ opacity: 1;
12
+ max-height: 350px;
13
+ }
14
+ 100% {
15
+ opacity: 0;
16
+ max-height: 0px;
17
+ display: none;
18
+ margin-top: -16px;
19
+ }
20
+ `;
21
+
22
+ const fadeOpen = keyframes`
23
+ 0% {
24
+ opacity: 0;
25
+ max-height: 0px;
26
+ display: none;
27
+ margin-top: -16px;
28
+ }
29
+ 100% {
30
+ opacity: 1;
31
+ max-height: 350px;
32
+ }
33
+ `;
34
+
10
35
  const StyledPopUp = styled.div`
11
- display: ${props => props.isPop ? "grid" : "none"};
12
- background-color: ${({ theme }) => theme.color('white')};
36
+ display: grid;
37
+ overflow: hidden;
38
+ max-height: 350px;
39
+ opacity: 1;
40
+ animation: 0.4s ${fadeOpen} ease;
41
+ ${props => props.isClosed && css`
42
+ animation: 0.6s ${fadeClose} ease forwards;
43
+ `}
44
+ background-color: ${({ theme }) => theme.color('blue_light')};
13
45
  box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.15);
14
- border-radius: 8px;
46
+ border-radius: 10px;
15
47
 
16
48
  ${media('small')} {
17
49
  width: 450px;
@@ -26,20 +58,18 @@ const TextWrapper = styled.div`
26
58
 
27
59
  const Button = styled.button`
28
60
  justify-self: end;
29
- background: transparent;
61
+ background-color: transparent;
30
62
  border: 0;
31
63
  cursor: pointer;
32
- border: 1px solid ${({ theme }) => theme.color('white')};
64
+ width: 30px;
65
+ height: 30px;
66
+ margin: 3px;
33
67
  :active,
34
68
  :focus,
35
69
  :hover {
36
70
  outline: none;
37
71
  border: 1px solid ${({ theme }) => theme.color('grey')};
38
72
  }
39
- margin: 8px;
40
- width: 35px;
41
- height: 35px;
42
- padding: 5px;
43
73
 
44
74
  img {
45
75
  width: 15px;
@@ -49,11 +79,11 @@ const Button = styled.button`
49
79
  `;
50
80
 
51
81
  const PopUpComponent = ({ PopUpText }) => {
52
- const [isPop, setIsPop] = useState(true);
82
+ const [isClosed, setIsClosed] = useState(false);
53
83
 
54
84
  return (
55
- <StyledPopUp isPop={isPop}>
56
- <Button onClick={() => setIsPop(false)} aria-label="Close">
85
+ <StyledPopUp isClosed={isClosed}>
86
+ <Button onClick={() => setIsClosed(true)} aria-label="Close">
57
87
  <img src={CloseCross} alt="Close cross icon"/>
58
88
  </Button>
59
89
  <TextWrapper>
@@ -80,7 +80,7 @@ const Label = styled.label`
80
80
  }
81
81
  `;
82
82
 
83
- const GivingSelector = ({ givingType, changeGivingType }) => (
83
+ const GivingSelector = ({ givingType, changeGivingType, setPopOpen }) => (
84
84
  <Wrapper>
85
85
  <MoneyBox>
86
86
  <input
@@ -93,6 +93,7 @@ const GivingSelector = ({ givingType, changeGivingType }) => (
93
93
  checked={givingType === 'single'}
94
94
  onClick={() => {
95
95
  changeGivingType('single');
96
+ setPopOpen(true);
96
97
  }}
97
98
  />
98
99
  <Label active={givingType === 'single'} htmlFor="give-once">
@@ -108,6 +109,7 @@ const GivingSelector = ({ givingType, changeGivingType }) => (
108
109
  checked={givingType === 'monthly'}
109
110
  onClick={() => {
110
111
  changeGivingType('monthly');
112
+ setPopOpen(false);
111
113
  }}
112
114
  />
113
115
  <Label active={givingType === 'monthly'} htmlFor="give-monthly">
@@ -120,7 +122,8 @@ const GivingSelector = ({ givingType, changeGivingType }) => (
120
122
 
121
123
  GivingSelector.propTypes = {
122
124
  givingType: PropTypes.string.isRequired,
123
- changeGivingType: PropTypes.func.isRequired
125
+ changeGivingType: PropTypes.func.isRequired,
126
+ setPopOpen: PropTypes.bool.isRequired
124
127
  };
125
128
 
126
129
  export default GivingSelector;