forked from uselagoon/lagoon
/
index.js
76 lines (70 loc) · 1.87 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React from 'react';
import { bp, color } from 'lib/variables';
const Button = ({ action = null, href = null, disabled, children, variant }) => {
const ButtonElement = href ? 'a' : 'button';
const onClick = action
? action
: e => {
if (disabled) {
e.preventDefault();
return false;
}
};
return (
<>
<ButtonElement
onClick={onClick}
href={href}
disabled={disabled}
className={`${variant ? `btn-${variant}` : 'btn'} ${disabled ? 'btn--disabled' : ''} `}
>
{children}
</ButtonElement>
<style jsx>
{`
.btn {
display: inline-block;
background-color: ${color.lightBlue};
border: none;
border-radius: 3px;
color: ${color.white};
cursor: pointer;
padding: 10px 30px;
@media ${bp.tinyUp} {
align-self: auto;
}
&:hover {
background-color: ${color.blue};
}
&.btn--disabled {
background-color: ${color.lightestGrey};
color: ${color.darkGrey};
cursor: not-allowed;
}
}
.btn-red {
display: inline-block;
background-color: ${color.lightRed};
border: none;
border-radius: 3px;
color: ${color.white};
cursor: pointer;
padding: 10px 30px;
@media ${bp.tinyUp} {
align-self: auto;
}
&:hover {
background-color: ${color.red};
}
&.btn--disabled {
background-color: ${color.lightestGrey};
color: ${color.darkGrey};
cursor: not-allowed;
}
}
`}
</style>
</>
);
};
export default Button;