forked from moshiuzzaman/devsonket.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButton.js
More file actions
72 lines (65 loc) · 1.27 KB
/
Copy pathButton.js
File metadata and controls
72 lines (65 loc) · 1.27 KB
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
import React from "react"
import { Link } from "gatsby"
import PropTypes from "prop-types"
import styled from "@emotion/styled"
const ButtonContainer = styled.span``
const btnStyle = `
text-decoration: none;
display: inline-block;
padding: 12px 15px;
border-radius: 4px;
cursor: pointer;
font-weight: 600;
line-height: 1;
transition: 0.2s all ease;
background: #02b3e4;
color: white;
text-shadow: 0 1px 3px #86888e;
@media print {
display: none;
}
&:hover {
background-color: #02b7e9;
}
`
const ButtonAnchor = styled.a`
${btnStyle}
`
const ButtonLinkAnchor = styled(Link)`
${btnStyle}
`
export const Button = ({
children,
bgColor,
href,
to,
onClick,
target,
rel,
}) => {
return (
<ButtonContainer>
{!to ? (
<ButtonAnchor
target={target ? "_blank" : "self"}
rel={rel ? rel : ""}
onClick={onClick && onClick}
style={{ backgroundColor: bgColor }}
href={href}
>
{children}
</ButtonAnchor>
) : (
<ButtonLinkAnchor to={to}>{children}</ButtonLinkAnchor>
)}
</ButtonContainer>
)
}
Button.defaultProps = {
text: `button`,
bgColor: "#333",
}
Button.propTypes = {
text: PropTypes.string,
bgColor: PropTypes.string,
}