Skip to content

Commit 1131377

Browse files
author
Prafful Kumar
committed
button
1 parent 8ba208f commit 1131377

File tree

9 files changed

+229
-85
lines changed

9 files changed

+229
-85
lines changed

Diff for: package.json

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"react": "^17.0.1",
1414
"react-dom": "^17.0.1",
1515
"react-scripts": "4.0.3",
16+
"styled-components": "^5.2.1",
1617
"typescript": "^4.1.2",
1718
"web-vitals": "^1.0.1"
1819
},
@@ -39,5 +40,8 @@
3940
"last 1 firefox version",
4041
"last 1 safari version"
4142
]
43+
},
44+
"devDependencies": {
45+
"@types/styled-components": "^5.1.7"
4246
}
4347
}

Diff for: src/App.css

-38
This file was deleted.

Diff for: src/App.test.tsx

-9
This file was deleted.

Diff for: src/App.tsx

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import Button from "./components/Button";
42

53
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+
}}
1811
>
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+
);
2424
}
2525

2626
export default App;

Diff for: src/components/Button.tsx

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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;

Diff for: src/index.css

-13
This file was deleted.

Diff for: src/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import './index.css';
43
import App from './App';
54
import reportWebVitals from './reportWebVitals';
65

Diff for: src/logo.svg

-1
This file was deleted.

0 commit comments

Comments
 (0)