forked from opencollective/opencollective-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.js
57 lines (48 loc) · 1.33 KB
/
button.js
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
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const CollectButton = styled.div`
background-color: transparent;
background-image: ${({ color, verb }) => `url(/static/images/buttons/${verb}-button-${color}.svg)`};
background-repeat: no-repeat;
cursor: pointer;
display: block;
float: left;
height: 50px;
margin: 0;
overflow: hidden;
padding: 0;
width: ${({ verb }) => (verb === 'contribute' ? '338px' : '300px')};
&:hover {
background-position: 0 -50px;
}
&:active {
background-position: 0 -100px;
}
&:focus {
outline: 0;
}
`;
class ButtonPage extends React.Component {
static getInitialProps({ query: { color, collectiveSlug, verb }, res }) {
// Allow to be embedded as Iframe everywhere
if (res) {
res.removeHeader('X-Frame-Options');
}
return { color, collectiveSlug, verb };
}
static propTypes = {
color: PropTypes.string,
collectiveSlug: PropTypes.string,
verb: PropTypes.string,
};
render() {
const { color = 'white', collectiveSlug, verb = 'donate' } = this.props;
return (
<a target="_blank" rel="noopener noreferrer" href={`https://opencollective.com/${collectiveSlug}/${verb}`}>
<CollectButton color={color} verb={verb} />
</a>
);
}
}
export default ButtonPage;