forked from wizeline/react-certification-2020
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathButton.component.jsx
More file actions
52 lines (49 loc) · 1.24 KB
/
Button.component.jsx
File metadata and controls
52 lines (49 loc) · 1.24 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
import React from 'react';
import { Link } from 'react-router-dom';
import { ButtonContainer } from './Button.styled';
const Button = (props) => {
if (props.href) {
return (
<ButtonContainer>
<a
className={`button button--${props.size || 'default'} ${
props.inverse && 'button--inverse'
} ${props.danger && 'button--danger'}`}
href={props.href}
>
{props.children}
</a>
</ButtonContainer>
);
}
if (props.to) {
return (
<ButtonContainer>
<Link
to={props.to}
exact={props.exact}
className={`button button--${props.size || 'default'} ${
props.inverse && 'button--inverse'
} ${props.danger && 'button--danger'}`}
>
{props.children}
</Link>
</ButtonContainer>
);
}
return (
<ButtonContainer>
<button
className={`button button--${props.size || 'default'} ${
props.inverse && 'button--inverse'
} ${props.danger && 'button--danger'}`}
type="button"
onClick={props.onClick}
disabled={props.disabled}
>
{props.children}
</button>
</ButtonContainer>
);
};
export default Button;