File tree 9 files changed +229
-85
lines changed
9 files changed +229
-85
lines changed Original file line number Diff line number Diff line change 13
13
"react" : " ^17.0.1" ,
14
14
"react-dom" : " ^17.0.1" ,
15
15
"react-scripts" : " 4.0.3" ,
16
+ "styled-components" : " ^5.2.1" ,
16
17
"typescript" : " ^4.1.2" ,
17
18
"web-vitals" : " ^1.0.1"
18
19
},
39
40
" last 1 firefox version" ,
40
41
" last 1 safari version"
41
42
]
43
+ },
44
+ "devDependencies" : {
45
+ "@types/styled-components" : " ^5.1.7"
42
46
}
43
47
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import React from 'react' ;
2
- import logo from './logo.svg' ;
3
- import './App.css' ;
1
+ import Button from "./components/Button" ;
4
2
5
3
function App ( ) {
6
- return (
7
- < div className = "App" >
8
- < header className = "App-header" >
9
- < img src = { logo } className = "App-logo" alt = "logo" />
10
- < p >
11
- Edit < code > src/App.tsx</ code > and save to reload.
12
- </ p >
13
- < a
14
- className = "App-link"
15
- href = "https://reactjs.org"
16
- target = "_blank"
17
- rel = "noopener noreferrer"
4
+ return (
5
+ < div
6
+ style = { {
7
+ background : 'rgb(126 126 126)' ,
8
+ height : '100vh' ,
9
+ padding : '20px' ,
10
+ } }
18
11
>
19
- Learn React
20
- </ a >
21
- </ header >
22
- </ div >
23
- ) ;
12
+ < Button
13
+ // background="#fff"
14
+ // color="#000"
15
+ // borderColor="#000"
16
+ // outline
17
+ round
18
+ raise
19
+ >
20
+ Click me please
21
+ </ Button >
22
+ </ div >
23
+ ) ;
24
24
}
25
25
26
26
export default App ;
Original file line number Diff line number Diff line change
1
+ import styled , { CSSObject , CSSProperties } from 'styled-components' ;
2
+
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
+ }
13
+
14
+ function Button ( {
15
+ children,
16
+ background,
17
+ color,
18
+ borderColor,
19
+ uppercase,
20
+ round,
21
+ outline,
22
+ raise,
23
+ ...props
24
+ } : Props ) {
25
+
26
+ const StyledButton = styled . button `
27
+ background: ${ outline ? 'transparent' : background || 'blue' } ;
28
+ border: ${ borderColor || outline ? '1px solid ' + borderColor || background : 'none' } ;
29
+ color: ${ outline ? color || background : color || '#fff' } ;
30
+ font-size: 14px;
31
+ border-radius: ${ round ? '20px' : '5px' } ;
32
+ font-weight: 600;
33
+
34
+ line-height: 15px;
35
+ padding: 10px;
36
+
37
+ letter-spacing: 0.3px;
38
+ text-transform: ${ uppercase ? 'uppercase' : '' } ;
39
+ cursor: pointer;
40
+
41
+ &:focus{
42
+ outline: none;
43
+ }
44
+ &:active, {
45
+ outline: none;
46
+ box-shadow: 0 3px 0 rgb(9 30 66 / 10%);
47
+ top: 3px;
48
+ }
49
+ &:hover{
50
+ box-shadow: 0 3px 5px rgb(9 30 66 / 10%), 0 0 1px rgb(9 30 66 / 31%);
51
+ transform: ${ raise ? 'translate3d(0px, -2px, 0px)' : 'none' } ;
52
+ }
53
+ `
54
+
55
+ return (
56
+ < StyledButton
57
+ { ...props }
58
+ >
59
+ { children }
60
+ </ StyledButton >
61
+ )
62
+ }
63
+ export default Button ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import ReactDOM from 'react-dom' ;
3
- import './index.css' ;
4
3
import App from './App' ;
5
4
import reportWebVitals from './reportWebVitals' ;
6
5
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments