Skip to content

Commit 134e4e9

Browse files
committed
add react-ts
1 parent 2c6da17 commit 134e4e9

File tree

19 files changed

+535
-0
lines changed

19 files changed

+535
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.\
15+
You will also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
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.
37+
38+
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.
39+
40+
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.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "read-video-react",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^5.16.4",
7+
"@testing-library/react": "^13.3.0",
8+
"@testing-library/user-event": "^13.5.0",
9+
"@types/jest": "^27.5.2",
10+
"@types/node": "^16.11.45",
11+
"@types/react": "^18.0.15",
12+
"@types/react-dom": "^18.0.6",
13+
"keillion-dynamsoft-javascript-barcode": "^0.20220720101353.0",
14+
"dynamsoft-javascript-barcode": "9.0.2",
15+
"react": "^18.2.0",
16+
"react-dom": "^18.2.0",
17+
"react-scripts": "5.0.1",
18+
"typescript": "^4.7.4",
19+
"web-vitals": "^2.1.4"
20+
},
21+
"scripts": {
22+
"start": "react-scripts start",
23+
"build": "react-scripts build",
24+
"test": "react-scripts test",
25+
"eject": "react-scripts eject"
26+
},
27+
"eslintConfig": {
28+
"extends": [
29+
"react-app",
30+
"react-app/jest"
31+
]
32+
},
33+
"browserslist": {
34+
"production": [
35+
">0.2%",
36+
"not dead",
37+
"not op_mini all"
38+
],
39+
"development": [
40+
"last 1 chrome version",
41+
"last 1 firefox version",
42+
"last 1 safari version"
43+
]
44+
}
45+
}
3.78 KB
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
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" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
Notice the use of %PUBLIC_URL% in the tags above.
15+
It will be replaced with the URL of the `public` folder during the build.
16+
Only files inside the `public` folder can be referenced from the HTML.
17+
18+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
19+
work correctly both with client-side routing and a non-root public URL.
20+
Learn how to configure a non-root public URL by running `npm run build`.
21+
-->
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+
<!--
28+
This HTML file is a template.
29+
If you open it directly in the browser, you will see an empty page.
30+
31+
You can add webfonts, meta tags, or analytics to this file.
32+
The build step will place the bundled scripts into the <body> tag.
33+
34+
To begin the development, run `npm start` or `yarn start`.
35+
To create a production bundle, use `npm run build` or `yarn build`.
36+
-->
37+
</body>
38+
</html>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
height: 5vmin;
7+
pointer-events: none;
8+
}
9+
10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
16+
.App-header {
17+
background-color: #282c34;
18+
min-height: 100vh;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
23+
font-size: calc(10px + 2vmin);
24+
color: white;
25+
}
26+
27+
.App-link {
28+
color: #61dafb;
29+
}
30+
31+
@keyframes App-logo-spin {
32+
from {
33+
transform: rotate(0deg);
34+
}
35+
to {
36+
transform: rotate(360deg);
37+
}
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import './App.css';
3+
import HelloWorld from './components/HelloWorld/HelloWorld';
4+
5+
function App() {
6+
return (
7+
<div className="App">
8+
<HelloWorld></HelloWorld>
9+
</div>
10+
);
11+
}
12+
13+
export default App;
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
.helloWorld {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
justify-content: center;
6+
overflow: hidden;
7+
width: 100%;
8+
height: 100%;
9+
color: #455A64;
10+
}
11+
12+
h1 {
13+
font-size: 1.5em;
14+
}
15+
16+
button {
17+
font-size: 1.5rem;
18+
margin: 1.5vh 0;
19+
border: 1px solid black;
20+
background-color: white;
21+
color: black;
22+
}
23+
24+
span {
25+
font-size: 0.8rem;
26+
}
27+
28+
.latest-result {
29+
display: block;
30+
margin: 0;
31+
padding: 0.4rem 0.8rem;
32+
color: inherit;
33+
width: 80vw;
34+
border: none;
35+
font-size: 1rem;
36+
border-radius: 0.2rem;
37+
text-align: center;
38+
}
39+
40+
.latest-result::placeholder {
41+
color: #B0BEC5;
42+
}
43+
44+
.latest-result:focus {
45+
outline: none;
46+
box-shadow: 0.1rem 0.4rem 0.8rem #fe8e14;
47+
}
48+
49+
#results {
50+
border: 1px dashed grey;
51+
overflow: auto;
52+
width: 80vw;
53+
padding: 2vmin;
54+
margin-bottom: 3vh;
55+
height: 15vh;
56+
}
57+
58+
#results ul {
59+
padding: 0;
60+
margin: 0;
61+
list-style: none;
62+
text-align: left;
63+
font-size: 0.8rem;
64+
}
65+
66+
.resultText {
67+
color: #cE5E04
68+
}
69+
70+
.bigger {
71+
font-size: large;
72+
margin-bottom: 2%;
73+
}
74+
75+
.container {
76+
margin: 2vmin auto;
77+
text-align: center;
78+
font-size: medium;
79+
/* height: 40vh; */
80+
width: 80vw;
81+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import './HelloWorld.css';
2+
import reactLogo from '../../logo.svg';
3+
import "../../dbr"; // import side effects. The license, engineResourcePath, so on.
4+
import { BarcodeReader } from "dynamsoft-javascript-barcode";
5+
import React from 'react';
6+
import VideoDecode from '../VideoDecode/VideoDecode';
7+
import ImgDecode from '../ImgDecode/ImgDecode';
8+
9+
interface isState {
10+
bShowScanner: boolean,
11+
bShowImgDecode: boolean
12+
}
13+
14+
class HelloWorld extends React.Component<any, isState> {
15+
state = {
16+
bShowScanner: true,
17+
bShowImgDecode: false
18+
};
19+
20+
async componentDidMount() {
21+
try {
22+
await BarcodeReader.loadWasm();
23+
} catch (ex: any) {
24+
if (ex.message.indexOf("network connection error")) {
25+
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
26+
console.log(customMsg);
27+
alert(customMsg);
28+
}
29+
throw ex;
30+
}
31+
}
32+
33+
showScanner = () => {
34+
this.setState({
35+
bShowScanner: true,
36+
bShowImgDecode: false
37+
});
38+
}
39+
40+
showImgDecode = () => {
41+
this.setState({
42+
bShowScanner: false,
43+
bShowImgDecode: true
44+
});
45+
}
46+
47+
render() {
48+
return (
49+
<div className="helloWorld">
50+
<h1>Hello World for React<img src={reactLogo} className="App-logo" alt="logo" /></h1>
51+
<div className="btn-group">
52+
<button style={{ marginRight: '10px', backgroundColor: this.state.bShowScanner ? 'rgb(255,174,55)' : 'white' }} onClick={this.showScanner}>Video Decode</button>
53+
<button style={{ backgroundColor: this.state.bShowImgDecode ? 'rgb(255,174,55)' : 'white' }} onClick={this.showImgDecode}>Image Decode</button>
54+
</div>
55+
<div className="container">
56+
{this.state.bShowScanner ? (<VideoDecode></VideoDecode>) : ""}
57+
{this.state.bShowImgDecode ? (<ImgDecode></ImgDecode>) : ""}
58+
</div>
59+
</div>
60+
);
61+
}
62+
}
63+
export default HelloWorld;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.ImgDecode {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
width: 100%;
6+
height: 90%;
7+
border: 1px solid black
8+
}

0 commit comments

Comments
 (0)