File tree 3 files changed +27
-27
lines changed
3 files changed +27
-27
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,7 @@ function App() {
14
14
>
15
15
Click me please
16
16
</ Button > < br /> < br />
17
- < Button
18
- outline
19
- >
17
+ < Button >
20
18
Hello
21
19
</ Button >
22
20
</ div >
Original file line number Diff line number Diff line change
1
+ import { ButtonHTMLAttributes } from 'react' ;
1
2
import styled from 'styled-components' ;
3
+ import { PRIMARY_COLOR } from '../theme' ;
2
4
3
- type Props = {
4
- children : React . ReactNode ,
5
- background ?: string ,
6
- color ?: string ,
7
- borderColor ?: string ,
8
- uppercase ?: Boolean ,
9
- round ?: Boolean ,
10
- outline ?: Boolean ,
11
- raise ?: Boolean ,
12
- fontWeight ?: string | number
13
- boxShadow ?: Boolean ,
5
+ interface Props extends ButtonHTMLAttributes < HTMLButtonElement > {
6
+ children : React . ReactNode ;
7
+ background ?: string ;
8
+ color ?: string ;
9
+ borderColor ?: string ;
10
+ uppercase ?: Boolean ;
11
+ round ?: Boolean ;
12
+ outline ?: Boolean ;
13
+ raise ?: Boolean ;
14
+ fontWeight ?: string | number ;
15
+ boxShadow ?: Boolean ;
16
+ square ?: Boolean ;
14
17
}
15
18
16
19
function Button ( {
17
20
children,
18
- background = '#ff5a5f' ,
21
+ background = PRIMARY_COLOR ,
19
22
color,
20
23
borderColor,
21
- uppercase,
22
- round,
23
- outline,
24
- raise,
24
+ uppercase = false ,
25
+ round = false ,
26
+ outline = false ,
27
+ raise = false ,
25
28
fontWeight,
26
29
boxShadow = true ,
30
+ square = false ,
27
31
...props
28
32
} : Props ) {
29
33
@@ -32,29 +36,26 @@ function Button({
32
36
border: ${ borderColor || outline ? '1px solid ' + ( borderColor || background ) : 'none' } ;
33
37
color: ${ outline ? color || background : color || '#fff' } ;
34
38
font-size: 14px;
35
- border-radius: ${ round ? '20px' : '5px' } ;
39
+ border-radius: ${ square ? '0px' : round ? '20px' : '5px' } ;
36
40
font-weight: ${ fontWeight || null } ;
37
-
38
41
line-height: 15px;
39
42
padding: 10px;
40
-
41
43
letter-spacing: 0.3px;
42
44
text-transform: ${ uppercase ? 'uppercase' : '' } ;
43
45
cursor: pointer;
44
-
45
46
&:focus{
46
47
outline: none;
47
48
}
48
- &:active, {
49
+ &:active{
49
50
outline: none;
50
- box-shadow: 0 3px 0 rgb(9 30 66 / 10%);
51
+ box-shadow: 0 3px 0 rgb(9 30 66 / 10 %);
51
52
top: 3px;
52
53
}
53
54
&:hover{
54
55
box-shadow: ${ boxShadow ? '0 3px 5px rgb(9 30 66 / 10%), 0 0 1px rgb(9 30 66 / 31%)' : '' } ;
55
56
transform: ${ raise ? 'translate3d(0px, -2px, 0px)' : 'none' } ;
56
- }
57
- `
57
+ }
58
+ `
58
59
59
60
return (
60
61
< StyledButton
Original file line number Diff line number Diff line change
1
+ export const PRIMARY_COLOR :string = '#ff5a5f' ;
You can’t perform that action at this time.
0 commit comments