-
Notifications
You must be signed in to change notification settings - Fork 11
/
ContributorButton.tsx
77 lines (68 loc) · 1.78 KB
/
ContributorButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React, { useState } from 'react';
import styled from 'styled-components';
import BackgroundButton from 'components/atoms/Button/BackgroundButton/BackgroundButton';
import BorderButton from 'components/atoms/Button/BorderButton/BorderButton';
import Check from 'components/atoms/icons/CheckSmall';
const Container = styled.div`
display: flex;
& > * {
max-width: 150px;
margin-top: 6px;
text-transform: none;
}
`;
const ContributorBackgroundButton = styled(BackgroundButton)`
min-width: 150px;
&:hover {
color: #fff;
background-color: #062e65;
border-color: #062e65;
}
`;
const ContributorBorderButton = styled(BorderButton)`
&,
&:hover {
color: ${props => props.theme.primaryColor};
background-color: #fff;
border-color: ${props => props.theme.primaryColor};
min-width: 150px;
}
`;
interface Props {
subscribed?: boolean;
onSubscribe: () => void;
onUnsubscribe: () => void;
}
const ContributorButton = ({
subscribed,
onSubscribe,
onUnsubscribe
}: Props) => {
const [subscribedButtonHovered, setSubscribedButtonHovered] = useState(false);
return (
<Container>
{subscribed && (
<ContributorBorderButton
onClick={onUnsubscribe}
onPointerEnter={() => setSubscribedButtonHovered(true)}
onPointerLeave={() => setSubscribedButtonHovered(false)}
>
{subscribedButtonHovered ? (
'Se désabonner'
) : (
<>
<Check />
Abonné
</>
)}
</ContributorBorderButton>
)}
{!subscribed && (
<ContributorBackgroundButton onClick={onSubscribe}>
S'abonner
</ContributorBackgroundButton>
)}
</Container>
);
};
export default ContributorButton;