Skip to content

Commit f830c3d

Browse files
committed
add button component
1 parent e335e3f commit f830c3d

File tree

7 files changed

+215
-23
lines changed

7 files changed

+215
-23
lines changed

.prettierrc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"trailingComma": "es5",
3-
"tabWidth": 4,
4-
"semi": false,
5-
"singleQuote": false
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": false
66
}

package-lock.json

+152
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@testing-library/react": "^8.0.1",
7+
"dotenv": "^8.0.0",
68
"husky": "^2.4.0",
79
"lint-staged": "^8.2.0",
8-
"prettier": "^1.18.1",
9-
"dotenv": "^8.0.0",
1010
"node-fetch": "^2.6.0",
11+
"prettier": "^1.18.1",
1112
"react": "^16.8.6",
1213
"react-dom": "^16.8.6",
13-
"react-scripts": "3.0.1"
14+
"react-scripts": "3.0.1",
15+
"styled-components": "^4.3.1"
1416
},
1517
"scripts": {
1618
"start": "react-scripts start",

public/index.html

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<!--
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<link
7+
href="https://fonts.googleapis.com/css?family=Bangers&display=swap"
8+
rel="stylesheet"
9+
/>
10+
<meta name="viewport" content="width=device-width, initial-scale=1" />
11+
<meta name="theme-color" content="#000000" />
12+
<!--
913
manifest.json provides metadata used when your web app is installed on a
1014
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1115
-->
12-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
13-
<!--
16+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
17+
<!--
1418
Notice the use of %PUBLIC_URL% in the tags above.
1519
It will be replaced with the URL of the `public` folder during the build.
1620
Only files inside the `public` folder can be referenced from the HTML.
@@ -19,12 +23,12 @@
1923
work correctly both with client-side routing and a non-root public URL.
2024
Learn how to configure a non-root public URL by running `npm run build`.
2125
-->
22-
<title>React App</title>
23-
</head>
24-
<body>
25-
<noscript>You need to enable JavaScript to run this app.</noscript>
26-
<div id="root"></div>
27-
<!--
26+
<title>React App</title>
27+
</head>
28+
<body>
29+
<noscript>You need to enable JavaScript to run this app.</noscript>
30+
<div id="root"></div>
31+
<!--
2832
This HTML file is a template.
2933
If you open it directly in the browser, you will see an empty page.
3034
@@ -33,6 +37,5 @@
3337
3438
To begin the development, run `npm start` or `yarn start`.
3539
To create a production bundle, use `npm run build` or `yarn build`.
36-
-->
37-
</body>
40+
--></body>
3841
</html>

src/App.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22
import logo from "./logo.svg"
33
import "./App.css"
4+
import Button from "./components/Button"
45

56
function App() {
67
const [data, setData] = React.useState(null)
@@ -32,6 +33,9 @@ function App() {
3233
Learn React
3334
</a>
3435
</header>
36+
<main>
37+
<Button>Click me!</Button>
38+
</main>
3539
</div>
3640
)
3741
}

src/components/Button.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react"
2+
import styled from "styled-components"
3+
4+
const StyledButton = styled.button`
5+
box-shadow: 4px 8px 4px rgba(0, 0, 0, 0.25);
6+
font-family: Bangers;
7+
font-style: normal;
8+
font-weight: normal;
9+
font-size: 2em;
10+
padding: 0.5em;
11+
color: black
12+
background: white;
13+
border: 4px solid black;
14+
box-sizing: border-box;
15+
border-radius: 3em;
16+
`
17+
18+
const Button = props => {
19+
return <StyledButton data-testid="button">{props.children}</StyledButton>
20+
}
21+
22+
export default Button

src/components/Button.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from "react"
2+
import ReactDOM from "react-dom"
3+
import { render, fireEvent } from "@testing-library/react"
4+
import Button from "./Button"
5+
6+
test("Button renders", () => {
7+
const { getByTestId } = render(<Button />)
8+
getByTestId("button")
9+
})

0 commit comments

Comments
 (0)