@ -0,0 +1,23 @@ |
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. |
||||
|
||||
# dependencies |
||||
/node_modules |
||||
/.pnp |
||||
.pnp.js |
||||
|
||||
# testing |
||||
/coverage |
||||
|
||||
# production |
||||
/build |
||||
|
||||
# misc |
||||
.DS_Store |
||||
.env.local |
||||
.env.development.local |
||||
.env.test.local |
||||
.env.production.local |
||||
|
||||
npm-debug.log* |
||||
yarn-debug.log* |
||||
yarn-error.log* |
@ -0,0 +1,70 @@ |
||||
# Getting Started with Create React App |
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). |
||||
|
||||
## Available Scripts |
||||
|
||||
In the project directory, you can run: |
||||
|
||||
### `npm start` |
||||
|
||||
Runs the app in the development mode.\ |
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. |
||||
|
||||
The page will reload when you make changes.\ |
||||
You may also see any lint errors in the console. |
||||
|
||||
### `npm test` |
||||
|
||||
Launches the test runner in the interactive watch mode.\ |
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. |
||||
|
||||
### `npm run build` |
||||
|
||||
Builds the app for production to the `build` folder.\ |
||||
It correctly bundles React in production mode and optimizes the build for the best performance. |
||||
|
||||
The build is minified and the filenames include the hashes.\ |
||||
Your app is ready to be deployed! |
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. |
||||
|
||||
### `npm run eject` |
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!** |
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. |
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. |
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. |
||||
|
||||
## Learn More |
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). |
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/). |
||||
|
||||
### Code Splitting |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) |
||||
|
||||
### Analyzing the Bundle Size |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) |
||||
|
||||
### Making a Progressive Web App |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) |
||||
|
||||
### Advanced Configuration |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) |
||||
|
||||
### Deployment |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) |
||||
|
||||
### `npm run build` fails to minify |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
@ -0,0 +1,39 @@ |
||||
{ |
||||
"name": "box", |
||||
"version": "0.1.0", |
||||
"private": true, |
||||
"dependencies": { |
||||
"@testing-library/jest-dom": "^5.16.5", |
||||
"@testing-library/react": "^13.3.0", |
||||
"@testing-library/user-event": "^13.5.0", |
||||
"bootstrap": "^5.2.0", |
||||
"react": "^18.2.0", |
||||
"react-dom": "^18.2.0", |
||||
"react-scripts": "5.0.1", |
||||
"web-vitals": "^2.1.4" |
||||
}, |
||||
"scripts": { |
||||
"start": "react-scripts start", |
||||
"build": "react-scripts build", |
||||
"test": "react-scripts test", |
||||
"eject": "react-scripts eject" |
||||
}, |
||||
"eslintConfig": { |
||||
"extends": [ |
||||
"react-app", |
||||
"react-app/jest" |
||||
] |
||||
}, |
||||
"browserslist": { |
||||
"production": [ |
||||
">0.2%", |
||||
"not dead", |
||||
"not op_mini all" |
||||
], |
||||
"development": [ |
||||
"last 1 chrome version", |
||||
"last 1 firefox version", |
||||
"last 1 safari version" |
||||
] |
||||
} |
||||
} |
After Width: | Height: | Size: 3.8 KiB |
@ -0,0 +1,20 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
||||
<meta name="theme-color" content="#000000" /> |
||||
<meta name="description" content="Web site created using create-react-app" /> |
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> |
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> |
||||
<title>Box</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<noscript>You need to enable JavaScript to run this app.</noscript> |
||||
<div id="root"></div> |
||||
</body> |
||||
|
||||
</html> |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,25 @@ |
||||
{ |
||||
"short_name": "React App", |
||||
"name": "Create React App Sample", |
||||
"icons": [ |
||||
{ |
||||
"src": "favicon.ico", |
||||
"sizes": "64x64 32x32 24x24 16x16", |
||||
"type": "image/x-icon" |
||||
}, |
||||
{ |
||||
"src": "logo192.png", |
||||
"type": "image/png", |
||||
"sizes": "192x192" |
||||
}, |
||||
{ |
||||
"src": "logo512.png", |
||||
"type": "image/png", |
||||
"sizes": "512x512" |
||||
} |
||||
], |
||||
"start_url": ".", |
||||
"display": "standalone", |
||||
"theme_color": "#000000", |
||||
"background_color": "#ffffff" |
||||
} |
@ -0,0 +1,3 @@ |
||||
# https://www.robotstxt.org/robotstxt.html |
||||
User-agent: * |
||||
Disallow: |
@ -0,0 +1,76 @@ |
||||
import React, { Component } from 'react'; |
||||
|
||||
|
||||
class Box extends Component { |
||||
state = { |
||||
x: 1, |
||||
width: 500, |
||||
height: 500, |
||||
}; |
||||
|
||||
|
||||
|
||||
btn_1_style = { |
||||
margin: "20px 20px 0px 150px", |
||||
} |
||||
|
||||
btn_2_style = { |
||||
margin: "20px 0px 0px 0px", |
||||
} |
||||
|
||||
|
||||
handleClickLeft = (step) => { |
||||
this.setState({ |
||||
x: this.state.x - step, |
||||
width: this.state.width - 50, |
||||
height: this.state.height - 50, |
||||
}); |
||||
|
||||
console.log(step,this.state.width,this.state.height); |
||||
} |
||||
|
||||
handleClickRight = (step) => { |
||||
this.setState({ |
||||
x: this.state.x + step, |
||||
width: this.state.width + 50, |
||||
height: this.state.height + 50, |
||||
}); |
||||
|
||||
|
||||
console.log(step,this.state.width,this.state.height); |
||||
} |
||||
|
||||
getStyle() { |
||||
let styles = { |
||||
width: this.state.width, |
||||
height: this.state.height, |
||||
backgroundColor: "lightblue", |
||||
textAlign: "center", |
||||
lineHeight: this.state.height + "px", |
||||
fontSize: "20px", |
||||
color: "red", |
||||
}; |
||||
|
||||
if (this.state.x % 2 === 0) { |
||||
styles.backgroundColor = "orange"; |
||||
styles.color = "black"; |
||||
} |
||||
return styles; |
||||
} |
||||
|
||||
|
||||
render() { |
||||
return ( |
||||
<React.Fragment> |
||||
<div style={this.getStyle()}>{this.toString()}</div> |
||||
<button onClick={() => this.handleClickLeft(10)} className='btn btn-success sm' style={this.btn_1_style}>Smaller</button> |
||||
<button onClick={() => this.handleClickRight(10)} className='btn btn-danger sm' style={this.btn_2_style}>Larger</button> |
||||
</React.Fragment>); |
||||
} |
||||
|
||||
toString() { |
||||
return `x: ${this.state.x}\n width: ${this.state.width}\n height: ${this.state.height}`; |
||||
} |
||||
} |
||||
|
||||
export default Box; |
@ -0,0 +1,13 @@ |
||||
body { |
||||
margin: 0; |
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', |
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', |
||||
sans-serif; |
||||
-webkit-font-smoothing: antialiased; |
||||
-moz-osx-font-smoothing: grayscale; |
||||
} |
||||
|
||||
code { |
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', |
||||
monospace; |
||||
} |
@ -0,0 +1,12 @@ |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom/client'; |
||||
import './index.css'; |
||||
import Box from './components/box'; |
||||
import "bootstrap/dist/css/bootstrap.css" |
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root')); |
||||
root.render( |
||||
<React.StrictMode> |
||||
<Box /> |
||||
</React.StrictMode> |
||||
); |
@ -0,0 +1,23 @@ |
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. |
||||
|
||||
# dependencies |
||||
/node_modules |
||||
/.pnp |
||||
.pnp.js |
||||
|
||||
# testing |
||||
/coverage |
||||
|
||||
# production |
||||
/build |
||||
|
||||
# misc |
||||
.DS_Store |
||||
.env.local |
||||
.env.development.local |
||||
.env.test.local |
||||
.env.production.local |
||||
|
||||
npm-debug.log* |
||||
yarn-debug.log* |
||||
yarn-error.log* |
@ -0,0 +1,70 @@ |
||||
# Getting Started with Create React App |
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). |
||||
|
||||
## Available Scripts |
||||
|
||||
In the project directory, you can run: |
||||
|
||||
### `npm start` |
||||
|
||||
Runs the app in the development mode.\ |
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. |
||||
|
||||
The page will reload when you make changes.\ |
||||
You may also see any lint errors in the console. |
||||
|
||||
### `npm test` |
||||
|
||||
Launches the test runner in the interactive watch mode.\ |
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. |
||||
|
||||
### `npm run build` |
||||
|
||||
Builds the app for production to the `build` folder.\ |
||||
It correctly bundles React in production mode and optimizes the build for the best performance. |
||||
|
||||
The build is minified and the filenames include the hashes.\ |
||||
Your app is ready to be deployed! |
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. |
||||
|
||||
### `npm run eject` |
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!** |
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. |
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. |
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. |
||||
|
||||
## Learn More |
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). |
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/). |
||||
|
||||
### Code Splitting |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) |
||||
|
||||
### Analyzing the Bundle Size |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) |
||||
|
||||
### Making a Progressive Web App |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) |
||||
|
||||
### Advanced Configuration |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) |
||||
|
||||
### Deployment |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) |
||||
|
||||
### `npm run build` fails to minify |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
@ -0,0 +1,39 @@ |
||||
{ |
||||
"name": "calc", |
||||
"version": "0.1.0", |
||||
"private": true, |
||||
"dependencies": { |
||||
"@testing-library/jest-dom": "^5.16.5", |
||||
"@testing-library/react": "^13.3.0", |
||||
"@testing-library/user-event": "^13.5.0", |
||||
"bootstrap": "^5.2.0", |
||||
"react": "^18.2.0", |
||||
"react-dom": "^18.2.0", |
||||
"react-scripts": "5.0.1", |
||||
"web-vitals": "^2.1.4" |
||||
}, |
||||
"scripts": { |
||||
"start": "react-scripts start", |
||||
"build": "react-scripts build", |
||||
"test": "react-scripts test", |
||||
"eject": "react-scripts eject" |
||||
}, |
||||
"eslintConfig": { |
||||
"extends": [ |
||||
"react-app", |
||||
"react-app/jest" |
||||
] |
||||
}, |
||||
"browserslist": { |
||||
"production": [ |
||||
">0.2%", |
||||
"not dead", |
||||
"not op_mini all" |
||||
], |
||||
"development": [ |
||||
"last 1 chrome version", |
||||
"last 1 firefox version", |
||||
"last 1 safari version" |
||||
] |
||||
} |
||||
} |
After Width: | Height: | Size: 3.8 KiB |
@ -0,0 +1,20 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
||||
<meta name="theme-color" content="#000000" /> |
||||
<meta name="description" content="Web site created using create-react-app" /> |
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> |
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> |
||||
<title>React App</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<noscript>You need to enable JavaScript to run this app.</noscript> |
||||
<div id="root"></div> |
||||
</body> |
||||
|
||||
</html> |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,25 @@ |
||||
{ |
||||
"short_name": "React App", |
||||
"name": "Create React App Sample", |
||||
"icons": [ |
||||
{ |
||||
"src": "favicon.ico", |
||||
"sizes": "64x64 32x32 24x24 16x16", |
||||
"type": "image/x-icon" |
||||
}, |
||||
{ |
||||
"src": "logo192.png", |
||||
"type": "image/png", |
||||
"sizes": "192x192" |
||||
}, |
||||
{ |
||||
"src": "logo512.png", |
||||
"type": "image/png", |
||||
"sizes": "512x512" |
||||
} |
||||
], |
||||
"start_url": ".", |
||||
"display": "standalone", |
||||
"theme_color": "#000000", |
||||
"background_color": "#ffffff" |
||||
} |
@ -0,0 +1,3 @@ |
||||
# https://www.robotstxt.org/robotstxt.html |
||||
User-agent: * |
||||
Disallow: |
@ -0,0 +1,13 @@ |
||||
body { |
||||
margin: 0; |
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', |
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', |
||||
sans-serif; |
||||
-webkit-font-smoothing: antialiased; |
||||
-moz-osx-font-smoothing: grayscale; |
||||
} |
||||
|
||||
code { |
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', |
||||
monospace; |
||||
} |
@ -0,0 +1,12 @@ |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom/client'; |
||||
import './index.css'; |
||||
import 'bootstrap/dist/css/bootstrap.css' |
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root')); |
||||
root.render( |
||||
<React.StrictMode> |
||||
</React.StrictMode> |
||||
); |
||||
|
||||
|
@ -0,0 +1,23 @@ |
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. |
||||
|
||||
# dependencies |
||||
/node_modules |
||||
/.pnp |
||||
.pnp.js |
||||
|
||||
# testing |
||||
/coverage |
||||
|
||||
# production |
||||
/build |
||||
|
||||
# misc |
||||
.DS_Store |
||||
.env.local |
||||
.env.development.local |
||||
.env.test.local |
||||
.env.production.local |
||||
|
||||
npm-debug.log* |
||||
yarn-debug.log* |
||||
yarn-error.log* |
@ -0,0 +1,70 @@ |
||||
# Getting Started with Create React App |
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). |
||||
|
||||
## Available Scripts |
||||
|
||||
In the project directory, you can run: |
||||
|
||||
### `npm start` |
||||
|
||||
Runs the app in the development mode.\ |
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. |
||||
|
||||
The page will reload when you make changes.\ |
||||
You may also see any lint errors in the console. |
||||
|
||||
### `npm test` |
||||
|
||||
Launches the test runner in the interactive watch mode.\ |
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. |
||||
|
||||
### `npm run build` |
||||
|
||||
Builds the app for production to the `build` folder.\ |
||||
It correctly bundles React in production mode and optimizes the build for the best performance. |
||||
|
||||
The build is minified and the filenames include the hashes.\ |
||||
Your app is ready to be deployed! |
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. |
||||
|
||||
### `npm run eject` |
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!** |
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. |
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. |
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. |
||||
|
||||
## Learn More |
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). |
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/). |
||||
|
||||
### Code Splitting |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) |
||||
|
||||
### Analyzing the Bundle Size |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) |
||||
|
||||
### Making a Progressive Web App |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) |
||||
|
||||
### Advanced Configuration |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) |
||||
|
||||
### Deployment |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) |
||||
|
||||
### `npm run build` fails to minify |
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
@ -0,0 +1,39 @@ |
||||
{ |
||||
"name": "solutions", |
||||
"version": "0.1.0", |
||||
"private": true, |
||||
"dependencies": { |
||||
"@testing-library/jest-dom": "^5.16.5", |
||||
"@testing-library/react": "^13.3.0", |
||||
"@testing-library/user-event": "^13.5.0", |
||||
"bootstrap": "^5.2.0", |
||||
"react": "^18.2.0", |
||||
"react-dom": "^18.2.0", |
||||
"react-scripts": "5.0.1", |
||||
"web-vitals": "^2.1.4" |
||||
}, |
||||
"scripts": { |
||||
"start": "react-scripts start", |
||||
"build": "react-scripts build", |
||||
"test": "react-scripts test", |
||||
"eject": "react-scripts eject" |
||||
}, |
||||
"eslintConfig": { |
||||
"extends": [ |
||||
"react-app", |
||||
"react-app/jest" |
||||
] |
||||
}, |
||||
"browserslist": { |
||||
"production": [ |
||||
">0.2%", |
||||
"not dead", |
||||
"not op_mini all" |
||||
], |
||||
"development": [ |
||||
"last 1 chrome version", |
||||
"last 1 firefox version", |
||||
"last 1 safari version" |
||||
] |
||||
} |
||||
} |
After Width: | Height: | Size: 3.8 KiB |
@ -0,0 +1,21 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
||||
<meta name="theme-color" content="#000000" /> |
||||
<meta |
||||
name="description" |
||||
content="Web site created using create-react-app" |
||||
/> |
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> |
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> |
||||
<title>Solutions</title> |
||||
|
||||
</head> |
||||
<body> |
||||
<noscript>You need to enable JavaScript to run this app.</noscript> |
||||
<div id="root"></div> |
||||
</body> |
||||
</html> |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,25 @@ |
||||
{ |
||||
"short_name": "React App", |
||||
"name": "Create React App Sample", |
||||
"icons": [ |
||||
{ |
||||
"src": "favicon.ico", |
||||
"sizes": "64x64 32x32 24x24 16x16", |
||||
"type": "image/x-icon" |
||||
}, |
||||
{ |
||||
"src": "logo192.png", |
||||
"type": "image/png", |
||||
"sizes": "192x192" |
||||
}, |
||||
{ |
||||
"src": "logo512.png", |
||||
"type": "image/png", |
||||
"sizes": "512x512" |
||||
} |
||||
], |
||||
"start_url": ".", |
||||
"display": "standalone", |
||||
"theme_color": "#000000", |
||||
"background_color": "#ffffff" |
||||
} |
@ -0,0 +1,3 @@ |
||||
# https://www.robotstxt.org/robotstxt.html |
||||
User-agent: * |
||||
Disallow: |
@ -0,0 +1,92 @@ |
||||
import React, { Component } from 'react'; |
||||
|
||||
|
||||
class Solutions extends Component { |
||||
state = { |
||||
solutions: [ |
||||
{key: 10,number: 3331,title: "交换数值_10",views: 1111}, |
||||
{key: 11,number: 3332,title: "交换数值_11",views: 1112}, |
||||
{key: 12,number: 3333,title: "交换数值_12",views: 1113}, |
||||
{key: 13,number: 3334,title: "交换数值_13",views: 1114}, |
||||
{key: 14,number: 3335,title: "交换数值_14",views: 1115}, |
||||
{key: 15,number: 3336,title: "交换数值_15",views: 1116}, |
||||
{key: 16,number: 3337,title: "交换数值_16",views: 1117}, |
||||
{key: 17,number: 3338,title: "交换数值_17",views: 1118}, |
||||
] |
||||
} |
||||
|
||||
|
||||
btn_style = { |
||||
margin: "0px 0px 0px 20px", |
||||
} |
||||
|
||||
handleInsert = () => { |
||||
let k = this.state.solutions.length; |
||||
const solutions = [...this.state.solutions, { |
||||
key: this.state.solutions[k-1]['key'] + 1, number:this.state.solutions[k-1]['number'] + 1,title: `交换数值_${this.state.solutions[k-1].key+1}`,views: this.state.solutions[k-1]['views'] + 1, |
||||
}]; |
||||
this.setState({ |
||||
solutions: solutions, |
||||
}) |
||||
} |
||||
|
||||
handleDelete = (s) => { |
||||
// 保留和当前元素不同的其他元素,只删除对应元素 |
||||
const solutions = this.state.solutions.filter(solution => solution !== s); |
||||
this.setState({ |
||||
solutions: solutions, |
||||
}) |
||||
} |
||||
render() { |
||||
|
||||
if (this.state.solutions.length === 0) { |
||||
return ( |
||||
<div id="warning"> |
||||
<div class="alert alert-danger d-flex align-items-center" role="alert"> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:"> |
||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/> |
||||
</svg> |
||||
<div> |
||||
没有更多的题解了 |
||||
</div> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
return ( |
||||
<React.Fragment> |
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light"> |
||||
<div class="container-fluid"> |
||||
<span class="navbar-brand">题解列表</span> |
||||
</div> |
||||
</nav> |
||||
|
||||
<table className="table"> |
||||
<thead> |
||||
<tr> |
||||
<th>#</th> |
||||
<th>标题</th> |
||||
<th>阅读量</th> |
||||
<th>操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{this.state.solutions.map(solution => ( |
||||
<tr key={solution.key}> |
||||
<td>{solution.number}</td> |
||||
<td>{solution.title}</td> |
||||
<td>{solution.views}</td> |
||||
<td> |
||||
<button className='btn btn-danger sm' onClick={() => this.handleDelete(solution)}>删除</button> |
||||
<button className='btn btn-success sm' onClick={() => this.handleInsert()} style={this.btn_style}>添加</button> |
||||
</td> |
||||
</tr> |
||||
))} |
||||
</tbody> |
||||
</table> |
||||
</React.Fragment> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default Solutions; |
@ -0,0 +1,23 @@ |
||||
body { |
||||
margin: 0; |
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', |
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', |
||||
sans-serif; |
||||
-webkit-font-smoothing: antialiased; |
||||
-moz-osx-font-smoothing: grayscale; |
||||
} |
||||
|
||||
code { |
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', |
||||
monospace; |
||||
} |
||||
|
||||
|
||||
#warning { |
||||
width: 500px; |
||||
position: absolute; |
||||
top: calc(40%); |
||||
font-size: larger; |
||||
font-weight: bold; |
||||
left: 500px; |
||||
} |
@ -0,0 +1,14 @@ |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom/client'; |
||||
import Solutions from './components/solutions'; |
||||
import "bootstrap/dist/css/bootstrap.css"; |
||||
import "../src/index.css" |
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root')); |
||||
root.render( |
||||
<React.StrictMode> |
||||
<div className="Container"> |
||||
<Solutions /> |
||||
</div> |
||||
</React.StrictMode> |
||||
); |