-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (26 loc) · 749 Bytes
/
index.js
File metadata and controls
32 lines (26 loc) · 749 Bytes
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
import React from 'react';
import { any, func, string } from 'prop-types';
import classNames from 'classnames';
import { Link } from 'gatsby';
const Button = React.memo(({ children, className, to, onClick }) => {
const css = classNames('inline-block bg-primary text-white px-6 py-3 rounded hover:bg-primary-dark', className);
if (to) {
if (to.startsWith('http')) {
return (
<a aria-label={children} href={to} className={css}>{children}</a>
);
}
return (
<Link to={to} className={css}>{children}</Link>
);
}
return (
<button onClick={onClick} className={css}>{children}</button>
);
});
Button.propTypes = {
children: any,
className: string,
onClick: func,
};
export default Button;