Skip to content

Commit 2b5b461

Browse files
committed
setting up
1 parent 08c316f commit 2b5b461

17 files changed

+3636
-3220
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
44

55
In the project directory, you can run:
66

7-
### `npm start`
7+
### `yarn start`
88

9-
Runs the app in the development mode.<br>
9+
Runs the app in the development mode.<br />
1010
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
1111

12-
The page will reload if you make edits.<br>
12+
The page will reload if you make edits.<br />
1313
You will also see any lint errors in the console.
1414

15-
### `npm test`
15+
### `yarn test`
1616

17-
Launches the test runner in the interactive watch mode.<br>
17+
Launches the test runner in the interactive watch mode.<br />
1818
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
1919

20-
### `npm run build`
20+
### `yarn build`
2121

22-
Builds the app for production to the `build` folder.<br>
22+
Builds the app for production to the `build` folder.<br />
2323
It correctly bundles React in production mode and optimizes the build for the best performance.
2424

25-
The build is minified and the filenames include the hashes.<br>
25+
The build is minified and the filenames include the hashes.<br />
2626
Your app is ready to be deployed!
2727

2828
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
2929

30-
### `npm run eject`
30+
### `yarn eject`
3131

3232
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
3333

@@ -63,6 +63,6 @@ This section has moved here: https://facebook.github.io/create-react-app/docs/ad
6363

6464
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
6565

66-
### `npm run build` fails to minify
66+
### `yarn build` fails to minify
6767

6868
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

package.json

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2-
"name": "test-admin",
2+
"name": "react-admin-tutorial",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@testing-library/jest-dom": "^4.2.4",
7+
"@testing-library/react": "^9.3.2",
8+
"@testing-library/user-event": "^7.1.2",
69
"prop-types": "^15.7.2",
7-
"ra-data-json-server": "^2.8.0",
8-
"react": "^16.8.4",
9-
"react-admin": "^2.8.2",
10-
"react-dom": "^16.8.4",
11-
"react-scripts": "2.1.8"
10+
"ra-data-json-server": "^3.1.1",
11+
"react": "^16.12.0",
12+
"react-admin": "^3.1.1",
13+
"react-dom": "^16.12.0",
14+
"react-scripts": "3.3.0"
1215
},
1316
"scripts": {
1417
"start": "react-scripts start",
@@ -19,10 +22,16 @@
1922
"eslintConfig": {
2023
"extends": "react-app"
2124
},
22-
"browserslist": [
23-
">0.2%",
24-
"not dead",
25-
"not ie <= 11",
26-
"not op_mini all"
27-
]
25+
"browserslist": {
26+
"production": [
27+
">0.2%",
28+
"not dead",
29+
"not op_mini all"
30+
],
31+
"development": [
32+
"last 1 chrome version",
33+
"last 1 firefox version",
34+
"last 1 safari version"
35+
]
36+
}
2837
}

public/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
68
<meta
7-
name="viewport"
8-
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9+
name="description"
10+
content="Web site created using create-react-app"
911
/>
10-
<meta name="theme-color" content="#000000" />
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1113
<!--
1214
manifest.json provides metadata used when your web app is installed on a
1315
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

public/logo192.png

5.22 KB
Loading

public/logo512.png

9.44 KB
Loading

public/manifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
"src": "favicon.ico",
77
"sizes": "64x64 32x32 24x24 16x16",
88
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
919
}
1020
],
1121
"start_url": ".",

public/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *

src/App.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
}
44

55
.App-logo {
6-
animation: App-logo-spin infinite 20s linear;
76
height: 40vmin;
87
pointer-events: none;
98
}
109

10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
1116
.App-header {
1217
background-color: #282c34;
1318
min-height: 100vh;

src/App.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
// Added Menu Icons
2-
// https://marmelab.com/react-admin/Tutorial.html
3-
41
import React from 'react';
5-
import { Admin, Resource } from 'react-admin';
6-
import { PostList, PostEdit, PostCreate } from './posts'
7-
import { UserList } from './users'
8-
import jsonServerProvider from 'ra-data-json-server';
9-
import PostIcon from '@material-ui/icons/Book'
10-
import UserIcon from '@material-ui/icons/Group'
11-
12-
const dataProvider = jsonServerProvider('http://jsonplaceholder.typicode.com');
2+
import logo from './logo.svg';
3+
import './App.css';
134

14-
const App = () => (
15-
<Admin dataProvider={dataProvider} >
16-
<Resource name="posts" list={PostList} edit={PostEdit} create={PostCreate} icon={PostIcon} />
17-
<Resource name="users" list={UserList} icon={UserIcon} />
18-
</Admin>
19-
)
5+
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.js</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"
18+
>
19+
Learn React
20+
</a>
21+
</header>
22+
</div>
23+
);
24+
}
2025

2126
export default App;

src/App.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { render } from '@testing-library/react';
33
import App from './App';
44

5-
it('renders without crashing', () => {
6-
const div = document.createElement('div');
7-
ReactDOM.render(<App />, div);
8-
ReactDOM.unmountComponentAtNode(div);
5+
test('renders learn react link', () => {
6+
const { getByText } = render(<App />);
7+
const linkElement = getByText(/learn react/i);
8+
expect(linkElement).toBeInTheDocument();
99
});

src/MyUrlField.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/index.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
body {
22
margin: 0;
3-
padding: 0;
4-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
5-
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
3+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
65
sans-serif;
76
-webkit-font-smoothing: antialiased;
87
-moz-osx-font-smoothing: grayscale;
98
}
109

1110
code {
12-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1312
monospace;
1413
}

src/posts.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/serviceWorker.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const isLocalhost = Boolean(
1414
window.location.hostname === 'localhost' ||
1515
// [::1] is the IPv6 localhost address.
1616
window.location.hostname === '[::1]' ||
17-
// 127.0.0.1/8 is considered localhost for IPv4.
17+
// 127.0.0.0/8 are considered localhost for IPv4.
1818
window.location.hostname.match(
1919
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
2020
)
@@ -100,7 +100,9 @@ function registerValidSW(swUrl, config) {
100100

101101
function checkValidServiceWorker(swUrl, config) {
102102
// Check if the service worker can be found. If it can't reload the page.
103-
fetch(swUrl)
103+
fetch(swUrl, {
104+
headers: { 'Service-Worker': 'script' }
105+
})
104106
.then(response => {
105107
// Ensure service worker exists, and that we really are getting a JS file.
106108
const contentType = response.headers.get('content-type');

src/setupTests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import '@testing-library/jest-dom/extend-expect';

src/users.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)